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 | |
---|
36 | private $helper; |
---|
37 | |
---|
38 | protected function setUp() |
---|
39 | { |
---|
40 | parent::setUp(); |
---|
41 | |
---|
42 | $this->helper = new SC_Helper_Purchase_rollbackOrderMock(); |
---|
43 | } |
---|
44 | |
---|
45 | protected function tearDown() |
---|
46 | { |
---|
47 | parent::tearDown(); |
---|
48 | } |
---|
49 | |
---|
50 | ///////////////////////////////////////// |
---|
51 | public function testRollbackOrder_デフォルトの引数で呼び出した場合_カートの状態をロールバックして元に戻る() |
---|
52 | { |
---|
53 | $this->objQuery->begin(); |
---|
54 | $order_id = '1001'; |
---|
55 | |
---|
56 | $uniqid = $this->helper->rollbackOrder($order_id); |
---|
57 | |
---|
58 | $this->actual['testResult'] = $this->helper->testResult; |
---|
59 | $this->actual['siteRegist'] = $_SESSION['site']['regist_success']; |
---|
60 | $this->expected = array( |
---|
61 | 'testResult' => array( |
---|
62 | 'cancelOrder' => array( |
---|
63 | 'order_id' => '1001', |
---|
64 | 'orderStatus' => ORDER_CANCEL, |
---|
65 | 'is_delete' => false |
---|
66 | ), |
---|
67 | 'getOrderTempByOrderId' => array( |
---|
68 | 'order_id' => '1001' |
---|
69 | ), |
---|
70 | 'saveOrderTemp' => array( |
---|
71 | 'uniqid' => $uniqid, |
---|
72 | 'arrOrderTemp' => array( |
---|
73 | 'customer_id' => '2001', |
---|
74 | 'del_flg' => '0' |
---|
75 | ) |
---|
76 | ), |
---|
77 | 'verifyChangeCart' => array( |
---|
78 | 'uniqid' => $uniqid |
---|
79 | ) |
---|
80 | ), |
---|
81 | 'siteRegist' => true |
---|
82 | ); |
---|
83 | $this->verify(); |
---|
84 | } |
---|
85 | |
---|
86 | /** |
---|
87 | * 実際にトランザクションを開始したかどうかはテストできないが、 |
---|
88 | * 問題なく処理が完了することのみ確認 |
---|
89 | */ |
---|
90 | public function testRollbackOrder_トランザクションが開始していない場合_内部で開始する() |
---|
91 | { |
---|
92 | $order_id = '1001'; |
---|
93 | |
---|
94 | $uniqid = $this->helper->rollbackOrder($order_id, ORDER_DELIV, true); |
---|
95 | |
---|
96 | $this->actual['testResult'] = $this->helper->testResult; |
---|
97 | $this->actual['siteRegist'] = $_SESSION['site']['regist_success']; |
---|
98 | $this->expected = array( |
---|
99 | 'testResult' => array( |
---|
100 | 'cancelOrder' => array( |
---|
101 | 'order_id' => '1001', |
---|
102 | 'orderStatus' => ORDER_DELIV, |
---|
103 | 'is_delete' => true |
---|
104 | ), |
---|
105 | 'getOrderTempByOrderId' => array( |
---|
106 | 'order_id' => '1001' |
---|
107 | ), |
---|
108 | 'saveOrderTemp' => array( |
---|
109 | 'uniqid' => $uniqid, |
---|
110 | 'arrOrderTemp' => array( |
---|
111 | 'customer_id' => '2001', |
---|
112 | 'del_flg' => '0' |
---|
113 | ) |
---|
114 | ), |
---|
115 | 'verifyChangeCart' => array( |
---|
116 | 'uniqid' => $uniqid |
---|
117 | ) |
---|
118 | ), |
---|
119 | 'siteRegist' => true |
---|
120 | ); |
---|
121 | $this->verify(); |
---|
122 | } |
---|
123 | ////////////////////////////////////////// |
---|
124 | } |
---|
125 | |
---|
126 | class SC_Helper_Purchase_rollbackOrderMock extends SC_Helper_Purchase |
---|
127 | { |
---|
128 | public $testResult = array(); |
---|
129 | |
---|
130 | function cancelOrder($order_id, $orderStatus, $is_delete) |
---|
131 | { |
---|
132 | $this->testResult['cancelOrder'] = array( |
---|
133 | 'order_id' => $order_id, |
---|
134 | 'orderStatus' => $orderStatus, |
---|
135 | 'is_delete' => $is_delete |
---|
136 | ); |
---|
137 | } |
---|
138 | |
---|
139 | function getOrderTempByOrderId($order_id) |
---|
140 | { |
---|
141 | $this->testResult['getOrderTempByOrderId'] = array( |
---|
142 | 'order_id' => $order_id |
---|
143 | ); |
---|
144 | return array( |
---|
145 | 'customer_id' => '2001' |
---|
146 | ); |
---|
147 | } |
---|
148 | |
---|
149 | function saveOrderTemp($uniqid, $arrOrderTemp, $objCustomer) |
---|
150 | { |
---|
151 | $this->testResult['saveOrderTemp'] = array( |
---|
152 | 'uniqid' => $uniqid, |
---|
153 | 'arrOrderTemp' => $arrOrderTemp |
---|
154 | ); |
---|
155 | } |
---|
156 | |
---|
157 | function verifyChangeCart($uniqid, $objCartSession) |
---|
158 | { |
---|
159 | $this->testResult['verifyChangeCart'] = array( |
---|
160 | 'uniqid' => $uniqid |
---|
161 | ); |
---|
162 | } |
---|
163 | } |
---|
164 | |
---|