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::registerShipping()のテストクラス. |
---|
29 | * |
---|
30 | * |
---|
31 | * @author Hiroko Tamagawa |
---|
32 | * @version $Id$ |
---|
33 | */ |
---|
34 | class SC_Helper_Purchase_registerShippingTest extends SC_Helper_Purchase_TestBase |
---|
35 | { |
---|
36 | |
---|
37 | protected function setUp() |
---|
38 | { |
---|
39 | parent::setUp(); |
---|
40 | $this->setUpShippingOnDb(); |
---|
41 | } |
---|
42 | |
---|
43 | protected function tearDown() |
---|
44 | { |
---|
45 | parent::tearDown(); |
---|
46 | } |
---|
47 | |
---|
48 | ///////////////////////////////////////// |
---|
49 | public function testRegisterShipping_元々存在しない受注IDの場合_新規にデータが作られる() |
---|
50 | { |
---|
51 | $order_id = '10'; |
---|
52 | $arrParams = array( |
---|
53 | '20' => |
---|
54 | array( |
---|
55 | 'order_id' => '10', |
---|
56 | 'shipping_id' => '20', |
---|
57 | 'shipping_name01' => '配送情報10', |
---|
58 | 'shipping_date' => '2012/01/12' |
---|
59 | ) |
---|
60 | ); |
---|
61 | |
---|
62 | $this->expected['count'] = '4'; // 1件増える |
---|
63 | $this->expected['content'] = array( |
---|
64 | 'order_id' => '10', |
---|
65 | 'shipping_id' => '20', |
---|
66 | 'shipping_name01' => '配送情報10', |
---|
67 | 'shipping_date' => '2012-01-12 00:00:00' |
---|
68 | ); |
---|
69 | |
---|
70 | SC_Helper_Purchase::registerShipping($order_id, $arrParams); |
---|
71 | |
---|
72 | $this->actual['count'] = $this->objQuery->count('dtb_shipping'); |
---|
73 | $this->result = $this->objQuery->setWhere('order_id = ?') |
---|
74 | ->select( |
---|
75 | 'order_id,shipping_id,shipping_name01,shipping_date,create_date,update_date', |
---|
76 | 'dtb_shipping', |
---|
77 | '', |
---|
78 | array($order_id)); |
---|
79 | $this->actual['content'] = $this->result[0]; |
---|
80 | unset($this->actual['content']['create_date']); |
---|
81 | unset($this->actual['content']['update_date']); |
---|
82 | $this->verify('登録した配送情報'); |
---|
83 | $this->assertNotNull($this->result[0]['create_date']); |
---|
84 | $this->assertNotNull($this->result[0]['update_date']); |
---|
85 | } |
---|
86 | |
---|
87 | public function testRegisterShipping_元々存在する受注IDの場合_既存のデータが置き換えられる() |
---|
88 | { |
---|
89 | $order_id = '2'; |
---|
90 | $arrParams = array( |
---|
91 | '30' => |
---|
92 | array( |
---|
93 | 'order_id' => '2', |
---|
94 | 'shipping_id' => '30', |
---|
95 | 'shipping_name01' => '配送情報02-update', |
---|
96 | 'shipping_date' => '2013/12/03' |
---|
97 | ) |
---|
98 | ); |
---|
99 | |
---|
100 | $this->expected['count'] = '3'; // 件数が変わらない |
---|
101 | $this->expected['content'] = array( |
---|
102 | 'order_id' => '2', |
---|
103 | 'shipping_id' => '30', |
---|
104 | 'shipping_name01' => '配送情報02-update', |
---|
105 | 'shipping_date' => '2013-12-03 00:00:00' |
---|
106 | ); |
---|
107 | |
---|
108 | SC_Helper_Purchase::registerShipping($order_id, $arrParams); |
---|
109 | |
---|
110 | $this->actual['count'] = $this->objQuery->count('dtb_shipping'); |
---|
111 | $this->result = $this->objQuery->setWhere('order_id = ?') |
---|
112 | ->select( |
---|
113 | 'order_id,shipping_id,shipping_name01,shipping_date,create_date,update_date', |
---|
114 | 'dtb_shipping', |
---|
115 | '', |
---|
116 | array($order_id)); |
---|
117 | $this->actual['content'] = $this->result[0]; |
---|
118 | unset($this->actual['content']['create_date']); |
---|
119 | unset($this->actual['content']['update_date']); |
---|
120 | $this->verify('登録した配送情報'); |
---|
121 | $this->assertNotNull($this->result[0]['create_date']); |
---|
122 | $this->assertNotNull($this->result[0]['update_date']); |
---|
123 | } |
---|
124 | |
---|
125 | public function testRegisterShipping_配送日付が空の場合_エラーが起きず変換処理がスキップされる() |
---|
126 | { |
---|
127 | $order_id = '2'; |
---|
128 | $arrParams = array( |
---|
129 | '30' => |
---|
130 | array( |
---|
131 | 'order_id' => '2', |
---|
132 | 'shipping_id' => '30', |
---|
133 | 'shipping_name01' => '配送情報02-update' |
---|
134 | // 'shipping_date' => '2013/12/03 00:00:00' |
---|
135 | ) |
---|
136 | ); |
---|
137 | |
---|
138 | $this->expected['count'] = '3'; |
---|
139 | $this->expected['content'] = array( |
---|
140 | 'order_id' => '2', |
---|
141 | 'shipping_id' => '30', |
---|
142 | 'shipping_name01' => '配送情報02-update', |
---|
143 | 'shipping_date' => NULL |
---|
144 | ); |
---|
145 | |
---|
146 | SC_Helper_Purchase::registerShipping($order_id, $arrParams); |
---|
147 | |
---|
148 | $this->actual['count'] = $this->objQuery->count('dtb_shipping'); |
---|
149 | $this->result = $this->objQuery->setWhere('order_id = ?') |
---|
150 | ->select( |
---|
151 | 'order_id,shipping_id,shipping_name01,shipping_date,create_date,update_date', |
---|
152 | 'dtb_shipping', |
---|
153 | '', |
---|
154 | array($order_id)); |
---|
155 | $this->actual['content'] = $this->result[0]; |
---|
156 | unset($this->actual['content']['create_date']); |
---|
157 | unset($this->actual['content']['update_date']); |
---|
158 | $this->verify('登録した配送情報'); |
---|
159 | $this->assertNotNull($this->result[0]['create_date']); |
---|
160 | $this->assertNotNull($this->result[0]['update_date']); |
---|
161 | } |
---|
162 | |
---|
163 | public function testRegisterShipping_非会員購入の場合_配送IDが設定される() |
---|
164 | { |
---|
165 | $order_id = '2'; |
---|
166 | $arrParams = array( |
---|
167 | '30' => |
---|
168 | array( |
---|
169 | 'order_id' => '2', |
---|
170 | // 'shipping_id' => '30', |
---|
171 | 'shipping_name01' => '配送情報02-update', |
---|
172 | 'shipping_date' => '2013/12/03 00:00:00' |
---|
173 | ) |
---|
174 | ); |
---|
175 | |
---|
176 | $this->expected['count'] = '3'; // 件数が変わらない |
---|
177 | $this->expected['content'] = array( |
---|
178 | 'order_id' => '2', |
---|
179 | 'shipping_id' => '30', |
---|
180 | 'shipping_name01' => '配送情報02-update', |
---|
181 | 'shipping_date' => '2013-12-03 00:00:00' |
---|
182 | ); |
---|
183 | |
---|
184 | SC_Helper_Purchase::registerShipping($order_id, $arrParams); |
---|
185 | |
---|
186 | $this->actual['count'] = $this->objQuery->count('dtb_shipping'); |
---|
187 | $this->result = $this->objQuery->setWhere('order_id = ?') |
---|
188 | ->select( |
---|
189 | 'order_id,shipping_id,shipping_name01,shipping_date,create_date,update_date', |
---|
190 | 'dtb_shipping', |
---|
191 | '', |
---|
192 | array($order_id)); |
---|
193 | $this->actual['content'] = $this->result[0]; |
---|
194 | unset($this->actual['content']['create_date']); |
---|
195 | unset($this->actual['content']['update_date']); |
---|
196 | $this->verify('登録した配送情報'); |
---|
197 | $this->assertNotNull($this->result[0]['create_date']); |
---|
198 | $this->assertNotNull($this->result[0]['update_date']); |
---|
199 | } |
---|
200 | |
---|
201 | ////////////////////////////////////////// |
---|
202 | |
---|
203 | } |
---|
204 | |
---|