source: branches/version-2_13-dev/tests/class/SC_CheckError/SC_CheckError_SPTAB_CHECKTest.php @ 22853

Revision 22853, 4.9 KB checked in by kimoto, 8 years ago (diff)

#150 ユニットテスト環境の整備
SC_CheckError SPTAB_CHECKの追加

Line 
1<?php
2/*
3 * This file is part of EC-CUBE
4 *
5 * Copyright(c) 2000-2013 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$HOME = realpath(dirname(__FILE__)) . "/../../..";
25require_once($HOME . "/tests/class/Common_TestCase.php");
26
27class SC_CheckError_SPTAB_CHECKTest extends Common_TestCase
28{
29
30    protected function setUp()
31    {
32        parent::setUp();
33    }
34
35    protected function tearDown()
36    {
37        parent::tearDown();
38    }
39
40    /////////////////////////////////////////
41
42    public function testSPTAB_CHECK_タブのみの入力()
43    {
44        $arrForm = array('form' => "\t");
45        $objErr = new SC_CheckError_Ex($arrForm);
46        $objErr->doFunc(array('SPTAB_CHECK', 'form') ,array('SPTAB_CHECK'));
47
48        $this->expected = '※ SPTAB_CHECKにスペース、タブ、改行のみの入力はできません。<br />';
49        $this->actual = $objErr->arrErr['form'];
50        $this->verify('');
51    }
52
53    public function testSPTAB_CHECK_半角スペースのみの入力()
54    {
55        $arrForm = array('form' => " ");
56        $objErr = new SC_CheckError_Ex($arrForm);
57        $objErr->doFunc(array('SPTAB_CHECK', 'form') ,array('SPTAB_CHECK'));
58
59        $this->expected = '※ SPTAB_CHECKにスペース、タブ、改行のみの入力はできません。<br />';
60        $this->actual = $objErr->arrErr['form'];
61        $this->verify('');
62    }
63
64    public function testSPTAB_CHECK_全角スペースのみの入力()
65    {
66        $arrForm = array('form' => " ");
67        $objErr = new SC_CheckError_Ex($arrForm);
68        $objErr->doFunc(array('SPTAB_CHECK', 'form') ,array('SPTAB_CHECK'));
69
70        $this->expected = '※ SPTAB_CHECKにスペース、タブ、改行のみの入力はできません。<br />';
71        $this->actual = $objErr->arrErr['form'];
72        $this->verify('');
73    }
74
75    public function testSPTAB_CHECK_改行のみの入力()
76    {
77        $arrForm = array('form' => "\n");
78        $objErr = new SC_CheckError_Ex($arrForm);
79        $objErr->doFunc(array('SPTAB_CHECK', 'form') ,array('SPTAB_CHECK'));
80
81        $this->expected = '※ SPTAB_CHECKにスペース、タブ、改行のみの入力はできません。<br />';
82        $this->actual = $objErr->arrErr['form'];
83        $this->verify('');
84    }
85
86    public function testSPTAB_CHECK_改行のみの入力2()
87    {
88        $arrForm = array('form' => "\r");
89        $objErr = new SC_CheckError_Ex($arrForm);
90        $objErr->doFunc(array('SPTAB_CHECK', 'form') ,array('SPTAB_CHECK'));
91
92        $this->expected = '※ SPTAB_CHECKにスペース、タブ、改行のみの入力はできません。<br />';
93        $this->actual = $objErr->arrErr['form'];
94        $this->verify('');
95    }
96
97    public function testSPTAB_CHECK_スペース改行タブの混在()
98    {
99        $arrForm = array('form' => "  \t\n\r");
100        $objErr = new SC_CheckError_Ex($arrForm);
101        $objErr->doFunc(array('SPTAB_CHECK', 'form') ,array('SPTAB_CHECK'));
102
103        $this->expected = '※ SPTAB_CHECKにスペース、タブ、改行のみの入力はできません。<br />';
104        $this->actual = $objErr->arrErr['form'];
105        $this->verify('');
106    }
107
108    public function testSPTAB_CHECK_文字の先頭にスペース()
109    {
110        $arrForm = array('form' => " test");
111        $objErr = new SC_CheckError_Ex($arrForm);
112        $objErr->doFunc(array('SPTAB_CHECK', 'form') ,array('SPTAB_CHECK'));
113
114        $this->expected = '';
115        $this->actual = $objErr->arrErr['form'];
116        $this->verify('');
117    }
118
119    public function testSPTAB_CHECK_文字の間にスペース()
120    {
121        $arrForm = array('form' => "te st");
122        $objErr = new SC_CheckError_Ex($arrForm);
123        $objErr->doFunc(array('SPTAB_CHECK', 'form') ,array('SPTAB_CHECK'));
124
125        $this->expected = '';
126        $this->actual = $objErr->arrErr['form'];
127        $this->verify('');
128    }
129
130    public function testSPTAB_CHECK_文字の最後にスペース()
131    {
132        $arrForm = array('form' => "test ");
133        $objErr = new SC_CheckError_Ex($arrForm);
134        $objErr->doFunc(array('SPTAB_CHECK', 'form') ,array('SPTAB_CHECK'));
135
136        $this->expected = '';
137        $this->actual = $objErr->arrErr['form'];
138        $this->verify('');
139    }
140
141}
Note: See TracBrowser for help on using the repository browser.