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

Revision 22202, 3.9 KB checked in by shift_hiroko.tamagawa, 11 years ago (diff)

#1977 #1978 単体テストのファイルにコピーライトを追記、定数が邪魔をしてテストできない箇所をいったんコメントアウト

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::clearShipmentItemTemp()のテストクラス.
29 *
30 *
31 * @author Hiroko Tamagawa
32 * @version $Id$
33 */
34class SC_Helper_Purchase_clearShipmentItemTempTest extends SC_Helper_Purchase_TestBase {
35
36  protected function setUp() {
37    parent::setUp();
38  }
39
40  protected function tearDown() {
41    parent::tearDown();
42  }
43
44  /////////////////////////////////////////
45  public function testClearShipmentItem_配送先ID未指定の場合_全ての配送商品がクリアされる() {
46    $this->setUpShipping($this->getMultipleShipping());
47
48    $helper = new SC_Helper_Purchase();
49    $helper->clearShipmentItemTemp(); // default:null
50
51    $this->expected = array('00001'=>null, '00002'=>null, '00003'=>null);
52    $this->actual['00001'] = $_SESSION['shipping']['00001']['shipment_item'];
53    $this->actual['00002'] = $_SESSION['shipping']['00002']['shipment_item'];
54    $this->actual['00003'] = $_SESSION['shipping']['00003']['shipment_item'];
55
56    $this->verify('配送商品');
57  }
58
59  public function testClearShipmentItem_配送先ID指定の場合_指定したIDの配送商品がクリアされる() {
60    $this->setUpShipping($this->getMultipleShipping());
61
62    $helper = new SC_Helper_Purchase();
63    $helper->clearShipmentItemTemp('00001');
64
65    $this->expected = array('00001'=>null, '00002'=>array('商品2'), '00003'=>array());
66    $this->actual['00001'] = $_SESSION['shipping']['00001']['shipment_item'];
67    $this->actual['00002'] = $_SESSION['shipping']['00002']['shipment_item'];
68    $this->actual['00003'] = $_SESSION['shipping']['00003']['shipment_item'];
69
70    $this->verify('配送商品');
71  }
72
73  public function testClearShipmentItem_存在しないIDを指定した場合_何も変更されない() {
74    $this->setUpShipping($this->getMultipleShipping());
75
76    $helper = new SC_Helper_Purchase();
77    $helper->clearShipmentItemTemp('00004');
78
79    $this->expected = array('00001'=>array('商品1'), '00002'=>array('商品2'), '00003'=>array());
80    $this->actual['00001'] = $_SESSION['shipping']['00001']['shipment_item'];
81    $this->actual['00002'] = $_SESSION['shipping']['00002']['shipment_item'];
82    $this->actual['00003'] = $_SESSION['shipping']['00003']['shipment_item'];
83
84    $this->verify('配送商品');
85  }
86
87  public function testClearShipmentItem_商品情報が配列でない場合_何も変更されない() {
88    $this->setUpShipping($this->getMultipleShipping());
89    // 内容を配列でないように変更
90    $_SESSION['shipping']['00001'] = 'temp';
91
92    $helper = new SC_Helper_Purchase();
93    $helper->clearShipmentItemTemp('00001');
94
95    // '00001'は配列でないので全体を取得
96    $this->expected = array('00001'=>'temp', '00002'=>array('商品2'), '00003'=>array());
97    $this->actual['00001'] = $_SESSION['shipping']['00001'];
98    $this->actual['00002'] = $_SESSION['shipping']['00002']['shipment_item'];
99    $this->actual['00003'] = $_SESSION['shipping']['00003']['shipment_item'];
100
101    $this->verify('配送商品');
102  }
103
104}
105
Note: See TracBrowser for help on using the repository browser.