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

Revision 22567, 4.0 KB checked in by shutta, 11 years ago (diff)

#2043 (typo修正・ソース整形・ソースコメントの改善 for 2.12.4)
Zend Framework PHP 標準コーディング規約のコーディングスタイルへ準拠。
classおよびfunctionの開始波括弧「{」のスタイルを修正。

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