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

Revision 22257, 5.2 KB checked in by shift_hiroko.tamagawa, 9 years ago (diff)

#1978 SC_Helper_Purchase単体テスト(completeOrder)の修正

  • 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::completeOrder()のテストクラス.
29 *
30 *
31 * @author Hiroko Tamagawa
32 * @version $Id$
33 */
34class SC_Helper_Purchase_completeOrderTest extends SC_Helper_Purchase_TestBase {
35
36  private $helper;
37
38  protected function setUp() {
39    parent::setUp();
40    $this->setUpOrder();
41    $this->setUpOrderTemp(); // order_temp_id = '1001'
42    $this->setUpShipping();
43    $this->setUpCustomer();
44
45    $_SESSION['cartKey'] = '1';
46    $_SESSION['site'] = array(
47      'pre_page' => 'pre',
48      'now_page' => 'now',
49      'regist_success' => TRUE,
50      'uniqid' => '1001'
51    );
52
53    $this->helper = new SC_Helper_Purchase_completeOrderMock();
54  }
55
56  protected function tearDown() {
57    parent::tearDown();
58  }
59
60  /////////////////////////////////////////
61  // 適切なfunctionが呼ばれていることのみ確認
62  public function testCompleteOrder_顧客IDが指定されている場合_購入日が更新される() {
63    $_SESSION['customer']['customer_id'] = '1002'; // 顧客ID
64    $this->helper->completeOrder(ORDER_DELIV);
65
66    $this->expected = array(
67      'verifyChangeCart' => array(
68        'uniqId' => '1001'
69      ),
70      'getOrderTemp' => array(
71        'uniqId' => '1001'
72      ),
73      'registerOrderComplete' => array(
74        'order_temp_id' => '1001',
75        'status' => ORDER_DELIV,
76        'cartKey' => '1'
77      ),
78      'registerShipmentItem' => array(
79        array(
80          'order_id' => '1001',
81          'shipping_id' => '00001',
82          'shipment_item' => '商品1'
83        )
84      ),
85      'registerShipping' => array(
86        'order_id' => '1001'
87      ),
88      'cleanupSession' => array(
89        'order_id' => '1001',
90        'cartKey' => '1'
91      )
92    );
93    $this->actual = $_SESSION['testResult'];
94    $this->verify('適切なfunctionが呼ばれている');
95    $last_buy_date = $this->objQuery->get('last_buy_date', 'dtb_customer', 'customer_id = ?', '1002');
96    $this->assertNotNull($last_buy_date, '最終購入日');
97  }
98
99  public function testCompleteOrder_顧客IDが指定されていない場合_特にエラーなく修了できる() {
100    $this->helper->completeOrder(); // デフォルトのステータス(NEW)
101
102    $this->expected = array(
103      'verifyChangeCart' => array(
104        'uniqId' => '1001'
105      ),
106      'getOrderTemp' => array(
107        'uniqId' => '1001'
108      ),
109      'registerOrderComplete' => array(
110        'order_temp_id' => '1001',
111        'status' => ORDER_NEW,
112        'cartKey' => '1'
113      ),
114      'registerShipmentItem' => array(
115        array(
116          'order_id' => '1001',
117          'shipping_id' => '00001',
118          'shipment_item' => '商品1'
119        )
120      ),
121      'registerShipping' => array(
122        'order_id' => '1001'
123      ),
124      'cleanupSession' => array(
125        'order_id' => '1001',
126        'cartKey' => '1'
127      )
128    );
129    $this->actual = $_SESSION['testResult'];
130    $this->verify('適切なfunctionが呼ばれている');
131  }
132
133  //////////////////////////////////////////
134
135}
136
137class SC_Helper_Purchase_completeOrderMock extends SC_Helper_Purchase{
138
139  function verifyChangeCart($uniqId, $objCartSession){
140    $_SESSION['testResult']['verifyChangeCart'] = array('uniqId'=>$uniqId);
141  }
142
143  function getOrderTemp($uniqId) {
144    $_SESSION['testResult']['getOrderTemp'] = array('uniqId'=>$uniqId);
145    return parent::getOrderTemp($uniqId);
146  }
147
148  function registerOrderComplete($orderTemp, $objCartSession, $cartKey) {
149    $_SESSION['testResult']['registerOrderComplete'] = array(
150      'order_temp_id' => $orderTemp['order_temp_id'],
151      'status' => $orderTemp['status'],
152      'cartKey' => $cartKey
153    );
154    return parent::registerOrderComplete($orderTemp, $objCartSession, $cartKey);
155  }
156
157  function registerShipmentItem($order_id, $shipping_id, $shipment_item) {
158    $_SESSION['testResult']['registerShipmentItem'][] = array(
159      'order_id' => $order_id,
160      'shipping_id' => $shipping_id,
161      'shipment_item' => $shipment_item
162    );
163  }
164
165  function registerShipping($order_id, $shipping_temp) {
166    $_SESSION['testResult']['registerShipping'] = array(
167      'order_id' => $order_id
168    );
169  }
170
171  function cleanupSession($order_id, $objCartSesion, $objCustomer, $cartKey) {
172    $_SESSION['testResult']['cleanupSession'] = array(
173      'order_id' => $order_id,
174      'cartKey' => $cartKey
175    );
176  }
177
178}
179
180?>
181
Note: See TracBrowser for help on using the repository browser.