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

Revision 22567, 4.9 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::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}
130
131class SC_Helper_Purchase_registerOrderCompleteMock extends SC_Helper_Purchase
132{
133
134  function registerOrder($order_id, $params)
135  {
136    $_SESSION['testResult']['registerOrder'] = array(
137      'order_id' => $order_id,
138      'status' => $params['status'],
139      'mailmaga_flg' => $params['mailmaga_flg']
140    );
141  }
142
143  function registerOrderDetail($order_id, $params)
144  {
145    $_SESSION['testResult']['registerOrderDetail'] = array(
146      'order_id' => $order_id,
147      'params' => $params
148    );
149  }
150
151  function setUniqId()
152  {}
153}
154
155class SC_CartSession_registerOrderCompleteMock extends SC_CartSession
156{
157
158  // カートの内容を取得
159  function getCartList($cartKey)
160  {
161    return array(
162      array(
163        'productsClass' => array(
164          'product_id' => '1002',
165          'product_class_id' => '1002',
166          'name' => '製品02',
167          'product_code' => 'cd1002',
168          'classcategory_name1' => 'cat01',
169          'classcategory_name2' => 'cat02'
170        ),
171        'point_rate' => '5',
172        'price' => '1000',
173        'quantity' => '10'
174      )
175    );
176  }
177}
178?>
179
Note: See TracBrowser for help on using the repository browser.