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

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