source: branches/version-2_13-dev/tests/class/SC_CheckError/SC_CheckError_HTML_TAG_CHECKTest.php @ 22850

Revision 22850, 2.7 KB checked in by kimoto, 8 years ago (diff)

#150 ユニットテスト環境の整備
SC_CheckError HTML_TAG_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_HTML_TAG_CHECKTest extends Common_TestCase
28{
29
30    protected function setUp()
31    {
32        parent::setUp();
33        $masterData = new SC_DB_MasterData_Ex();
34        $this->arrAllowedTag = $masterData->getMasterData('mtb_allowed_tag');
35    }
36
37    protected function tearDown()
38    {
39        parent::tearDown();
40    }
41
42    /////////////////////////////////////////
43
44    public function testHTML_TAG_CHECK_scriptタグが含まれる()
45    {
46        $arrForm = array('form' => '<script></script>');
47        $objErr = new SC_CheckError_Ex($arrForm);
48        $objErr->doFunc(array('HTML_TAG_CHECK', 'form', $this->arrAllowedTag) ,array('HTML_TAG_CHECK'));
49
50        $this->expected = '※ HTML_TAG_CHECKに許可されていないタグ [script], [script] が含まれています。<br />';
51        $this->actual = $objErr->arrErr['form'];
52        $this->verify('');
53    }
54
55    public function testHTML_TAG_CHECK_pタグが含まれる()
56    {
57        $arrForm = array('form' => '<p><p><p>');
58        $objErr = new SC_CheckError_Ex($arrForm);
59        $objErr->doFunc(array('HTML_TAG_CHECK', 'form', $this->arrAllowedTag) ,array('HTML_TAG_CHECK'));
60
61        $this->expected = '';
62        $this->actual = $objErr->arrErr['form'];
63        $this->verify('');
64    }
65
66    public function testHTML_TAG_CHECK_htmlタグが含まれない()
67    {
68        $arrForm = array('form' => '
69            htmlを含まないテスト文章。
70            htmlを含まないテスト文章。
71            htmlを含まないテスト文章。
72            ');
73        $objErr = new SC_CheckError_Ex($arrForm);
74        $objErr->doFunc(array('HTML_TAG_CHECK', 'form', $this->arrAllowedTag) ,array('HTML_TAG_CHECK'));
75
76        $this->expected = '';
77        $this->actual = $objErr->arrErr['form'];
78        $this->verify('');
79    }
80
81}
Note: See TracBrowser for help on using the repository browser.