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

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