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

Revision 22796, 14.7 KB checked in by h_yoshimoto, 11 years ago (diff)

#2236 2.12.3リリース以降の2.12-devへのコミット差し戻し

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