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

Revision 22857, 6.6 KB checked in by Seasoft, 11 years ago (diff)

#2043 (typo修正・ソース整形・ソースコメントの改善 for 2.13.0)

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