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

Revision 22141, 6.6 KB checked in by shift_hiroko.tamagawa, 11 years ago (diff)

#1978 SC_Helper_Purchaseの単体テスト一部を追加

  • Property svn:keywords set to Id Rev Date
Line 
1<?php
2
3$HOME = realpath(dirname(__FILE__)) . "/../../../..";
4require_once($HOME . "/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_TestBase.php");
5/*
6 * This file is part of EC-CUBE
7 *
8 * Copyright(c) 2000-2012 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/**
28 * SC_Helper_Purchase::registerShipmentItem()のテストクラス.
29 *
30 *
31 * @author Hiroko Tamagawa
32 * @version $Id$
33 */
34class SC_Helper_Purchase_registerShipmentItemTest extends SC_Helper_Purchase_TestBase {
35
36  protected function setUp() {
37    parent::setUp();
38    $this->setUpShipmentItem();
39  }
40
41  protected function tearDown() {
42    parent::tearDown();
43  }
44
45  /////////////////////////////////////////
46  public function testRegisterShipmentItem_製品クラスIDが入っていない場合_登録を行わない() {
47    // 引数の設定
48    $order_id = '1';
49    $shipping_id = '1';
50    $arrParams = array(
51      array(
52        // 'product_class_id' => '1',
53        'product_name' => '追加製品名01',
54        'product_code' => 'newcode01',
55        'classcategory_name1' => 'newcat01',
56        'classcategory_name2' => 'newcat02',
57        'price' => '2500'
58      )
59    );
60
61    // 期待値の設定
62    $this->expected['count'] = 0;
63
64    // 対象functionの呼び出し
65    SC_Helper_Purchase::registerShipmentItem($order_id, $shipping_id, $arrParams);
66    $result = $this->objQuery->select(
67      'product_class_id,product_name,product_code,classcategory_name1,classcategory_name2,price',
68      'dtb_shipment_item',
69      'order_id = ? and shipping_id = ?',
70      array($order_id, $shipping_id)
71    );
72    $this->actual['count'] = count($result);
73
74    $this->verify('登録された配送商品情報');
75  }
76
77  public function testRegisterShipmentItem_製品名等が指定されている場合_指定された値で登録を行う() {
78    // 引数の設定
79    $order_id = '1';
80    $shipping_id = '1';
81    $arrParams = array(
82      array(
83        'product_class_id' => '1',
84        'product_name' => '追加製品名01',
85        'product_code' => 'newcode01',
86        'classcategory_name1' => 'newcat01',
87        'classcategory_name2' => 'newcat02',
88        'price' => '2500'
89      )
90    );
91
92    // 期待値の設定
93    $this->expected['count'] = 1;
94    $this->expected['first'] = array(
95      'product_class_id' => '1',
96      'product_name' => '追加製品名01',
97      'product_code' => 'newcode01',
98      'classcategory_name1' => 'newcat01',
99      'classcategory_name2' => 'newcat02',
100      'price' => '2500'
101    );
102
103    // 対象functionの呼び出し
104    SC_Helper_Purchase::registerShipmentItem($order_id, $shipping_id, $arrParams);
105    $result = $this->objQuery->select(
106      'product_class_id,product_name,product_code,classcategory_name1,classcategory_name2,price',
107      'dtb_shipment_item',
108      'order_id = ? and shipping_id = ?',
109      array($order_id, $shipping_id)
110    );
111    $this->actual['count'] = count($result);
112    $this->actual['first'] = $result[0];
113
114    $this->verify('登録された配送商品情報');
115  }
116
117  public function testRegisterShipmentItem_製品名等が指定されていない場合_DBからマスタ情報を取得して登録を行う() {
118    // 引数の設定
119    $order_id = '1';
120    $shipping_id = '1';
121    $arrParams = array(
122      array(
123        'product_class_id' => '1001'
124        // 'product_name' => '追加製品名01',
125        // 'product_code' => 'newcode01',
126        // 'classcategory_name1' => 'newcat01',
127        // 'classcategory_name2' => 'newcat02',
128        // 'price' => '2500'
129      )
130    );
131
132    // 期待値の設定
133    $this->expected['count'] = 1;
134    $this->expected['first'] = array(
135      'product_class_id' => '1001',
136      'product_name' => '製品名1001',
137      'product_code' => 'code1001',
138      'classcategory_name1' => 'cat1001',
139      'classcategory_name2' => 'cat1002',
140  // TODO 要確認price01, price02を設定しても価格が取れない。実際にはDBから取るケースが無い?
141      //'price' => '1500'
142      'price' => null
143    );
144
145    // 対象functionの呼び出し
146    SC_Helper_Purchase::registerShipmentItem($order_id, $shipping_id, $arrParams);
147    $result = $this->objQuery->select(
148      'product_class_id,product_name,product_code,classcategory_name1,classcategory_name2,price',
149      'dtb_shipment_item',
150      'order_id = ? and shipping_id = ?',
151      array($order_id, $shipping_id)
152    );
153    $this->actual['count'] = count($result);
154    $this->actual['first'] = $result[0];
155
156    $this->verify('登録された配送商品情報');
157
158  }
159
160  public function testRegisterShipmentItem_DBに存在しないカラムを指定した場合_エラーなく登録できる() {
161    // 引数の設定
162    $order_id = '1';
163    $shipping_id = '1';
164    $arrParams = array(
165      array(
166        'product_class_id' => '1',
167        'product_name' => '追加製品名01',
168        'product_code' => 'newcode01',
169        'classcategory_name1' => 'newcat01',
170        'classcategory_name2' => 'newcat02',
171        'price' => '2500',
172        'xxxx' => 'yyyyyy' // 存在しないカラム
173      )
174    );
175
176    // 期待値の設定
177    $this->expected['count'] = 1;
178    $this->expected['first'] = array(
179      'product_class_id' => '1',
180      'product_name' => '追加製品名01',
181      'product_code' => 'newcode01',
182      'classcategory_name1' => 'newcat01',
183      'classcategory_name2' => 'newcat02',
184      'price' => '2500'
185    );
186
187    // 対象functionの呼び出し
188    SC_Helper_Purchase::registerShipmentItem($order_id, $shipping_id, $arrParams);
189    $result = $this->objQuery->select(
190      'product_class_id,product_name,product_code,classcategory_name1,classcategory_name2,price',
191      'dtb_shipment_item',
192      'order_id = ? and shipping_id = ?',
193      array($order_id, $shipping_id)
194    );
195    $this->actual['count'] = count($result);
196    $this->actual['first'] = $result[0];
197
198    $this->verify('登録された配送商品情報');
199
200  }
201 
202  //////////////////////////////////////////
203
204}
205
Note: See TracBrowser for help on using the repository browser.