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

Revision 23651, 14.9 KB checked in by Seasoft, 9 years ago (diff)

#2631 (「商品登録」「商品登録CSV」での入力必須不整合)

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