source: branches/feature-module-update/test/class/page/LC_Page_Test.php @ 15116

Revision 15116, 2.7 KB checked in by nanasess, 17 years ago (diff)

svn properties 修正

  • Property svn:keywords set to Id Revision Date
  • Property svn:mime-type set to application/x-httpd-php; charset=UTF-8
Line 
1<?php
2/*
3 * Copyright(c) 2000-2007 LOCKON CO.,LTD. All Rights Reserved.
4 *
5 * http://www.lockon.co.jp/
6 */
7
8// {{{ requires
9require_once(CLASS_PATH . "pages/LC_Page.php");
10require_once("PHPUnit/TestCase.php");
11
12/**
13 * LC_Page のテストケース.
14 *
15 * @package Page
16 * @author LOCKON CO.,LTD.
17 * @version $Id$
18 */
19class LC_Page_Test extends PHPUnit_TestCase {
20
21    // }}}
22    // {{{ functions
23
24    /**
25     * LC_Page::sendRedirect() のテストケース(エラー).
26     */
27    function testSendRedirect() {
28        $objPage = new LC_Page();
29        $result = $objPage->sendRedirect(SITE_URL);
30
31        $this->assertEquals(true, empty($result));
32    }
33
34    /**
35     * LC_Page::sendRedirect() のテストケース(エラー).
36     */
37    function testSendRedirectIsFailed() {
38        $objPage = new LC_Page();
39        $result = $objPage->sendRedirect("http://www.example.org");
40
41        $this->assertEquals(false, $result);
42    }
43
44    /**
45     * LC_Page::getToken() のテストケース.
46     */
47    function testGetToken() {
48        $objPage = new LC_Page();
49
50        $token = $objPage->getToken();
51
52        // 40文字の16進数
53        $this->assertEquals(1, preg_match("/[a-f0-9]{40,}/", $token));
54
55        // セッションに文字列が格納されているか
56        $this->assertEquals($token, $_SESSION[TRANSACTION_ID_NAME]);
57    }
58
59    /**
60     * LC_Page::isValidToken() のテストケース(POST).
61     */
62    function testIsValidToken() {
63        $objPage = new LC_Page();
64
65        $token = $objPage->getToken();
66
67        // POST でトークンを渡す.
68        $_POST[TRANSACTION_ID_NAME] = $token;
69
70        $this->assertEquals(true, $objPage->isValidToken());
71        unset($_POST[TRANSACTION_ID_NAME]);
72    }
73
74    /**
75     * LC_Page::isValidToken() のテストケース(GET).
76     */
77    function testIsValidTokenWithGET() {
78        $objPage = new LC_Page();
79
80        $token = $objPage->getToken();
81
82        // GET でトークンを渡す.
83        $_GET[TRANSACTION_ID_NAME] = $token;
84
85        $this->assertEquals(true, $objPage->isValidToken());
86        unset($_GET[TRANSACTION_ID_NAME]);
87    }
88
89
90    /**
91     * LC_Page::isValidToken() のテストケース(エラー).
92     *
93     * 値が渡されてない場合
94     */
95    function testIsValidTokenNotParam() {
96
97        $objPage = new LC_Page();
98
99        $token = $objPage->getToken();
100
101        // 値を渡さなければ falsel
102        $this->assertEquals(false, $objPage->isValidToken());
103    }
104
105    /**
106     * LC_Page::createToken() のテストケース.
107     */
108    function testCreateToken() {
109        // 40文字の16進数
110        $this->assertEquals(1, preg_match("/[a-f0-9]{40,}/", LC_Page::createToken()));
111    }
112}
113?>
Note: See TracBrowser for help on using the repository browser.