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::cancelOrder()のテストクラス. |
---|
29 | * |
---|
30 | * @author Hiroko Tamagawa |
---|
31 | * @version $Id$ |
---|
32 | */ |
---|
33 | class SC_Helper_Purchase_cancelOrderTest extends SC_Helper_Purchase_TestBase { |
---|
34 | |
---|
35 | private $helper; |
---|
36 | |
---|
37 | protected function setUp() { |
---|
38 | parent::setUp(); |
---|
39 | $this->setUpProductClass(); |
---|
40 | $this->helper = new SC_Helper_Purchase_cancelOrderMock(); |
---|
41 | } |
---|
42 | |
---|
43 | protected function tearDown() { |
---|
44 | parent::tearDown(); |
---|
45 | } |
---|
46 | |
---|
47 | ///////////////////////////////////////// |
---|
48 | public function testCancelOrder_デフォルトの引数で呼び出した場合_製品クラスのデータが更新される(){ |
---|
49 | $order_id = '1001'; |
---|
50 | $this->objQuery->begin(); |
---|
51 | |
---|
52 | $this->helper->cancelOrder($order_id); |
---|
53 | |
---|
54 | $this->actual['testResult'] = $_SESSION['testResult']; |
---|
55 | $this->actual['productClass'] = $this->objQuery->select( |
---|
56 | 'stock', 'dtb_products_class', |
---|
57 | 'product_class_id in (?, ?)', array('1001', '1002') |
---|
58 | ); |
---|
59 | $this->expected = array( |
---|
60 | 'testResult' => array( |
---|
61 | 'registerOrder' => array( |
---|
62 | 'order_id' => '1001', |
---|
63 | 'params' => array( |
---|
64 | 'status' => ORDER_CANCEL |
---|
65 | ) |
---|
66 | ), |
---|
67 | 'getOrderDetail' => array( |
---|
68 | 'order_id' => '1001' |
---|
69 | ) |
---|
70 | ), |
---|
71 | 'productClass' => array( |
---|
72 | array('stock' => '105'), |
---|
73 | array('stock' => '51') |
---|
74 | ) |
---|
75 | ); |
---|
76 | $this->verify(); |
---|
77 | } |
---|
78 | |
---|
79 | // 実際にトランザクションを開始したかどうかはテストできないが、 |
---|
80 | // 問題なく処理が完了することのみ確認 |
---|
81 | public function testCancelOrder_トランザクションが開始していない場合_内部で開始する(){ |
---|
82 | $order_id = '1001'; |
---|
83 | |
---|
84 | $this->helper->cancelOrder($order_id, ORDER_NEW); |
---|
85 | |
---|
86 | $this->actual['testResult'] = $_SESSION['testResult']; |
---|
87 | $this->actual['productClass'] = $this->objQuery->select( |
---|
88 | 'stock', 'dtb_products_class', |
---|
89 | 'product_class_id in (?, ?)', array('1001', '1002') |
---|
90 | ); |
---|
91 | $this->expected = array( |
---|
92 | 'testResult' => array( |
---|
93 | 'registerOrder' => array( |
---|
94 | 'order_id' => '1001', |
---|
95 | 'params' => array( |
---|
96 | 'status' => ORDER_NEW |
---|
97 | ) |
---|
98 | ), |
---|
99 | 'getOrderDetail' => array( |
---|
100 | 'order_id' => '1001' |
---|
101 | ) |
---|
102 | ), |
---|
103 | 'productClass' => array( |
---|
104 | array('stock' => '105'), |
---|
105 | array('stock' => '51') |
---|
106 | ) |
---|
107 | ); |
---|
108 | |
---|
109 | $this->verify(); |
---|
110 | } |
---|
111 | |
---|
112 | public function testCancelOrder_削除フラグが立っている場合_DB更新時に削除フラグが立てられる(){ |
---|
113 | $order_id = '1001'; |
---|
114 | $this->objQuery->begin(); |
---|
115 | |
---|
116 | $this->helper->cancelOrder($order_id, ORDER_DELIV, true); |
---|
117 | |
---|
118 | $this->actual['testResult'] = $_SESSION['testResult']; |
---|
119 | $this->actual['productClass'] = $this->objQuery->select( |
---|
120 | 'stock', 'dtb_products_class', |
---|
121 | 'product_class_id in (?, ?)', array('1001', '1002') |
---|
122 | ); |
---|
123 | $this->expected = array( |
---|
124 | 'testResult' => array( |
---|
125 | 'registerOrder' => array( |
---|
126 | 'order_id' => '1001', |
---|
127 | 'params' => array( |
---|
128 | 'status' => ORDER_DELIV, |
---|
129 | 'del_flg' => '1' |
---|
130 | ) |
---|
131 | ), |
---|
132 | 'getOrderDetail' => array( |
---|
133 | 'order_id' => '1001' |
---|
134 | ) |
---|
135 | ), |
---|
136 | 'productClass' => array( |
---|
137 | array('stock' => '105'), |
---|
138 | array('stock' => '51') |
---|
139 | ) |
---|
140 | ); |
---|
141 | |
---|
142 | $this->verify(); |
---|
143 | } |
---|
144 | |
---|
145 | ////////////////////////////////////////// |
---|
146 | |
---|
147 | } |
---|
148 | |
---|
149 | class SC_Helper_Purchase_cancelOrderMock extends SC_Helper_Purchase { |
---|
150 | |
---|
151 | function registerOrder($order_id, $params) { |
---|
152 | $_SESSION['testResult']['registerOrder'] = array( |
---|
153 | 'order_id' => $order_id, |
---|
154 | 'params' => $params |
---|
155 | ); |
---|
156 | } |
---|
157 | |
---|
158 | function getOrderDetail($order_id) { |
---|
159 | $_SESSION['testResult']['getOrderDetail'] = array( |
---|
160 | 'order_id' => $order_id |
---|
161 | ); |
---|
162 | |
---|
163 | return array( |
---|
164 | array( |
---|
165 | 'product_class_id' => '1001', |
---|
166 | 'quantity' => '5' |
---|
167 | ), |
---|
168 | array( |
---|
169 | 'product_class_id' => '1002', |
---|
170 | 'quantity' => '1' |
---|
171 | ) |
---|
172 | ); |
---|
173 | } |
---|
174 | } |
---|
175 | |
---|
176 | |
---|