source: branches/version-2_5-dev/test/class/page/shopping/LC_Page_Shopping_LoadPaymentModule_Test.php @ 20116

Revision 20116, 3.3 KB checked in by nanasess, 11 years ago (diff)
  • svn properties を再設定
  • 再設定用のスクリプト追加
  • 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-2010 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/shopping/LC_Page_Shopping_LoadPaymentModule.php');
27
28/**
29 * LC_Page_Admin_Products_ProductClass のテストケース.
30 *
31 * @package Page
32 * @author Kentaro Ohkouchi
33 * @version $Id$
34 */
35class LC_Page_Shopping_LoadPaymentModule_Test extends PHPUnit_Framework_TestCase {
36
37    function setUp() {
38        $this->objQuery =& SC_Query::getSingletonInstance();
39        $this->objQuery->begin();
40        $this->objPage = new LC_Page_Shopping_LoadPaymentModule();
41    }
42
43    function tearDown() {
44        $this->objQuery->rollback();
45        $this->objPage = null;
46    }
47
48    function testGetPaymentIdBySession() {
49        $_SESSION['payment_id'] = 1;
50        $_GET['payment_id'] = 2;
51        $_POST['payment_id'] = 3;
52
53        $this->expected = $_SESSION['payment_id'];
54        $this->actual = $this->objPage->getPaymentId();
55
56        $this->verify();
57    }
58
59    function testGetPaymentIdByPOST() {
60        $_GET['payment_id'] = 1;
61        $_POST['payment_id'] = 1;
62
63        $this->expected = $_POST['payment_id'];
64        $this->actual = $this->objPage->getPaymentId();
65
66        $this->verify();
67    }
68
69    function testGetPaymentIdByGET() {
70        $_GET['payment_id'] = 2;
71
72        $this->expected = $_GET['payment_id'];
73        $this->actual = $this->objPage->getPaymentId();
74
75        $this->verify();
76    }
77
78    function testGetPaymentIdIsNull() {
79        $this->assertFalse($this->objPage->getPaymentId());
80    }
81
82    function testGetModulePath() {
83        $payment_id = 10000;
84        $module_path = __FILE__;
85        $this->setPayment($payment_id, $module_path);
86
87        $this->expected = __FILE__;
88        $this->actual = $this->objPage->getModulePath($payment_id);
89
90        $this->verify();
91    }
92
93    function testGetModulePathIsFailure() {
94        $payment_id = 10000;
95        $module_path = "aaa";
96        $this->setPayment($payment_id, $module_path);
97
98        $this->actual = $this->objPage->getModulePath($payment_id);
99
100        $this->assertFalse($this->actual);
101
102    }
103
104    function verify() {
105        $this->assertEquals($this->expected, $this->actual);
106    }
107
108    function setPayment($payment_id, $module_path) {
109        $this->objQuery->insert("dtb_payment", array('payment_id' => $payment_id,
110                                                     'module_path' => $module_path,
111                                                     'creator_id' => 1));
112    }
113}
Note: See TracBrowser for help on using the repository browser.