source: branches/version-2_13-dev/tests/class/SC_CheckError/SC_CheckError_createParamTest.php @ 22919

Revision 22919, 3.3 KB checked in by nanasess, 11 years ago (diff)

#150 ユニットテスト環境の整備

  • SC_CheckError::createParam() のテストを追加
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_createParamTest extends Common_TestCase
28{
29    protected $old_reporting_level;
30    protected $arrForm;
31    protected $objErr;
32
33    protected function setUp()
34    {
35        parent::setUp();
36        $this->old_reporting_level = error_reporting();
37        error_reporting($this->old_reporting_level ^ (E_USER_ERROR | E_USER_WARNING | E_USER_NOTICE));
38        $this->arrForm = array('form' => array(0=> 'A', 1 => "B", 2 => 'C'));
39        $this->objErr = new SC_CheckError_Ex($this->arrForm);
40
41    }
42
43    protected function tearDown()
44    {
45        parent::tearDown();
46        error_reporting($this->old_reporting_level);
47    }
48
49    /////////////////////////////////////////
50
51    public function testArrParamIsCaracter()
52    {
53        $this->objErr->doFunc(array('EXIST_CHECK', "aabbcc_1234") ,array('EXIST_CHECK'));
54
55        $this->expected = array('form' => array (0 => 'A',1 => 'B', 2 => 'C'),
56                                'aabbcc_1234' => '');
57        $this->actual = $this->objErr->arrParam;
58        $this->verify('arrParam is normal character');
59    }
60
61    public function testArrParamIsIllegalCaracter()
62    {
63        $this->objErr->doFunc(array('EXIST_CHECK', "aabbcc_1234-") ,array('EXIST_CHECK'));
64
65        $this->expected = array('form' => array (0 => 'A',1 => 'B', 2 => 'C'));
66        $this->actual = $this->objErr->arrParam;
67        $this->verify('arrParam is Illegal character');
68    }
69
70
71    public function testArrParamIsIllegalValue()
72    {
73
74        $this->arrForm = array('form' => '/../\\\.');
75        $this->objErr = new SC_CheckError_Ex($this->arrForm);
76
77        $this->objErr->doFunc(array('EXIST_CHECK', "form") ,array('EXIST_CHECK'));
78
79        $this->expected = "※ EXIST_CHECKに禁止された記号の並びまたは制御文字が入っています。<br />";
80        $this->actual = $this->objErr->arrErr['form'];
81        $this->verify('arrParam is Illegal value');
82    }
83
84    public function testArrParamIsIllegalValue2()
85    {
86        $this->arrForm = array('form' => "\x00");
87        $this->objErr = new SC_CheckError_Ex($this->arrForm);
88
89        $this->objErr->doFunc(array('EXIST_CHECK', "form") ,array('EXIST_CHECK'));
90
91        $this->expected = "※ EXIST_CHECKに禁止された記号の並びまたは制御文字が入っています。<br />";
92        $this->actual = $this->objErr->arrErr['form'];
93        $this->verify('arrParam is Illegal value2');
94    }
95}
Note: See TracBrowser for help on using the repository browser.