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

Revision 23546, 14.9 KB checked in by shutta, 10 years ago (diff)

#2580 Copyrightを更新
Copyrightを2014に更新

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-2014 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    // classcategory_id=0のものは削除しない
215    $this->objQuery->delete('dtb_classcategory', 'classcategory_id <> 0');
216    foreach ($class_category as $key => $item) {
217      $this->objQuery->insert('dtb_classcategory', $item);
218    }
219  }
220
221  /**
222   * DBに製品情報を登録します.
223   */
224 protected function setUpProducts()
225 {
226   $products = array(
227     array(
228       'update_date' => '2000-01-01 00:00:00',
229       'product_id' => '1001',
230       'name' => '製品名1001',
231       'del_flg' => '0',
232       'creator_id' => '1',
233       'status' => '1'
234     ),
235     array(
236       'update_date' => '2000-01-01 00:00:00',
237       'product_id' => '1002',
238       'name' => '製品名1002',
239       'del_flg' => '0',
240       'creator_id' => '1',
241       'status' => '2'
242     )
243   );
244
245   $this->objQuery->delete('dtb_products');
246   foreach ($products as $key => $item) {
247     $this->objQuery->insert('dtb_products', $item);
248   }
249 }
250
251 /**
252  * DBに支払方法の情報を登録します.
253  */
254 protected function setUpPaymentOptions()
255 {
256   $payment_options = array(
257     array(
258       'deliv_id' => '2001',
259       'payment_id' => '2001',
260       'rank' => '1'
261     ),
262     array(
263       'deliv_id' => '1001',
264       'payment_id' => '1001',
265       'rank' => '2'
266     ),
267     array(
268       'deliv_id' => '1001',
269       'payment_id' => '1002',
270       'rank' => '1'
271     ),
272     array(
273       'deliv_id' => '1003',
274       'payment_id' => '3001',
275       'rank' => '1'
276     ),
277     array(
278       'deliv_id' => '1003',
279       'payment_id' => '3002',
280       'rank' => '2'
281     ),
282     array(
283       'deliv_id' => '1003',
284       'payment_id' => '3003',
285       'rank' => '3'
286     ),
287     array(
288       'deliv_id' => '1003',
289       'payment_id' => '3004',
290       'rank' => '4'
291     ),
292     array(
293       'deliv_id' => '1003',
294       'payment_id' => '3005',
295       'rank' => '5'
296     )
297   );
298
299   $this->objQuery->delete('dtb_payment_options');
300   foreach ($payment_options as $key => $item) {
301     $this->objQuery->insert('dtb_payment_options', $item);
302   }
303 }
304
305 /**
306  * DBに配送業者の情報を登録します.
307  */
308 protected function setUpDeliv()
309 {
310   $deliv = array(
311     array(  // 削除フラグON
312       'deliv_id' => '2001',
313       'product_type_id' => '1001',
314       'name' => '配送業者del',
315       'rank' => '1',
316       'creator_id' => '1',
317       'del_flg' => '1',
318       'update_date' => '2000-01-01 00:00:00'
319     ),
320     array(
321       'deliv_id' => '1001',
322       'product_type_id' => '1001',
323       'name' => '配送業者01',
324       'creator_id' => '1',
325       'rank' => '2',
326       'update_date' => '2000-01-01 00:00:00'
327     ),
328     array(
329       'deliv_id' => '1002',
330       'product_type_id' => '1001',
331       'name' => '配送業者02',
332       'creator_id' => '1',
333       'rank' => '3',
334       'update_date' => '2000-01-01 00:00:00'
335     ),
336     array( // 商品種別違い
337       'deliv_id' => '1004',
338       'product_type_id' => '2001',
339       'name' => '配送業者21',
340       'creator_id' => '1',
341       'rank' => '4',
342       'update_date' => '2000-01-01 00:00:00'
343     ),
344   );
345
346   $this->objQuery->delete('dtb_deliv');
347   foreach ($deliv as $key => $item) {
348     $this->objQuery->insert('dtb_deliv', $item);
349   }
350 }
351
352 /**
353  * DBにお届け時間の情報を登録します.
354  */
355 protected function setUpDelivTime()
356 {
357   $deliv_time = array(
358     array(
359       'deliv_id' => '1002',
360       'time_id' => '1',
361       'deliv_time' => '午前'
362     ),
363     array(
364       'deliv_id' => '1001',
365       'time_id' => '2',
366       'deliv_time' => '午後'
367     ),
368     array(
369       'deliv_id' => '1001',
370       'time_id' => '1',
371       'deliv_time' => '午前'
372     ),
373   );
374
375   $this->objQuery->delete('dtb_delivtime');
376   foreach ($deliv_time as $key => $item) {
377     $this->objQuery->insert('dtb_delivtime', $item);
378   }
379 }
380
381 /**
382  * DBに支払方法の情報を登録します.
383  */
384 protected function setUpPayment()
385 {
386   $payment = array(
387     array(
388       'update_date' => '2000-01-01 00:00:00',
389       'payment_id' => '1001',
390       'creator_id' => '1',
391       'payment_method' => '支払方法1001'
392     ),
393     array(
394       'update_date' => '2000-01-01 00:00:00',
395       'payment_id' => '1002',
396       'creator_id' => '1',
397       'payment_method' => '支払方法1002',
398       'del_flg' => '1'
399     ),
400     array(
401       'update_date' => '2000-01-01 00:00:00',
402       'payment_id' => '1003',
403       'creator_id' => '1',
404       'payment_method' => '支払方法1003'
405     ),
406     array(
407       'update_date' => '2000-01-01 00:00:00',
408       'payment_id' => '3001',
409       'creator_id' => '1',
410       'payment_method' => '支払方法3001',
411       'del_flg' => '1'
412     ),
413     array(
414       'update_date' => '2000-01-01 00:00:00',
415       'payment_id' => '3002',
416       'creator_id' => '1',
417       'payment_method' => '支払方法3002'
418     ),
419     array(
420       'update_date' => '2000-01-01 00:00:00',
421       'payment_id' => '3003',
422       'creator_id' => '1',
423       'payment_method' => '支払方法3003',
424       'rule_max' => 10000
425     ),
426     array(
427       'update_date' => '2000-01-01 00:00:00',
428       'payment_id' => '3004',
429       'creator_id' => '1',
430       'payment_method' => '支払方法3004',
431       'upper_rule' => 20000
432     ),
433     array(
434       'update_date' => '2000-01-01 00:00:00',
435       'payment_id' => '3005',
436       'creator_id' => '1',
437       'payment_method' => '支払方法3005',
438       'rule_max' => 12000,
439       'upper_rule' => 21000
440     )
441   );
442
443   $this->objQuery->delete('dtb_payment');
444   foreach ($payment as $key => $item) {
445     $this->objQuery->insert('dtb_payment', $item);
446   }
447 }
448
449 /**
450  * DBに受注情報を設定します.
451  */
452  protected function setUpOrder()
453  {
454    $order = array(
455      array(
456        'update_date' => '2000-01-01 00:00:00',
457        'order_id' => '1001',
458        'customer_id' => '1001',
459        'order_name01' => '受注情報01',
460        'status' => '3',
461        'payment_date' => '2032-12-31 01:20:30', // 日付が変わっても良いように、遠い未来に設定
462        'use_point' => '10',
463        'add_point' => '20'
464      ),
465      array(
466        'update_date' => '2000-01-01 00:00:00',
467        'order_id' => '1002',
468        'customer_id' => '1002',
469        'order_name01' => '受注情報02',
470        'status' => '5',
471        'payment_id' => '1002',
472        'payment_method' => '支払方法1001',
473        'deliv_id' => '1002',
474        'use_point' => '10',
475        'add_point' => '20'
476      )
477    );
478
479    $this->objQuery->delete('dtb_order');
480    foreach ($order as $item) {
481      $this->objQuery->insert('dtb_order', $item);
482    }
483  }
484
485 /**
486  * DBに受注一時情報を設定します.
487  */
488  protected function setUpOrderTemp()
489  {
490    $order = array(
491      array(
492        'update_date' => '2000-01-01 00:00:00',
493        'order_temp_id' => '1001',
494        'customer_id' => '1001',
495        'order_name01' => '受注情報01',
496        'order_id' => '1001'
497      ),
498      array(
499        'update_date' => '2000-01-01 00:00:00',
500        'order_temp_id' => '1002',
501        'customer_id' => '1002',
502        'order_name01' => '受注情報02',
503        'payment_id' => '1002',
504        'payment_method' => '支払方法1001'
505      )
506    );
507
508    $this->objQuery->delete('dtb_order_temp');
509    foreach ($order as $item) {
510      $this->objQuery->insert('dtb_order_temp', $item);
511    }
512  }
513
514 /**
515  * DBに受注詳細を設定します.
516  */
517 protected function setUpOrderDetail()
518 {
519   $order_detail = array(
520     array(
521       'order_detail_id' => '1001',
522       'order_id' => '1001',
523       'product_id' => '1002',
524       'product_class_id' => '1002',
525       'product_code' => 'pc1002',
526       'product_name' => '製品名1002',
527       'classcategory_name1' => 'cat10021',
528       'classcategory_name2' => 'cat10022',
529       'price' => 3000,
530       'quantity' => 10,
531       'point_rate' => 5,
532       'tax_rate' => 5,
533       'tax_rule' => 0
534     ),
535     array(
536       'order_detail_id' => '1002',
537       'order_id' => '1001',
538       'product_id' => '1001',
539       'product_class_id' => '1001',
540       'product_code' => 'pc1001',
541       'product_name' => '製品名1001',
542       'classcategory_name1' => 'cat10011',
543       'classcategory_name2' => 'cat10012',
544       'price' => 4000,
545       'quantity' => 15,
546       'point_rate' => 6,
547       'tax_rate' => 3,
548       'tax_rule' => 1
549     ),
550     array(
551       'order_detail_id' => '1003',
552       'order_id' => '1002',
553       'product_id' => '1001',
554       'product_class_id' => '1001',
555       'product_name' => '製品名1003'
556     )
557   );
558
559   $this->objQuery->delete('dtb_order_detail');
560   foreach ($order_detail as $item) {
561     $this->objQuery->insert('dtb_order_detail', $item);
562   }
563 }
564
565 /**
566  * DBに顧客情報を設定します。
567  */
568 protected function setUpCustomer()
569 {
570   $customer = array(
571     array(
572       'customer_id' => '1001',
573       'name01' => '苗字',
574       'name02' => '名前',
575       'kana01' => 'みょうじ',
576       'kana02' => 'なまえ',
577       'email' => 'test@example.com',
578       'secret_key' => 'hoge',
579       'point' => '100',
580       'update_date' => '2000-01-01 00:00:00'
581     ),
582     array(
583       'customer_id' => '1002',
584       'name01' => '苗字2',
585       'name02' => '名前2',
586       'kana01' => 'みょうじ2',
587       'kana02' => 'なまえ2',
588       'email' => 'test2@example.com',
589       'secret_key' => 'hoge2',
590       'point' => '200',
591       'update_date' => '2000-01-01 00:00:00'
592     )
593   );
594
595   $this->objQuery->delete('dtb_customer');
596   foreach ($customer as $item) {
597     $this->objQuery->insert('dtb_customer', $item);
598   }
599 }
600}
601
Note: See TracBrowser for help on using the repository browser.