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

Revision 22204, 4.9 KB checked in by shift_hiroko.tamagawa, 8 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::registerOrderComplete()のテストクラス.
29 * TODO 在庫の減少処理はエラー表示⇒exit呼び出しとなるためテスト不可.
30 *
31 * @author Hiroko Tamagawa
32 * @version $Id$
33 */
34
35class SC_Helper_Purchase_registerOrderCompleteTest extends SC_Helper_Purchase_TestBase {
36  private $helper;
37
38  protected function setUp() {
39    parent::setUp();
40    $this->setUpOrderTemp();
41    $this->helper = new SC_Helper_Purchase_registerOrderCompleteMock();
42  }
43
44  protected function tearDown() {
45    parent::tearDown();
46  }
47
48  /////////////////////////////////////////
49  public function testRegisterOrderComplete_不要な変数が含まれている場合_登録前に除外される() {
50    // 引数の準備
51    $orderParams = array(
52      'order_id' => '1001',
53      'status' => ORDER_PAY_WAIT,
54      'mail_maga_flg' => '1',
55      'order_tax_rate' => '5',
56      'order_tax_rule' => '1'
57    );
58    $cartSession = new SC_CartSession_registerOrderCompleteMock();
59    $_SESSION['site']['uniqid'] = '1001';
60
61    $this->helper->registerOrderComplete($orderParams, $cartSession, '1');
62 
63    $this->expected = array(
64      'registerOrder' => array(
65        'order_id' => '1001',
66        'status' => ORDER_PAY_WAIT,
67        'mailmaga_flg' => null
68      ),
69      'registerOrderDetail' => array(
70        'order_id' => '1001',
71        'params' => array(
72          array(
73            'order_id' => '1001',
74            'product_id' => '1002',
75            'product_class_id' => '1002',
76            'product_name' => '製品02',
77            'product_code' => 'cd1002',
78            'classcategory_name1' => 'cat01',
79            'classcategory_name2' => 'cat02',
80            'point_rate' => '5',
81            'price' => '1000',
82            'quantity' => '10',
83            'tax_rate' => '5',
84            'tax_rule' => '1'
85          )
86        )
87      ),
88      'del_flg' => '1'
89    );
90
91    $this->actual = $_SESSION['testResult'];
92    $this->actual['del_flg'] = $this->objQuery->get('del_flg', 'dtb_order_temp', 'order_temp_id = ?', '1001');
93    $this->verify();
94  }
95
96  public function testRegisterOrderComplete_ステータスの指定がない場合_新規受付扱いとなる() {
97    // 引数の準備
98    $orderParams = array(
99      'order_id' => '1001',
100    //  'status' => ORDER_PAY_WAIT,
101      'order_tax_rate' => '5',
102      'order_tax_rule' => '1'
103    );
104    $cartSession = new SC_CartSession_registerOrderCompleteMock();
105    $_SESSION['site']['uniqid'] = '1001';
106
107    $this->helper->registerOrderComplete($orderParams, $cartSession, '1');
108 
109    // 上の条件と重複する部分は確認を省略
110    $this->expected = array(
111      'registerOrder' => array(
112        'order_id' => '1001',
113        'status' => ORDER_NEW,
114        'mailmaga_flg' => null
115      )
116    );
117
118    $this->actual['registerOrder'] = $_SESSION['testResult']['registerOrder'];
119    $this->verify();
120  }
121
122  //////////////////////////////////////////
123
124}
125
126class SC_Helper_Purchase_registerOrderCompleteMock extends SC_Helper_Purchase {
127
128  function registerOrder($order_id, $params) {
129    $_SESSION['testResult']['registerOrder'] = array(
130      'order_id' => $order_id,
131      'status' => $params['status'],
132      'mailmaga_flg' => $params['mailmaga_flg']
133    );
134  }
135
136  function registerOrderDetail($order_id, $params) {
137    $_SESSION['testResult']['registerOrderDetail'] = array(
138      'order_id' => $order_id,
139      'params' => $params
140    );
141  }
142
143  function setUniqId() {}
144}
145
146class SC_CartSession_registerOrderCompleteMock extends SC_CartSession {
147
148  // カートの内容を取得
149  function getCartList($cartKey) {
150    return array(
151      array(
152        'productsClass' => array(
153          'product_id' => '1002',
154          'product_class_id' => '1002',
155          'name' => '製品02',
156          'product_code' => 'cd1002',
157          'classcategory_name1' => 'cat01',
158          'classcategory_name2' => 'cat02'
159        ),
160        'point_rate' => '5',
161        'price' => '1000',
162        'quantity' => '10'
163      )
164    );
165  }
166}
167?>
168
Note: See TracBrowser for help on using the repository browser.