source: branches/version-2_12-dev/test/class/page/LC_Page_Test.php @ 21481

Revision 21481, 4.8 KB checked in by Seasoft, 12 years ago (diff)

#1613 (ソース整形・ソースコメントの改善)

  • Zend Framework PHP 標準コーディング規約への準拠を高めた
  • Property svn:eol-style set to LF
  • Property svn:keywords set to Id
  • Property svn:mime-type set to text/x-httpd-php; charset=UTF-8
Line 
1<?php
2/*
3 * This file is part of EC-CUBE
4 *
5 * Copyright(c) 2000-2011 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// {{{ requires
25require_once(realpath(dirname(__FILE__)) . '/../../require.php');
26require_once(realpath(dirname(__FILE__)) . '/../../../data/class/pages/LC_Page.php');
27
28/**
29 * LC_Page のテストケース.
30 *
31 * @package Page
32 * @author LOCKON CO.,LTD.
33 * @version $Id:LC_Page_Test.php 15116 2007-07-23 11:32:53Z nanasess $
34 */
35class LC_Page_Test extends PHPUnit_Framework_TestCase {
36
37    // }}}
38    // {{{ functions
39
40    /*
41     * FIXME LC_Page::sendRedirect() は, リダイレクトしてしまうため,
42     *       PHPUnit3 ではテストできない...
43     */
44
45    /**
46     * LC_Page::sendRedirect() のテストケース(エラー).
47     */
48    /*
49    function testSendRedirect() {
50        $objPage = new LC_Page();
51        $result = $objPage->sendRedirect(HTTP_URL);
52
53        $this->assertEquals(true, empty($result));
54    }
55    */
56    /**
57     * LC_Page::sendRedirect() のテストケース(エラー).
58     */
59    /*
60    function testSendRedirectIsFailed() {
61        $objPage = new LC_Page();
62        $result = $objPage->sendRedirect("http://www.example.org");
63
64        $this->assertEquals(false, $result);
65    }
66    */
67
68    /**
69     * LC_Page::getToken() のテストケース.
70     */
71    function testGetToken() {
72        $objPage = new LC_Page();
73
74        $objPage->setTokenTo();
75        $token = $objPage->transactionid;
76
77        // 40文字の16進数
78        $this->assertEquals(1, preg_match("/[a-f0-9]{40,}/", $token));
79
80        // セッションに文字列が格納されているか
81        $this->assertEquals($token, $_SESSION[TRANSACTION_ID_NAME]);
82    }
83
84    /**
85     * LC_Page::getLocation() のテストケース.
86     */
87    function testGetLocation() {
88        $objPage = new LC_Page();
89        $_SERVER['DOCUMENT_ROOT'] = realpath(dirname(__FILE__) . "/../../../html");
90        $url = $objPage->getLocation("/abouts/index.php");
91
92        $this->assertEquals(HTTP_URL . "abouts/index.php", $url);
93        unset($_SERVER['DOCUMENT_ROOT']);
94    }
95
96    /**
97     * LC_Page::getLocation() のテストケース.
98     *
99     * 絶対パス
100     */
101    function testGetLocationWithFullPath() {
102        $objPage = new LC_Page();
103        $_SERVER['DOCUMENT_ROOT'] = realpath(dirname(__FILE__) . "/../../../html");
104        $url = $objPage->getLocation(ROOT_URLPATH . 'abouts/index.php');
105
106        $this->assertEquals(HTTP_URL . "abouts/index.php", $url);
107        unset($_SERVER['DOCUMENT_ROOT']);
108    }
109
110    /**
111     * LC_Page::getLocation() のテストケース.
112     *
113     * QueryString 付与
114     */
115    function testGetLocationWithQueryString() {
116        $objPage = new LC_Page();
117        $_SERVER['DOCUMENT_ROOT'] = realpath(dirname(__FILE__) . "/../../../html");
118
119        $queryString = array('mode' => 'update', 'type' => 'text');
120        $url = $objPage->getLocation("/abouts/index.php", $queryString);
121
122        $this->assertEquals(HTTP_URL . "abouts/index.php?mode=update&type=text", $url);
123        unset($_SERVER['DOCUMENT_ROOT']);
124    }
125
126    /**
127     * LC_Page::getLocation() のテストケース.
128     *
129     * HTTPS_URL 使用
130     */
131    function testGetLocationUseSSL() {
132        $objPage = new LC_Page();
133        $_SERVER['DOCUMENT_ROOT'] = realpath(dirname(__FILE__) . "/../../../html");
134
135        $queryString = array('mode' => 'update', 'type' => 'text');
136        $url = $objPage->getLocation("/abouts/index.php", $queryString, true);
137
138        $this->assertEquals(HTTPS_URL . "abouts/index.php?mode=update&type=text", $url);
139        unset($_SERVER['DOCUMENT_ROOT']);
140    }
141
142    /**
143     * LC_Page::getLocation() のテストケース.
144     *
145     * DocumentRoot 指定
146     */
147    function testGetLocationWithDocumentRoot() {
148        $objPage = new LC_Page();
149        $documentRoot = realpath(dirname(__FILE__) . "/../../../html");
150
151        $queryString = array('mode' => 'update', 'type' => 'text');
152        $url = $objPage->getLocation("/abouts/index.php", array(),
153                                     false, $documentRoot);
154
155        $this->assertEquals(HTTP_URL . "abouts/index.php", $url);
156    }
157}
158?>
Note: See TracBrowser for help on using the repository browser.