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

Revision 22567, 5.3 KB checked in by shutta, 11 years ago (diff)

#2043 (typo修正・ソース整形・ソースコメントの改善 for 2.12.4)
Zend Framework PHP 標準コーディング規約のコーディングスタイルへ準拠。
classおよびfunctionの開始波括弧「{」のスタイルを修正。

  • 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}
141
142class SC_Helper_Purchase_completeOrderMock extends SC_Helper_Purchase
143{
144
145  function verifyChangeCart($uniqId, $objCartSession)
146  {
147    $_SESSION['testResult']['verifyChangeCart'] = array('uniqId'=>$uniqId);
148  }
149
150  function getOrderTemp($uniqId)
151  {
152    $_SESSION['testResult']['getOrderTemp'] = array('uniqId'=>$uniqId);
153    return parent::getOrderTemp($uniqId);
154  }
155
156  function registerOrderComplete($orderTemp, $objCartSession, $cartKey)
157  {
158    $_SESSION['testResult']['registerOrderComplete'] = array(
159      'order_temp_id' => $orderTemp['order_temp_id'],
160      'status' => $orderTemp['status'],
161      'cartKey' => $cartKey
162    );
163    return parent::registerOrderComplete($orderTemp, $objCartSession, $cartKey);
164  }
165
166  function registerShipmentItem($order_id, $shipping_id, $shipment_item)
167  {
168    $_SESSION['testResult']['registerShipmentItem'][] = array(
169      'order_id' => $order_id,
170      'shipping_id' => $shipping_id,
171      'shipment_item' => $shipment_item
172    );
173  }
174
175  function registerShipping($order_id, $shipping_temp)
176  {
177    $_SESSION['testResult']['registerShipping'] = array(
178      'order_id' => $order_id
179    );
180  }
181
182  function cleanupSession($order_id, $objCartSesion, $objCustomer, $cartKey)
183  {
184    $_SESSION['testResult']['cleanupSession'] = array(
185      'order_id' => $order_id,
186      'cartKey' => $cartKey
187    );
188  }
189
190}
191
192?>
193
Note: See TracBrowser for help on using the repository browser.