1 | <?php |
---|
2 | |
---|
3 | $HOME = realpath(dirname(__FILE__)) . "/../../../.."; |
---|
4 | require_once($HOME . "/tests/class/Common_TestCase.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 | * SC_Helper_Purchaseのテストの基底クラス. |
---|
28 | * |
---|
29 | * |
---|
30 | * @author Hiroko Tamagawa |
---|
31 | * @version $Id$ |
---|
32 | */ |
---|
33 | class SC_Helper_Purchase_TestBase extends Common_TestCase { |
---|
34 | |
---|
35 | protected function setUp() { |
---|
36 | parent::setUp(); |
---|
37 | } |
---|
38 | |
---|
39 | protected function tearDown() { |
---|
40 | parent::tearDown(); |
---|
41 | } |
---|
42 | |
---|
43 | ///////////////////////////////////////// |
---|
44 | /** |
---|
45 | * セッションに配送情報を設定します。 |
---|
46 | */ |
---|
47 | protected function setUpShipping($shipping) { |
---|
48 | if (!$shipping) { |
---|
49 | $shipping = $this->getSingleShipping(); |
---|
50 | } |
---|
51 | |
---|
52 | $_SESSION['shipping'] = $shipping; |
---|
53 | } |
---|
54 | |
---|
55 | protected function getSingleShipping() { |
---|
56 | return array( |
---|
57 | '00001' => array( |
---|
58 | 'shipment_id' => '00001', |
---|
59 | 'shipment_item' => '商品1', |
---|
60 | 'shipping_pref' => '東京都') |
---|
61 | ); |
---|
62 | } |
---|
63 | |
---|
64 | protected function getMultipleShipping() { |
---|
65 | return array( |
---|
66 | '00001' => array( |
---|
67 | 'shipment_id' => '00001', |
---|
68 | 'shipment_item' => array('商品1'), |
---|
69 | 'shipping_pref' => '東京都'), |
---|
70 | '00002' => array( |
---|
71 | 'shipment_id' => '00002', |
---|
72 | 'shipment_item' => array('商品2'), |
---|
73 | 'shipping_pref' => '沖縄県'), |
---|
74 | '00003' => array( |
---|
75 | 'shipment_id' => '00003', |
---|
76 | 'shipment_item' => array(), |
---|
77 | 'shipping_pref' => '埼玉県') |
---|
78 | ); |
---|
79 | } |
---|
80 | |
---|
81 | /** |
---|
82 | * DBに配送情報を設定します。 |
---|
83 | */ |
---|
84 | protected function setUpShippingOnDb() { |
---|
85 | $shippings = array( |
---|
86 | array( |
---|
87 | 'update_date' => '2000-01-01 00:00:00', |
---|
88 | 'shipping_id' => '1', |
---|
89 | 'order_id' => '1', |
---|
90 | 'shipping_name01' => '配送情報01', |
---|
91 | 'shipping_date' => '2012-01-12' |
---|
92 | ), |
---|
93 | array( |
---|
94 | 'update_date' => '2000-01-01 00:00:00', |
---|
95 | 'shipping_id' => '2', |
---|
96 | 'order_id' => '2', |
---|
97 | 'shipping_name01' => '配送情報02', |
---|
98 | 'shipping_date' => '2011-10-01' |
---|
99 | ), |
---|
100 | array( |
---|
101 | 'update_date' => '2000-01-01 00:00:00', |
---|
102 | 'shipping_id' => '1002', |
---|
103 | 'order_id' => '1002', |
---|
104 | 'shipping_time' => '午後', |
---|
105 | 'time_id' => '1' |
---|
106 | ) |
---|
107 | ); |
---|
108 | |
---|
109 | $this->objQuery->delete('dtb_shipping'); |
---|
110 | foreach ($shippings as $key => $item) { |
---|
111 | $this->objQuery->insert('dtb_shipping', $item); |
---|
112 | } |
---|
113 | } |
---|
114 | |
---|
115 | /** |
---|
116 | * DBに配送商品情報を設定します。 |
---|
117 | */ |
---|
118 | protected function setUpShipmentItem() { |
---|
119 | $shipping_items = array( |
---|
120 | array( |
---|
121 | 'shipping_id' => '1', |
---|
122 | 'product_class_id' => '1001', |
---|
123 | 'order_id' => '1', |
---|
124 | 'product_name' => '商品名01', |
---|
125 | 'price' => '1500' |
---|
126 | ), |
---|
127 | array( |
---|
128 | 'shipping_id' => '1', |
---|
129 | 'product_class_id' => '1002', |
---|
130 | 'order_id' => '1', |
---|
131 | 'product_name' => '商品名02', |
---|
132 | 'price' => '2400' |
---|
133 | ) |
---|
134 | ); |
---|
135 | |
---|
136 | $this->objQuery->delete('dtb_shipment_item'); |
---|
137 | foreach ($shipping_items as $key => $item) { |
---|
138 | $this->objQuery->insert('dtb_shipment_item', $item); |
---|
139 | } |
---|
140 | $this->setUpProductClass(); |
---|
141 | } |
---|
142 | |
---|
143 | /** |
---|
144 | * DBに商品クラス情報を設定します. |
---|
145 | */ |
---|
146 | protected function setUpProductClass() { |
---|
147 | $product_class = array( |
---|
148 | array( |
---|
149 | 'update_date' => '2000-01-01 00:00:00', |
---|
150 | 'product_class_id' => '1001', |
---|
151 | 'product_id' => '1001', |
---|
152 | 'product_type_id' => '1', |
---|
153 | 'product_code' => 'code1001', |
---|
154 | 'classcategory_id1' => '1001', |
---|
155 | 'classcategory_id2' => '1002', |
---|
156 | 'price01' => '1500', |
---|
157 | 'price02' => '1500', |
---|
158 | 'creator_id' => '1', |
---|
159 | 'stock' => '100', |
---|
160 | 'del_flg' => '0' |
---|
161 | ), |
---|
162 | array( |
---|
163 | 'update_date' => '2000-01-01 00:00:00', |
---|
164 | 'product_class_id' => '1002', |
---|
165 | 'product_id' => '1002', |
---|
166 | 'product_type_id' => '2', |
---|
167 | 'price02' => '2500', |
---|
168 | 'creator_id' => '1', |
---|
169 | 'stock' => '50', |
---|
170 | 'del_flg' => '0' |
---|
171 | ) |
---|
172 | ); |
---|
173 | |
---|
174 | $this->objQuery->delete('dtb_products_class'); |
---|
175 | foreach ($product_class as $key => $item) { |
---|
176 | $this->objQuery->insert('dtb_products_class', $item); |
---|
177 | } |
---|
178 | $this->setUpClassCategory(); |
---|
179 | $this->setUpProducts(); |
---|
180 | } |
---|
181 | |
---|
182 | /** |
---|
183 | * DBに製品カテゴリ情報を登録します. |
---|
184 | */ |
---|
185 | protected function setUpClassCategory() { |
---|
186 | $class_category = array( |
---|
187 | array( |
---|
188 | 'update_date' => '2000-01-01 00:00:00', |
---|
189 | 'classcategory_id' => '1001', |
---|
190 | 'class_id' => '1', |
---|
191 | 'creator_id' => '1', |
---|
192 | 'name' => 'cat1001' |
---|
193 | ), |
---|
194 | array( |
---|
195 | 'update_date' => '2000-01-01 00:00:00', |
---|
196 | 'classcategory_id' => '1002', |
---|
197 | 'class_id' => '1', |
---|
198 | 'creator_id' => '1', |
---|
199 | 'name' => 'cat1002' |
---|
200 | ) |
---|
201 | ); |
---|
202 | |
---|
203 | $this->objQuery->delete('dtb_classcategory'); |
---|
204 | foreach ($class_category as $key => $item) { |
---|
205 | $this->objQuery->insert('dtb_classcategory', $item); |
---|
206 | } |
---|
207 | } |
---|
208 | |
---|
209 | /** |
---|
210 | * DBに製品情報を登録します. |
---|
211 | */ |
---|
212 | protected function setUpProducts() { |
---|
213 | $products = array( |
---|
214 | array( |
---|
215 | 'update_date' => '2000-01-01 00:00:00', |
---|
216 | 'product_id' => '1001', |
---|
217 | 'name' => '製品名1001', |
---|
218 | 'del_flg' => '0', |
---|
219 | 'creator_id' => '1', |
---|
220 | 'status' => '1' |
---|
221 | ), |
---|
222 | array( |
---|
223 | 'update_date' => '2000-01-01 00:00:00', |
---|
224 | 'product_id' => '1002', |
---|
225 | 'name' => '製品名1002', |
---|
226 | 'del_flg' => '0', |
---|
227 | 'creator_id' => '1', |
---|
228 | 'status' => '2' |
---|
229 | ) |
---|
230 | ); |
---|
231 | |
---|
232 | $this->objQuery->delete('dtb_products'); |
---|
233 | foreach ($products as $key => $item) { |
---|
234 | $this->objQuery->insert('dtb_products', $item); |
---|
235 | } |
---|
236 | } |
---|
237 | |
---|
238 | /** |
---|
239 | * DBに支払方法の情報を登録します. |
---|
240 | */ |
---|
241 | protected function setUpPaymentOptions() { |
---|
242 | $payment_options = array( |
---|
243 | array( |
---|
244 | 'deliv_id' => '2001', |
---|
245 | 'payment_id' => '2001', |
---|
246 | 'rank' => '1' |
---|
247 | ), |
---|
248 | array( |
---|
249 | 'deliv_id' => '1001', |
---|
250 | 'payment_id' => '1001', |
---|
251 | 'rank' => '2' |
---|
252 | ), |
---|
253 | array( |
---|
254 | 'deliv_id' => '1001', |
---|
255 | 'payment_id' => '1002', |
---|
256 | 'rank' => '1' |
---|
257 | ), |
---|
258 | array( |
---|
259 | 'deliv_id' => '1003', |
---|
260 | 'payment_id' => '3001', |
---|
261 | 'rank' => '1' |
---|
262 | ), |
---|
263 | array( |
---|
264 | 'deliv_id' => '1003', |
---|
265 | 'payment_id' => '3002', |
---|
266 | 'rank' => '2' |
---|
267 | ), |
---|
268 | array( |
---|
269 | 'deliv_id' => '1003', |
---|
270 | 'payment_id' => '3003', |
---|
271 | 'rank' => '3' |
---|
272 | ), |
---|
273 | array( |
---|
274 | 'deliv_id' => '1003', |
---|
275 | 'payment_id' => '3004', |
---|
276 | 'rank' => '4' |
---|
277 | ), |
---|
278 | array( |
---|
279 | 'deliv_id' => '1003', |
---|
280 | 'payment_id' => '3005', |
---|
281 | 'rank' => '5' |
---|
282 | ) |
---|
283 | ); |
---|
284 | |
---|
285 | $this->objQuery->delete('dtb_payment_options'); |
---|
286 | foreach ($payment_options as $key => $item) { |
---|
287 | $this->objQuery->insert('dtb_payment_options', $item); |
---|
288 | } |
---|
289 | } |
---|
290 | |
---|
291 | /** |
---|
292 | * DBに配送業者の情報を登録します. |
---|
293 | */ |
---|
294 | protected function setUpDeliv() { |
---|
295 | $deliv = array( |
---|
296 | array( // 削除フラグON |
---|
297 | 'deliv_id' => '2001', |
---|
298 | 'product_type_id' => '1001', |
---|
299 | 'name' => '配送業者del', |
---|
300 | 'rank' => '1', |
---|
301 | 'creator_id' => '1', |
---|
302 | 'del_flg' => '1', |
---|
303 | 'update_date' => '2000-01-01 00:00:00' |
---|
304 | ), |
---|
305 | array( |
---|
306 | 'deliv_id' => '1001', |
---|
307 | 'product_type_id' => '1001', |
---|
308 | 'name' => '配送業者01', |
---|
309 | 'creator_id' => '1', |
---|
310 | 'rank' => '2', |
---|
311 | 'update_date' => '2000-01-01 00:00:00' |
---|
312 | ), |
---|
313 | array( |
---|
314 | 'deliv_id' => '1002', |
---|
315 | 'product_type_id' => '1001', |
---|
316 | 'name' => '配送業者02', |
---|
317 | 'creator_id' => '1', |
---|
318 | 'rank' => '3', |
---|
319 | 'update_date' => '2000-01-01 00:00:00' |
---|
320 | ), |
---|
321 | array( // 商品種別違い |
---|
322 | 'deliv_id' => '1004', |
---|
323 | 'product_type_id' => '2001', |
---|
324 | 'name' => '配送業者21', |
---|
325 | 'creator_id' => '1', |
---|
326 | 'rank' => '4', |
---|
327 | 'update_date' => '2000-01-01 00:00:00' |
---|
328 | ), |
---|
329 | ); |
---|
330 | |
---|
331 | $this->objQuery->delete('dtb_deliv'); |
---|
332 | foreach ($deliv as $key => $item) { |
---|
333 | $this->objQuery->insert('dtb_deliv', $item); |
---|
334 | } |
---|
335 | } |
---|
336 | |
---|
337 | /** |
---|
338 | * DBにお届け時間の情報を登録します. |
---|
339 | */ |
---|
340 | protected function setUpDelivTime() { |
---|
341 | $deliv_time = array( |
---|
342 | array( |
---|
343 | 'deliv_id' => '1002', |
---|
344 | 'time_id' => '1', |
---|
345 | 'deliv_time' => '午前' |
---|
346 | ), |
---|
347 | array( |
---|
348 | 'deliv_id' => '1001', |
---|
349 | 'time_id' => '2', |
---|
350 | 'deliv_time' => '午後' |
---|
351 | ), |
---|
352 | array( |
---|
353 | 'deliv_id' => '1001', |
---|
354 | 'time_id' => '1', |
---|
355 | 'deliv_time' => '午前' |
---|
356 | ), |
---|
357 | ); |
---|
358 | |
---|
359 | $this->objQuery->delete('dtb_delivtime'); |
---|
360 | foreach ($deliv_time as $key => $item) { |
---|
361 | $this->objQuery->insert('dtb_delivtime', $item); |
---|
362 | } |
---|
363 | } |
---|
364 | |
---|
365 | /** |
---|
366 | * DBに支払方法の情報を登録します. |
---|
367 | */ |
---|
368 | protected function setUpPayment() { |
---|
369 | $payment = array( |
---|
370 | array( |
---|
371 | 'update_date' => '2000-01-01 00:00:00', |
---|
372 | 'payment_id' => '1001', |
---|
373 | 'creator_id' => '1', |
---|
374 | 'payment_method' => '支払方法1001' |
---|
375 | ), |
---|
376 | array( |
---|
377 | 'update_date' => '2000-01-01 00:00:00', |
---|
378 | 'payment_id' => '1002', |
---|
379 | 'creator_id' => '1', |
---|
380 | 'payment_method' => '支払方法1002', |
---|
381 | 'del_flg' => '1' |
---|
382 | ), |
---|
383 | array( |
---|
384 | 'update_date' => '2000-01-01 00:00:00', |
---|
385 | 'payment_id' => '1003', |
---|
386 | 'creator_id' => '1', |
---|
387 | 'payment_method' => '支払方法1003' |
---|
388 | ), |
---|
389 | array( |
---|
390 | 'update_date' => '2000-01-01 00:00:00', |
---|
391 | 'payment_id' => '3001', |
---|
392 | 'creator_id' => '1', |
---|
393 | 'payment_method' => '支払方法3001', |
---|
394 | 'del_flg' => '1' |
---|
395 | ), |
---|
396 | array( |
---|
397 | 'update_date' => '2000-01-01 00:00:00', |
---|
398 | 'payment_id' => '3002', |
---|
399 | 'creator_id' => '1', |
---|
400 | 'payment_method' => '支払方法3002' |
---|
401 | ), |
---|
402 | array( |
---|
403 | 'update_date' => '2000-01-01 00:00:00', |
---|
404 | 'payment_id' => '3003', |
---|
405 | 'creator_id' => '1', |
---|
406 | 'payment_method' => '支払方法3003', |
---|
407 | 'rule_max' => 10000 |
---|
408 | ), |
---|
409 | array( |
---|
410 | 'update_date' => '2000-01-01 00:00:00', |
---|
411 | 'payment_id' => '3004', |
---|
412 | 'creator_id' => '1', |
---|
413 | 'payment_method' => '支払方法3004', |
---|
414 | 'upper_rule' => 20000 |
---|
415 | ), |
---|
416 | array( |
---|
417 | 'update_date' => '2000-01-01 00:00:00', |
---|
418 | 'payment_id' => '3005', |
---|
419 | 'creator_id' => '1', |
---|
420 | 'payment_method' => '支払方法3005', |
---|
421 | 'rule_max' => 12000, |
---|
422 | 'upper_rule' => 21000 |
---|
423 | ) |
---|
424 | ); |
---|
425 | |
---|
426 | $this->objQuery->delete('dtb_payment'); |
---|
427 | foreach ($payment as $key => $item) { |
---|
428 | $this->objQuery->insert('dtb_payment', $item); |
---|
429 | } |
---|
430 | } |
---|
431 | |
---|
432 | /** |
---|
433 | * DBに受注情報を設定します. |
---|
434 | */ |
---|
435 | protected function setUpOrder() { |
---|
436 | $order = array( |
---|
437 | array( |
---|
438 | 'update_date' => '2000-01-01 00:00:00', |
---|
439 | 'order_id' => '1001', |
---|
440 | 'customer_id' => '1001', |
---|
441 | 'order_name01' => '受注情報01', |
---|
442 | 'status' => '3', |
---|
443 | 'payment_date' => '2032-12-31 01:20:30', // 日付が変わっても良いように、遠い未来に設定 |
---|
444 | 'use_point' => '10', |
---|
445 | 'add_point' => '20' |
---|
446 | ), |
---|
447 | array( |
---|
448 | 'update_date' => '2000-01-01 00:00:00', |
---|
449 | 'order_id' => '1002', |
---|
450 | 'customer_id' => '1002', |
---|
451 | 'order_name01' => '受注情報02', |
---|
452 | 'status' => '5', |
---|
453 | 'payment_id' => '1002', |
---|
454 | 'payment_method' => '支払方法1001', |
---|
455 | 'deliv_id' => '1002', |
---|
456 | 'use_point' => '10', |
---|
457 | 'add_point' => '20' |
---|
458 | ) |
---|
459 | ); |
---|
460 | |
---|
461 | $this->objQuery->delete('dtb_order'); |
---|
462 | foreach ($order as $item) { |
---|
463 | $this->objQuery->insert('dtb_order', $item); |
---|
464 | } |
---|
465 | } |
---|
466 | |
---|
467 | /** |
---|
468 | * DBに受注一時情報を設定します. |
---|
469 | */ |
---|
470 | protected function setUpOrderTemp() { |
---|
471 | $order = array( |
---|
472 | array( |
---|
473 | 'update_date' => '2000-01-01 00:00:00', |
---|
474 | 'order_temp_id' => '1001', |
---|
475 | 'customer_id' => '1001', |
---|
476 | 'order_name01' => '受注情報01', |
---|
477 | 'order_id' => '1001' |
---|
478 | ), |
---|
479 | array( |
---|
480 | 'update_date' => '2000-01-01 00:00:00', |
---|
481 | 'order_temp_id' => '1002', |
---|
482 | 'customer_id' => '1002', |
---|
483 | 'order_name01' => '受注情報02', |
---|
484 | 'payment_id' => '1002', |
---|
485 | 'payment_method' => '支払方法1001' |
---|
486 | ) |
---|
487 | ); |
---|
488 | |
---|
489 | $this->objQuery->delete('dtb_order_temp'); |
---|
490 | foreach ($order as $item) { |
---|
491 | $this->objQuery->insert('dtb_order_temp', $item); |
---|
492 | } |
---|
493 | } |
---|
494 | |
---|
495 | /** |
---|
496 | * DBに受注詳細を設定します. |
---|
497 | */ |
---|
498 | protected function setUpOrderDetail() { |
---|
499 | $order_detail = array( |
---|
500 | array( |
---|
501 | 'order_detail_id' => '1001', |
---|
502 | 'order_id' => '1001', |
---|
503 | 'product_id' => '1002', |
---|
504 | 'product_class_id' => '1002', |
---|
505 | 'product_code' => 'pc1002', |
---|
506 | 'product_name' => '製品名1002', |
---|
507 | 'classcategory_name1' => 'cat10021', |
---|
508 | 'classcategory_name2' => 'cat10022', |
---|
509 | 'price' => 3000, |
---|
510 | 'quantity' => 10, |
---|
511 | 'point_rate' => 5, |
---|
512 | 'tax_rate' => 5, |
---|
513 | 'tax_rule' => 0 |
---|
514 | ), |
---|
515 | array( |
---|
516 | 'order_detail_id' => '1002', |
---|
517 | 'order_id' => '1001', |
---|
518 | 'product_id' => '1001', |
---|
519 | 'product_class_id' => '1001', |
---|
520 | 'product_code' => 'pc1001', |
---|
521 | 'product_name' => '製品名1001', |
---|
522 | 'classcategory_name1' => 'cat10011', |
---|
523 | 'classcategory_name2' => 'cat10012', |
---|
524 | 'price' => 4000, |
---|
525 | 'quantity' => 15, |
---|
526 | 'point_rate' => 6, |
---|
527 | 'tax_rate' => 3, |
---|
528 | 'tax_rule' => 1 |
---|
529 | ), |
---|
530 | array( |
---|
531 | 'order_detail_id' => '1003', |
---|
532 | 'order_id' => '1002', |
---|
533 | 'product_id' => '1001', |
---|
534 | 'product_class_id' => '1001', |
---|
535 | 'product_name' => '製品名1003' |
---|
536 | ) |
---|
537 | ); |
---|
538 | |
---|
539 | $this->objQuery->delete('dtb_order_detail'); |
---|
540 | foreach ($order_detail as $item) { |
---|
541 | $this->objQuery->insert('dtb_order_detail', $item); |
---|
542 | } |
---|
543 | } |
---|
544 | |
---|
545 | /** |
---|
546 | * DBに顧客情報を設定します。 |
---|
547 | */ |
---|
548 | protected function setUpCustomer() { |
---|
549 | $customer = array( |
---|
550 | array( |
---|
551 | 'customer_id' => '1001', |
---|
552 | 'name01' => '苗字', |
---|
553 | 'name02' => '名前', |
---|
554 | 'kana01' => 'みょうじ', |
---|
555 | 'kana02' => 'なまえ', |
---|
556 | 'email' => 'test@example.com', |
---|
557 | 'secret_key' => 'hoge', |
---|
558 | 'point' => '100', |
---|
559 | 'update_date' => '2000-01-01 00:00:00' |
---|
560 | ), |
---|
561 | array( |
---|
562 | 'customer_id' => '1002', |
---|
563 | 'name01' => '苗字2', |
---|
564 | 'name02' => '名前2', |
---|
565 | 'kana01' => 'みょうじ2', |
---|
566 | 'kana02' => 'なまえ2', |
---|
567 | 'email' => 'test2@example.com', |
---|
568 | 'secret_key' => 'hoge2', |
---|
569 | 'point' => '200', |
---|
570 | 'update_date' => '2000-01-01 00:00:00' |
---|
571 | ) |
---|
572 | ); |
---|
573 | |
---|
574 | $this->objQuery->delete('dtb_customer'); |
---|
575 | foreach ($customer as $item) { |
---|
576 | $this->objQuery->insert('dtb_customer', $item); |
---|
577 | } |
---|
578 | } |
---|
579 | |
---|
580 | } |
---|
581 | |
---|