source: branches/version-2_13-dev/test/class/page/LC_Page_Test.php @ 23256

Revision 23256, 4.8 KB checked in by Seasoft, 10 years ago (diff)

#2427 (SC_SessionFactory_UseRequest#initSession URLパスでリダイレクトしている)
#2445 (TOPページのURLに揺らぎがある)
#2446 (HTTP へ復帰すべき画面遷移でも HTTPS が維持される)

  • 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-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// {{{ 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    // }}}
39    // {{{ functions
40
41    /*
42     * FIXME LC_Page::sendRedirect() は, リダイレクトしてしまうため,
43     *       PHPUnit3 ではテストできない...
44     */
45
46    /**
47     * LC_Page::sendRedirect() のテストケース(エラー).
48     */
49    /*
50    function testSendRedirect()
51    {
52        $objPage = new LC_Page();
53        $result = $objPage->sendRedirect(TOP_URL);
54
55        $this->assertEquals(true, empty($result));
56    }
57    */
58    /**
59     * LC_Page::sendRedirect() のテストケース(エラー).
60     */
61    /*
62    function testSendRedirectIsFailed()
63    {
64        $objPage = new LC_Page();
65        $result = $objPage->sendRedirect("http://www.example.org");
66
67        $this->assertEquals(false, $result);
68    }
69    */
70
71    /**
72     * LC_Page::getToken() のテストケース.
73     */
74    function testGetToken()
75    {
76        $objPage = new LC_Page();
77
78        $objPage->setTokenTo();
79        $token = $objPage->transactionid;
80
81        // 40文字の16進数
82        $this->assertEquals(1, preg_match("/[a-f0-9]{40,}/", $token));
83
84        // セッションに文字列が格納されているか
85        $this->assertEquals($token, $_SESSION[TRANSACTION_ID_NAME]);
86    }
87
88    /**
89     * LC_Page::getLocation() のテストケース.
90     */
91    function testGetLocation()
92    {
93        $objPage = new LC_Page();
94        $_SERVER['DOCUMENT_ROOT'] = realpath(dirname(__FILE__) . "/../../../html");
95        $url = $objPage->getLocation("/abouts/index.php");
96
97        $this->assertEquals(HTTP_URL . "abouts/index.php", $url);
98        unset($_SERVER['DOCUMENT_ROOT']);
99    }
100
101    /**
102     * LC_Page::getLocation() のテストケース.
103     *
104     * 絶対パス
105     */
106    function testGetLocationWithFullPath()
107    {
108        $objPage = new LC_Page();
109        $_SERVER['DOCUMENT_ROOT'] = realpath(dirname(__FILE__) . "/../../../html");
110        $url = $objPage->getLocation(ROOT_URLPATH . 'abouts/index.php');
111
112        $this->assertEquals(HTTP_URL . "abouts/index.php", $url);
113        unset($_SERVER['DOCUMENT_ROOT']);
114    }
115
116    /**
117     * LC_Page::getLocation() のテストケース.
118     *
119     * QueryString 付与
120     */
121    function testGetLocationWithQueryString()
122    {
123        $objPage = new LC_Page();
124        $_SERVER['DOCUMENT_ROOT'] = realpath(dirname(__FILE__) . "/../../../html");
125
126        $queryString = array('mode' => 'update', 'type' => 'text');
127        $url = $objPage->getLocation("/abouts/index.php", $queryString);
128
129        $this->assertEquals(HTTP_URL . "abouts/index.php?mode=update&type=text", $url);
130        unset($_SERVER['DOCUMENT_ROOT']);
131    }
132
133    /**
134     * LC_Page::getLocation() のテストケース.
135     *
136     * HTTPS_URL 使用
137     */
138    function testGetLocationUseSSL()
139    {
140        $objPage = new LC_Page();
141        $_SERVER['DOCUMENT_ROOT'] = realpath(dirname(__FILE__) . "/../../../html");
142
143        $queryString = array('mode' => 'update', 'type' => 'text');
144        $url = $objPage->getLocation("/abouts/index.php", $queryString, true);
145
146        $this->assertEquals(HTTPS_URL . "abouts/index.php?mode=update&type=text", $url);
147        unset($_SERVER['DOCUMENT_ROOT']);
148    }
149
150    /**
151     * LC_Page::getLocation() のテストケース.
152     *
153     * DocumentRoot 指定
154     */
155    function testGetLocationWithDocumentRoot()
156    {
157        $objPage = new LC_Page();
158        $documentRoot = realpath(dirname(__FILE__) . "/../../../html");
159
160        $queryString = array('mode' => 'update', 'type' => 'text');
161        $url = $objPage->getLocation("/abouts/index.php", array(),
162                                     false, $documentRoot);
163
164        $this->assertEquals(HTTP_URL . "abouts/index.php", $url);
165    }
166}
167?>
Note: See TracBrowser for help on using the repository browser.