1 | <?php |
---|
2 | |
---|
3 | $HOME = realpath(dirname(__FILE__)) . "/../../../.."; |
---|
4 | require_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 | */ |
---|
34 | class 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 | |
---|
166 | public function testRegisterShipmentItem_DBに存在しないカラムを指定した場合_エラーなく登録できる() |
---|
167 | { |
---|
168 | // 引数の設定 |
---|
169 | $order_id = '1'; |
---|
170 | $shipping_id = '1'; |
---|
171 | $arrParams = array( |
---|
172 | array( |
---|
173 | 'product_class_id' => '1', |
---|
174 | 'product_name' => '追加製品名01', |
---|
175 | 'product_code' => 'newcode01', |
---|
176 | 'classcategory_name1' => 'newcat01', |
---|
177 | 'classcategory_name2' => 'newcat02', |
---|
178 | 'price' => '2500', |
---|
179 | 'xxxx' => 'yyyyyy' // 存在しないカラム |
---|
180 | ) |
---|
181 | ); |
---|
182 | |
---|
183 | // 期待値の設定 |
---|
184 | $this->expected['count'] = 1; |
---|
185 | $this->expected['first'] = array( |
---|
186 | 'product_class_id' => '1', |
---|
187 | 'product_name' => '追加製品名01', |
---|
188 | 'product_code' => 'newcode01', |
---|
189 | 'classcategory_name1' => 'newcat01', |
---|
190 | 'classcategory_name2' => 'newcat02', |
---|
191 | 'price' => '2500' |
---|
192 | ); |
---|
193 | |
---|
194 | // 対象functionの呼び出し |
---|
195 | SC_Helper_Purchase::registerShipmentItem($order_id, $shipping_id, $arrParams); |
---|
196 | $result = $this->objQuery->select( |
---|
197 | 'product_class_id,product_name,product_code,classcategory_name1,classcategory_name2,price', |
---|
198 | 'dtb_shipment_item', |
---|
199 | 'order_id = ? and shipping_id = ?', |
---|
200 | array($order_id, $shipping_id) |
---|
201 | ); |
---|
202 | $this->actual['count'] = count($result); |
---|
203 | $this->actual['first'] = $result[0]; |
---|
204 | |
---|
205 | $this->verify('登録された配送商品情報'); |
---|
206 | |
---|
207 | } |
---|
208 | |
---|
209 | ////////////////////////////////////////// |
---|
210 | |
---|
211 | } |
---|
212 | |
---|