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

Revision 22165, 10.6 KB checked in by shift_hiroko.tamagawa, 11 years ago (diff)

単体テスト用のデータ作成を修正

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