source: branches/version-2_5-dev/test/class/util/SC_Utils_Test.php @ 20764

Revision 20764, 3.9 KB checked in by nanasess, 13 years ago (diff)

#601 (コピーライトの更新)

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Id
  • Property svn:mime-type set to text/x-httpd-php; charset=UTF-8
Line 
1<?php
2/*
3 * This file is part of EC-CUBE
4 *
5 * Copyright(c) 2000-2011 LOCKON CO.,LTD. All Rights Reserved.
6 *
7 * http://www.lockon.co.jp/
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
22 */
23
24// {{{ requires
25require_once(realpath(dirname(__FILE__)) . '/../../require.php');
26require_once(realpath(dirname(__FILE__)) . '/../../../data/class/pages/LC_Page_Ex.php');
27
28/**
29 * SC_Utils のテストケース.
30 *
31 * @package Page
32 * @author LOCKON CO.,LTD.
33 * @version $Id:LC_Page_Test.php 15116 2007-07-23 11:32:53Z nanasess $
34 */
35class SC_Utils_Test extends PHPUnit_Framework_TestCase {
36
37    // }}}
38    // {{{ functions
39
40    /**
41     * SC_Utils::getRealURL() のテストケース.
42     *
43     * 変換無し
44     */
45    function testGetRealURL_変換無し() {
46        $url = "http://www.example.jp/admin/index.php";
47
48        $expected = "http://www.example.jp/admin/index.php";
49        $actual = SC_Utils::getRealURL($url);
50
51        $this->assertEquals($expected, $actual);
52    }
53
54    function testGetRealURL_変換有() {
55        $url = "http://www.example.jp/admin/../index.php";
56
57        $expected = "http://www.example.jp/index.php";
58        $actual = SC_Utils::getRealURL($url);
59
60        $this->assertEquals($expected, $actual);
61    }
62
63    function testGetRealURL_空のディレクトリ() {
64        $url = "http://www.example.jp/admin/..///index.php";
65
66        $expected = "http://www.example.jp/index.php";
67        $actual = SC_Utils::getRealURL($url);
68
69        $this->assertEquals($expected, $actual);
70    }
71
72    function testGetRealURL_Dotのディレクトリ() {
73        $url = "http://www.example.jp/admin/././../index.php";
74
75        $expected = "http://www.example.jp/index.php";
76        $actual = SC_Utils::getRealURL($url);
77
78        $this->assertEquals($expected, $actual);
79    }
80
81    function testIsBlank() {
82        $val = "";
83        $this->assertTrue(SC_Utils::isBlank($val));
84
85        $valIsNotBlank = "\x00..\x1F  a \n\t";
86        $this->assertTrue(SC_Utils::isBlank($val));
87
88        $wideSpace = " ";
89        $this->assertTrue(SC_Utils::isBlank($wideSpace));
90        // greedy is false
91        $this->assertFalse(SC_Utils::isBlank($wideSpace, false));
92
93        $array = array();
94        $this->assertTrue(SC_Utils::isBlank($array));
95
96        $nestsArray = array(array(array()));
97        $this->assertTrue(SC_Utils::isBlank($nestsArray));
98        // greedy is false
99        $this->assertFalse(SC_Utils::isBlank($nestsArray, false));
100
101        $nestsArrayIsNotBlank = array(array(array("1")));
102        $this->assertFalse(SC_Utils::isBlank($nestsArrayIsNotBlank));
103        // greedy is false
104        $this->assertFalse(SC_Utils::isBlank($nestsArrayIsNotBlank, false));
105
106        $wideSpaceAndBlank = array(array(" \n "));
107        $this->assertTrue(SC_Utils::isBlank($wideSpaceAndBlank));
108        // greedy is false
109        $this->assertFalse(SC_Utils::isBlank($wideSpaceAndBlank, false));
110
111        $wideSpaceIsNotBlank = array(array(" \na "));
112        $this->assertFalse(SC_Utils::isBlank($wideSpaceIsNotBlank));
113        // greedy is false
114        $this->assertFalse(SC_Utils::isBlank($wideSpaceIsNotBlank, false));
115
116        $zero = 0;
117        $this->assertFalse(SC_Utils::isBlank($zero));
118        $this->assertFalse(SC_Utils::isBlank($zero, false));
119    }
120}
121?>
Note: See TracBrowser for help on using the repository browser.