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::getShippings()のテストクラス. |
---|
29 | * |
---|
30 | * |
---|
31 | * @author Hiroko Tamagawa |
---|
32 | * @version $Id$ |
---|
33 | */ |
---|
34 | class SC_Helper_Purchase_getShippingsTest extends SC_Helper_Purchase_TestBase |
---|
35 | { |
---|
36 | |
---|
37 | |
---|
38 | protected function setUp() |
---|
39 | { |
---|
40 | parent::setUp(); |
---|
41 | $this->setUpShipmentItem(); |
---|
42 | $this->setUpShippingOnDb(); |
---|
43 | } |
---|
44 | |
---|
45 | protected function tearDown() |
---|
46 | { |
---|
47 | parent::tearDown(); |
---|
48 | } |
---|
49 | |
---|
50 | ///////////////////////////////////////// |
---|
51 | public function testGetShippings_存在しない受注IDを指定した場合_結果が空になる() |
---|
52 | { |
---|
53 | $order_id = '100'; // 存在しないID |
---|
54 | |
---|
55 | $this->expected = array(); |
---|
56 | $helper = new SC_Helper_Purchase(); |
---|
57 | $this->actual = $helper->getShippings($order_id); |
---|
58 | |
---|
59 | $this->verify('配送情報'); |
---|
60 | } |
---|
61 | |
---|
62 | public function testGetShippings_存在する受注IDを指定した場合_結果が取得できる() |
---|
63 | { |
---|
64 | $order_id = '1'; |
---|
65 | |
---|
66 | $this->expected['count'] = 1; |
---|
67 | $this->expected['first'] = array( |
---|
68 | 'order_id' => '1', |
---|
69 | 'shipping_id' => '1', |
---|
70 | 'shipping_name01' => '配送情報01', |
---|
71 | 'shipping_date' => '2012-01-12 00:00:00' |
---|
72 | ); |
---|
73 | $this->expected['shipment_item_count'] = 2; |
---|
74 | |
---|
75 | $helper = new SC_Helper_Purchase(); |
---|
76 | $result = $helper->getShippings($order_id); |
---|
77 | $this->actual['count'] = count($result); |
---|
78 | // shipping_idごとの配列になっているのでshipping_idで抽出 |
---|
79 | $this->actual['first'] = Test_Utils::mapArray($result['1'], array( |
---|
80 | 'order_id', 'shipping_id', 'shipping_name01', 'shipping_date')); |
---|
81 | $this->actual['shipment_item_count'] = count($result['1']['shipment_item']); |
---|
82 | $this->verify('配送情報'); |
---|
83 | } |
---|
84 | |
---|
85 | public function testGetShippings_商品取得フラグをOFFにした場合_結果に商品情報が含まれない() |
---|
86 | { |
---|
87 | $order_id = '1'; |
---|
88 | |
---|
89 | $this->expected['count'] = 1; |
---|
90 | $this->expected['first'] = array( |
---|
91 | 'order_id' => '1', |
---|
92 | 'shipping_id' => '1', |
---|
93 | 'shipping_name01' => '配送情報01', |
---|
94 | 'shipping_date' => '2012-01-12 00:00:00' |
---|
95 | ); |
---|
96 | $this->expected['shipment_item_count'] = 0; |
---|
97 | |
---|
98 | $helper = new SC_Helper_Purchase(); |
---|
99 | $result = $helper->getShippings($order_id, false); |
---|
100 | $this->actual['count'] = count($result); |
---|
101 | // shipping_idごとの配列になっているのでshipping_idで抽出 |
---|
102 | $this->actual['first'] = Test_Utils::mapArray($result['1'], array( |
---|
103 | 'order_id', 'shipping_id', 'shipping_name01', 'shipping_date')); |
---|
104 | $this->actual['shipment_item_count'] = count($result['1']['shipment_item']); |
---|
105 | $this->verify('配送情報'); |
---|
106 | } |
---|
107 | |
---|
108 | ////////////////////////////////////////// |
---|
109 | } |
---|
110 | |
---|