1 | <?php |
---|
2 | |
---|
3 | $HOME = realpath(dirname(__FILE__)) . "/../../../.."; |
---|
4 | require_once($HOME . "/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_TestBase.php"); |
---|
5 | /* |
---|
6 | * This file is part of EC-CUBE |
---|
7 | * |
---|
8 | * Copyright(c) 2000-2013 LOCKON CO.,LTD. All Rights Reserved. |
---|
9 | * |
---|
10 | * http://www.lockon.co.jp/ |
---|
11 | * |
---|
12 | * This program is free software; you can redistribute it and/or |
---|
13 | * modify it under the terms of the GNU General Public License |
---|
14 | * as published by the Free Software Foundation; either version 2 |
---|
15 | * of the License, or (at your option) any later version. |
---|
16 | * |
---|
17 | * This program is distributed in the hope that it will be useful, |
---|
18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
20 | * GNU General Public License for more details. |
---|
21 | * |
---|
22 | * You should have received a copy of the GNU General Public License |
---|
23 | * along with this program; if not, write to the Free Software |
---|
24 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
---|
25 | */ |
---|
26 | |
---|
27 | /** |
---|
28 | * SC_Helper_Purchase::rollbackOrder()のテストクラス. |
---|
29 | * |
---|
30 | * @author Hiroko Tamagawa |
---|
31 | * @version $Id$ |
---|
32 | */ |
---|
33 | class SC_Helper_Purchase_rollbackOrderTest extends SC_Helper_Purchase_TestBase { |
---|
34 | |
---|
35 | private $helper; |
---|
36 | |
---|
37 | protected function setUp() { |
---|
38 | parent::setUp(); |
---|
39 | |
---|
40 | $this->helper = new SC_Helper_Purchase_rollbackOrderMock(); |
---|
41 | } |
---|
42 | |
---|
43 | protected function tearDown() { |
---|
44 | parent::tearDown(); |
---|
45 | } |
---|
46 | |
---|
47 | ///////////////////////////////////////// |
---|
48 | public function testRollbackOrder_デフォルトの引数で呼び出した場合_カートの状態をロールバックして元に戻る(){ |
---|
49 | $this->objQuery->begin(); |
---|
50 | $order_id = '1001'; |
---|
51 | |
---|
52 | $uniqid = $this->helper->rollbackOrder($order_id); |
---|
53 | |
---|
54 | $this->actual['testResult'] = $this->helper->testResult; |
---|
55 | $this->actual['siteRegist'] = $_SESSION['site']['regist_success']; |
---|
56 | $this->expected = array( |
---|
57 | 'testResult' => array( |
---|
58 | 'cancelOrder' => array( |
---|
59 | 'order_id' => '1001', |
---|
60 | 'orderStatus' => ORDER_CANCEL, |
---|
61 | 'is_delete' => false |
---|
62 | ), |
---|
63 | 'getOrderTempByOrderId' => array( |
---|
64 | 'order_id' => '1001' |
---|
65 | ), |
---|
66 | 'saveOrderTemp' => array( |
---|
67 | 'uniqid' => $uniqid, |
---|
68 | 'arrOrderTemp' => array( |
---|
69 | 'customer_id' => '2001', |
---|
70 | 'del_flg' => '0' |
---|
71 | ) |
---|
72 | ), |
---|
73 | 'verifyChangeCart' => array( |
---|
74 | 'uniqid' => $uniqid |
---|
75 | ) |
---|
76 | ), |
---|
77 | 'siteRegist' => true |
---|
78 | ); |
---|
79 | $this->verify(); |
---|
80 | } |
---|
81 | |
---|
82 | /** |
---|
83 | * 実際にトランザクションを開始したかどうかはテストできないが、 |
---|
84 | * 問題なく処理が完了することのみ確認 |
---|
85 | */ |
---|
86 | public function testRollbackOrder_トランザクションが開始していない場合_内部で開始する() { |
---|
87 | $order_id = '1001'; |
---|
88 | |
---|
89 | $uniqid = $this->helper->rollbackOrder($order_id, ORDER_DELIV, true); |
---|
90 | |
---|
91 | $this->actual['testResult'] = $this->helper->testResult; |
---|
92 | $this->actual['siteRegist'] = $_SESSION['site']['regist_success']; |
---|
93 | $this->expected = array( |
---|
94 | 'testResult' => array( |
---|
95 | 'cancelOrder' => array( |
---|
96 | 'order_id' => '1001', |
---|
97 | 'orderStatus' => ORDER_DELIV, |
---|
98 | 'is_delete' => true |
---|
99 | ), |
---|
100 | 'getOrderTempByOrderId' => array( |
---|
101 | 'order_id' => '1001' |
---|
102 | ), |
---|
103 | 'saveOrderTemp' => array( |
---|
104 | 'uniqid' => $uniqid, |
---|
105 | 'arrOrderTemp' => array( |
---|
106 | 'customer_id' => '2001', |
---|
107 | 'del_flg' => '0' |
---|
108 | ) |
---|
109 | ), |
---|
110 | 'verifyChangeCart' => array( |
---|
111 | 'uniqid' => $uniqid |
---|
112 | ) |
---|
113 | ), |
---|
114 | 'siteRegist' => true |
---|
115 | ); |
---|
116 | $this->verify(); |
---|
117 | } |
---|
118 | ////////////////////////////////////////// |
---|
119 | |
---|
120 | } |
---|
121 | |
---|
122 | class SC_Helper_Purchase_rollbackOrderMock extends SC_Helper_Purchase { |
---|
123 | public $testResult = array(); |
---|
124 | |
---|
125 | function cancelOrder($order_id, $orderStatus, $is_delete) { |
---|
126 | $this->testResult['cancelOrder'] = array( |
---|
127 | 'order_id' => $order_id, |
---|
128 | 'orderStatus' => $orderStatus, |
---|
129 | 'is_delete' => $is_delete |
---|
130 | ); |
---|
131 | } |
---|
132 | |
---|
133 | function getOrderTempByOrderId($order_id) { |
---|
134 | $this->testResult['getOrderTempByOrderId'] = array( |
---|
135 | 'order_id' => $order_id |
---|
136 | ); |
---|
137 | return array( |
---|
138 | 'customer_id' => '2001' |
---|
139 | ); |
---|
140 | } |
---|
141 | |
---|
142 | function saveOrderTemp($uniqid, $arrOrderTemp, $objCustomer) { |
---|
143 | $this->testResult['saveOrderTemp'] = array( |
---|
144 | 'uniqid' => $uniqid, |
---|
145 | 'arrOrderTemp' => $arrOrderTemp |
---|
146 | ); |
---|
147 | } |
---|
148 | |
---|
149 | function verifyChangeCart($uniqid, $objCartSession) { |
---|
150 | $this->testResult['verifyChangeCart'] = array( |
---|
151 | 'uniqid' => $uniqid |
---|
152 | ); |
---|
153 | } |
---|
154 | } |
---|
155 | |
---|