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

Revision 22141, 4.8 KB checked in by shift_hiroko.tamagawa, 11 years ago (diff)

#1978 SC_Helper_Purchaseの単体テスト一部を追加

  • 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-2012 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::getShipmentItems()のテストクラス.
29 *
30 *
31 * @author Hiroko Tamagawa
32 * @version $Id$
33 */
34class SC_Helper_Purchase_getShipmentItemsTest extends SC_Helper_Purchase_TestBase {
35
36  protected function setUp() {
37    parent::setUp();
38    $this->setUpShipmentItem();
39  }
40
41  protected function tearDown() {
42    parent::tearDown();
43  }
44
45  /////////////////////////////////////////
46  public function testGetShipmentItems_存在しない受注IDを指定した場合_結果が空になる() {
47    $order_id = '100'; // 存在しないID
48    $shipping_id = '1';
49
50    $this->expected = array();
51    $this->actual = SC_Helper_Purchase::getShipmentItems($order_id, $shipping_id);
52
53    $this->verify('配送情報');
54  }
55
56  public function testGetShipmentItems_存在しない配送先IDを指定した場合_結果が空になる() {
57    $order_id = '1';
58    $shipping_id = '100'; // 存在しないID
59
60    $this->expected = array();
61    $this->actual = SC_Helper_Purchase::getShipmentItems($order_id, $shipping_id);
62
63    $this->verify('配送情報');
64  }
65
66  public function testGetShipmentItems_存在する受注IDと配送先IDを指定した場合_結果が取得できる() {
67    $order_id = '1';
68    $shipping_id = '1';
69   
70    $this->expected['count'] = 2;
71    $this->expected['first'] = array(
72      'order_id' => '1',
73      'shipping_id' => '1',
74      'product_class_id' => '1001',
75      'product_name' => '商品名01',
76      'price' => '1500',
77      'productsClass' => array('product_class_id' => '1001', 'product_id' => '1001')
78    );
79    $this->expected['second'] = array(
80      'order_id' => '1',
81      'shipping_id' => '1',
82      'product_class_id' => '1002',
83      'product_name' => '商品名02',
84      'price' => '2400',
85      'productsClass' => array('product_class_id' => '1002', 'product_id' => '1002')
86    );
87
88    $result = SC_Helper_Purchase::getShipmentItems($order_id, $shipping_id);
89    $this->actual['count'] = count($result);
90    $this->actual['first'] = Test_Utils::mapArray($result[0], array(
91      'order_id', 'shipping_id', 'product_class_id', 'product_name', 'price', 'productsClass'));
92    $this->actual['first']['productsClass'] = Test_Utils::mapArray($this->actual['first']['productsClass'], array('product_class_id', 'product_id'));
93    $this->actual['second'] = Test_Utils::mapArray($result[1], array(
94      'order_id', 'shipping_id', 'product_class_id', 'product_name', 'price', 'productsClass'));
95    $this->actual['second']['productsClass'] = Test_Utils::mapArray($this->actual['second']['productsClass'], array('product_class_id', 'product_id'));
96    $this->verify('配送情報');
97  }
98
99  public function testGetShipmentItems_詳細フラグをOFFにした場合_結果に詳細情報が含まれない() {
100    $order_id = '1';
101    $shipping_id = '1';
102   
103    $this->expected['count'] = 2;
104    $this->expected['first'] = array(
105      'order_id' => '1',
106      'shipping_id' => '1',
107      'product_class_id' => '1001',
108      'product_name' => '商品名01',
109      'price' => '1500',
110      'productsClass' => null
111    );
112    $this->expected['second'] = array(
113      'order_id' => '1',
114      'shipping_id' => '1',
115      'product_class_id' => '1002',
116      'product_name' => '商品名02',
117      'price' => '2400',
118      'productsClass' => null
119    );
120
121    $result = SC_Helper_Purchase::getShipmentItems($order_id, $shipping_id, false);
122    $this->actual['count'] = count($result);
123    $this->actual['first'] = Test_Utils::mapArray($result[0], array(
124      'order_id', 'shipping_id', 'product_class_id', 'product_name', 'price', 'productsClass'));
125    $this->actual['second'] = Test_Utils::mapArray($result[1], array(
126      'order_id', 'shipping_id', 'product_class_id', 'product_name', 'price', 'productsClass'));
127    $this->verify('配送情報');
128
129  }
130
131  //////////////////////////////////////////
132
133}
134
Note: See TracBrowser for help on using the repository browser.