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

Revision 22796, 6.8 KB checked in by h_yoshimoto, 11 years ago (diff)

#2236 2.12.3リリース以降の2.12-devへのコミット差し戻し

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