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

Revision 21866, 3.9 KB checked in by h_yoshimoto, 12 years ago (diff)

#1831 Copyrightを更新を誤っているので戻します

  • 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/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 testGetOrderIdBySession() {
49        $_SESSION['order_id'] = 1;
50        $_GET['order_id'] = 2;
51        $_POST['order_id'] = 3;
52
53        $this->expected = $_SESSION['order_id'];
54        $this->actual = $this->objPage->getOrderId();
55
56        $this->verify();
57    }
58
59    function testGetOrderIdByPOST() {
60        $_GET['order_id'] = 1;
61        $_POST['order_id'] = 1;
62
63        $this->expected = $_POST['order_id'];
64        $this->actual = $this->objPage->getOrderId();
65
66        $this->verify();
67    }
68
69    function testGetOrderIdByGET() {
70        $_GET['order_id'] = 2;
71
72        $this->expected = $_GET['order_id'];
73        $this->actual = $this->objPage->getOrderId();
74
75        $this->verify();
76    }
77
78    function testGetOrderIdIsNull() {
79        $this->assertFalse($this->objPage->getOrderId());
80    }
81
82    function testGetModulePath() {
83        $order_id = 10000;
84        $payment_id = 10000;
85        $module_path = __FILE__;
86        $this->setPayment($order_id, $payment_id, $module_path);
87
88        $this->expected = __FILE__;
89        $this->actual = $this->objPage->getModulePath($order_id);
90
91        $this->verify();
92    }
93
94    function testGetModulePathIsFailure() {
95        $order_id = 10000;
96        $payment_id = 10000;
97        $module_path = 'aaa';
98        $this->setPayment($order_id, $payment_id, $module_path);
99
100        $this->actual = $this->objPage->getModulePath($order_id);
101
102        $this->assertFalse($this->actual);
103
104    }
105
106    function verify() {
107        $this->assertEquals($this->expected, $this->actual);
108    }
109
110    function setPayment($order_id, $payment_id, $module_path) {
111        $this->objQuery->insert('dtb_order', array('order_id' => $order_id,
112                                                   'customer_id' => (int) 0,
113                                                   'payment_id' => $payment_id,
114                                                   'create_date' => 'CURRENT_TIMESTAMP',
115                                                   'update_date' => 'CURRENT_TIMESTAMP'));
116
117        $this->objQuery->insert('dtb_payment', array('payment_id' => $order_id,
118                                                     'module_path' => $module_path,
119                                                     'creator_id' => 1,
120                                                     'create_date' => 'CURRENT_TIMESTAMP',
121                                                     'update_date' => 'CURRENT_TIMESTAMP'));
122    }
123}
Note: See TracBrowser for help on using the repository browser.