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

Revision 22857, 5.3 KB checked in by Seasoft, 11 years ago (diff)

#2043 (typo修正・ソース整形・ソースコメントの改善 for 2.13.0)

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