| 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 | protected function setUp() { |
|---|
| 38 | // parent::setUp(); |
|---|
| 39 | } |
|---|
| 40 | |
|---|
| 41 | protected function tearDown() { |
|---|
| 42 | // parent::tearDown(); |
|---|
| 43 | } |
|---|
| 44 | |
|---|
| 45 | ///////////////////////////////////////// |
|---|
| 46 | public function testIsBlank_0バイト文字列の場合_trueが返る() { |
|---|
| 47 | $input = ''; |
|---|
| 48 | $this->assertTrue(SC_Utils::isBlank($input), $input); |
|---|
| 49 | } |
|---|
| 50 | |
|---|
| 51 | public function testIsBlank_全角スペースの場合_trueが返る() { |
|---|
| 52 | $input = ' '; |
|---|
| 53 | $this->assertTrue(SC_Utils::isBlank($input), $input); |
|---|
| 54 | } |
|---|
| 55 | |
|---|
| 56 | public function testIsBlank_greedy指定なしで全角スペースの場合_falseが返る() { |
|---|
| 57 | $input = ' '; |
|---|
| 58 | $this->assertFalse(SC_Utils::isBlank($input, false), $input); |
|---|
| 59 | } |
|---|
| 60 | |
|---|
| 61 | public function testIsBlank_空の配列の場合_trueが返る() { |
|---|
| 62 | $input = array(); |
|---|
| 63 | $this->assertTrue(SC_Utils::isBlank($input), $input); |
|---|
| 64 | } |
|---|
| 65 | |
|---|
| 66 | public function testIsBlank_ネストした配列の場合_trueが返る() { |
|---|
| 67 | $input = array(array(array())); |
|---|
| 68 | $this->assertTrue(SC_Utils::isBlank($input), $input); |
|---|
| 69 | } |
|---|
| 70 | |
|---|
| 71 | public function testIsBlank_greedy指定なしでネストした配列の場合_falseが返る() { |
|---|
| 72 | $input = array(array(array())); |
|---|
| 73 | $this->assertFalse(SC_Utils::isBlank($input, false), $input); |
|---|
| 74 | } |
|---|
| 75 | |
|---|
| 76 | public function testIsBlank_空でない配列の場合_falseが返る() { |
|---|
| 77 | $input = array(array(array('1'))); |
|---|
| 78 | $this->assertFalse(SC_Utils::isBlank($input), $input); |
|---|
| 79 | } |
|---|
| 80 | |
|---|
| 81 | public function testIsBlank_greedy指定なしで空でない配列の場合_falseが返る() { |
|---|
| 82 | $input = array(array(array('1'))); |
|---|
| 83 | $this->assertFalse(SC_Utils::isBlank($input, false), $input); |
|---|
| 84 | } |
|---|
| 85 | |
|---|
| 86 | public function testIsBlank_全角スペースと空白の組み合わせの場合_trueが返る() { |
|---|
| 87 | $input = " \n "; |
|---|
| 88 | $this->assertTrue(SC_Utils::isBlank($input), $input); |
|---|
| 89 | } |
|---|
| 90 | |
|---|
| 91 | public function testIsBlank_greedy指定なしで全角スペースと空白の組み合わせの場合_falseが返る() { |
|---|
| 92 | $input = " \n "; |
|---|
| 93 | $this->assertFalse(SC_Utils::isBlank($input, false), $input); |
|---|
| 94 | } |
|---|
| 95 | |
|---|
| 96 | public function testIsBlank_全角スペースと非空白の組み合わせの場合_falseが返る() { |
|---|
| 97 | $input = ' A '; |
|---|
| 98 | $this->assertFalse(SC_Utils::isBlank($input), $input); |
|---|
| 99 | } |
|---|
| 100 | |
|---|
| 101 | public function testIsBlank_greedy指定なしで全角スペースと非空白の組み合わせの場合_falseが返る() { |
|---|
| 102 | $input = ' A '; |
|---|
| 103 | $this->assertFalse(SC_Utils::isBlank($input, false), $input); |
|---|
| 104 | } |
|---|
| 105 | |
|---|
| 106 | public function testIsBlank_数値のゼロを入力した場合_falseが返る() { |
|---|
| 107 | $input = 0; |
|---|
| 108 | $this->assertFalse(SC_Utils::isBlank($input), $input); |
|---|
| 109 | } |
|---|
| 110 | |
|---|
| 111 | public function testIsBlank_値が空の配列を入力した場合_trueが返る() { |
|---|
| 112 | $input = array(""); |
|---|
| 113 | $this->assertTrue(SC_Utils::isBlank($input), $input); |
|---|
| 114 | } |
|---|
| 115 | |
|---|
| 116 | public function testIsBlank_すべてのホワイトスペースを並べた場合_trueが返る() { |
|---|
| 117 | $input = " \t \n\r\x0B\0"; |
|---|
| 118 | $this->assertTrue(SC_Utils::isBlank($input), $input); |
|---|
| 119 | } |
|---|
| 120 | |
|---|
| 121 | public function testIsBlank_通常の文字が含まれている場合_falseが返る() { |
|---|
| 122 | $input = " AB \n\t"; |
|---|
| 123 | $this->assertFalse(SC_Utils::isBlank($input), $input); |
|---|
| 124 | } |
|---|
| 125 | |
|---|
| 126 | ////////////////////////////////////////// |
|---|
| 127 | |
|---|
| 128 | } |
|---|
| 129 | |
|---|