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