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

Revision 23356, 4.8 KB checked in by kimoto, 10 years ago (diff)

#2485 テストデータが矛盾しているので修正

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