1 | <?php |
---|
2 | |
---|
3 | $HOME = realpath(dirname(__FILE__)) . "/../../../.."; |
---|
4 | require_once($HOME . "/tests/class/Common_TestCase.php"); |
---|
5 | /* |
---|
6 | * This file is part of EC-CUBE |
---|
7 | * |
---|
8 | * Copyright(c) 2000-2013 LOCKON CO.,LTD. All Rights Reserved. |
---|
9 | * |
---|
10 | * http://www.lockon.co.jp/ |
---|
11 | * |
---|
12 | * This program is free software; you can redistribute it and/or |
---|
13 | * modify it under the terms of the GNU General Public License |
---|
14 | * as published by the Free Software Foundation; either version 2 |
---|
15 | * of the License, or (at your option) any later version. |
---|
16 | * |
---|
17 | * This program is distributed in the hope that it will be useful, |
---|
18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
20 | * GNU General Public License for more details. |
---|
21 | * |
---|
22 | * You should have received a copy of the GNU General Public License |
---|
23 | * along with this program; if not, write to the Free Software |
---|
24 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
---|
25 | */ |
---|
26 | |
---|
27 | /** |
---|
28 | * SC_Utils::isBlank()のテストクラス. |
---|
29 | * 元々test/class/以下にあったテストを移行しています. |
---|
30 | * |
---|
31 | * @author Hiroko Tamagawa |
---|
32 | * @version $Id$ |
---|
33 | */ |
---|
34 | class SC_Utils_isBlankTest extends Common_TestCase |
---|
35 | { |
---|
36 | |
---|
37 | |
---|
38 | protected function setUp() |
---|
39 | { |
---|
40 | // parent::setUp(); |
---|
41 | } |
---|
42 | |
---|
43 | protected function tearDown() |
---|
44 | { |
---|
45 | // parent::tearDown(); |
---|
46 | } |
---|
47 | |
---|
48 | ///////////////////////////////////////// |
---|
49 | public function testIsBlank_0バイト文字列の場合_trueが返る() |
---|
50 | { |
---|
51 | $input = ''; |
---|
52 | $this->assertTrue(SC_Utils::isBlank($input), $input); |
---|
53 | } |
---|
54 | |
---|
55 | public function testIsBlank_全角スペースの場合_trueが返る() |
---|
56 | { |
---|
57 | $input = ' '; |
---|
58 | $this->assertTrue(SC_Utils::isBlank($input), $input); |
---|
59 | } |
---|
60 | |
---|
61 | public function testIsBlank_greedy指定なしで全角スペースの場合_falseが返る() |
---|
62 | { |
---|
63 | $input = ' '; |
---|
64 | $this->assertFalse(SC_Utils::isBlank($input, false), $input); |
---|
65 | } |
---|
66 | |
---|
67 | public function testIsBlank_空の配列の場合_trueが返る() |
---|
68 | { |
---|
69 | $input = array(); |
---|
70 | $this->assertTrue(SC_Utils::isBlank($input), $input); |
---|
71 | } |
---|
72 | |
---|
73 | public function testIsBlank_ネストした配列の場合_trueが返る() |
---|
74 | { |
---|
75 | $input = array(array(array())); |
---|
76 | $this->assertTrue(SC_Utils::isBlank($input), $input); |
---|
77 | } |
---|
78 | |
---|
79 | public function testIsBlank_greedy指定なしでネストした配列の場合_falseが返る() |
---|
80 | { |
---|
81 | $input = array(array(array())); |
---|
82 | $this->assertFalse(SC_Utils::isBlank($input, false), $input); |
---|
83 | } |
---|
84 | |
---|
85 | public function testIsBlank_空でない配列の場合_falseが返る() |
---|
86 | { |
---|
87 | $input = array(array(array('1'))); |
---|
88 | $this->assertFalse(SC_Utils::isBlank($input), $input); |
---|
89 | } |
---|
90 | |
---|
91 | public function testIsBlank_greedy指定なしで空でない配列の場合_falseが返る() |
---|
92 | { |
---|
93 | $input = array(array(array('1'))); |
---|
94 | $this->assertFalse(SC_Utils::isBlank($input, false), $input); |
---|
95 | } |
---|
96 | |
---|
97 | public function testIsBlank_全角スペースと空白の組み合わせの場合_trueが返る() |
---|
98 | { |
---|
99 | $input = " \n "; |
---|
100 | $this->assertTrue(SC_Utils::isBlank($input), $input); |
---|
101 | } |
---|
102 | |
---|
103 | public function testIsBlank_greedy指定なしで全角スペースと空白の組み合わせの場合_falseが返る() |
---|
104 | { |
---|
105 | $input = " \n "; |
---|
106 | $this->assertFalse(SC_Utils::isBlank($input, false), $input); |
---|
107 | } |
---|
108 | |
---|
109 | public function testIsBlank_全角スペースと非空白の組み合わせの場合_falseが返る() |
---|
110 | { |
---|
111 | $input = ' A '; |
---|
112 | $this->assertFalse(SC_Utils::isBlank($input), $input); |
---|
113 | } |
---|
114 | |
---|
115 | public function testIsBlank_greedy指定なしで全角スペースと非空白の組み合わせの場合_falseが返る() |
---|
116 | { |
---|
117 | $input = ' A '; |
---|
118 | $this->assertFalse(SC_Utils::isBlank($input, false), $input); |
---|
119 | } |
---|
120 | |
---|
121 | public function testIsBlank_数値のゼロを入力した場合_falseが返る() |
---|
122 | { |
---|
123 | $input = 0; |
---|
124 | $this->assertFalse(SC_Utils::isBlank($input), $input); |
---|
125 | } |
---|
126 | |
---|
127 | public function testIsBlank_値が空の配列を入力した場合_trueが返る() |
---|
128 | { |
---|
129 | $input = array(""); |
---|
130 | $this->assertTrue(SC_Utils::isBlank($input), $input); |
---|
131 | } |
---|
132 | |
---|
133 | public function testIsBlank_全てのホワイトスペースを並べた場合_trueが返る() |
---|
134 | { |
---|
135 | $input = " \t \n\r\x0B\0"; |
---|
136 | $this->assertTrue(SC_Utils::isBlank($input), $input); |
---|
137 | } |
---|
138 | |
---|
139 | public function testIsBlank_通常の文字が含まれている場合_falseが返る() |
---|
140 | { |
---|
141 | $input = " AB \n\t"; |
---|
142 | $this->assertFalse(SC_Utils::isBlank($input), $input); |
---|
143 | } |
---|
144 | |
---|
145 | ////////////////////////////////////////// |
---|
146 | } |
---|
147 | |
---|