source: branches/version-2_13-dev/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_TestBase.php @ 23356

Revision 23356, 14.8 KB checked in by kimoto, 10 years ago (diff)

#2485 テストデータが矛盾しているので修正

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