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

Revision 22856, 4.8 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::cancelOrder()のテストクラス.
29 *
30 * @author Hiroko Tamagawa
31 * @version $Id$
32 */
33class SC_Helper_Purchase_cancelOrderTest extends SC_Helper_Purchase_TestBase
34{
35
36  private $helper;
37
38  protected function setUp()
39  {
40    parent::setUp();
41    $this->setUpProductClass();
42    $this->helper = new SC_Helper_Purchase_cancelOrderMock();
43  }
44
45  protected function tearDown()
46  {
47    parent::tearDown();
48  }
49
50  /////////////////////////////////////////
51  public function testCancelOrder_デフォルトの引数で呼び出した場合_製品クラスのデータが更新される()
52  {
53    $order_id = '1001';
54    $this->objQuery->begin();
55
56    $this->helper->cancelOrder($order_id);
57
58    $this->actual['testResult'] = $_SESSION['testResult'];
59    $this->actual['productClass'] = $this->objQuery->select(
60      'stock', 'dtb_products_class',
61      'product_class_id in (?, ?)', array('1001', '1002')
62    );
63    $this->expected = array(
64      'testResult' => array(
65        'registerOrder' => array(
66          'order_id' => '1001',
67          'params' => array(
68            'status' => ORDER_CANCEL
69          )
70        ),
71        'getOrderDetail' => array(
72          'order_id' => '1001'
73        )
74      ),
75      'productClass' => array(
76        array('stock' => '105'),
77        array('stock' => '51')
78      )
79    );
80    $this->verify();
81  }
82
83  // 実際にトランザクションを開始したかどうかはテストできないが、
84  // 問題なく処理が完了することのみ確認
85  public function testCancelOrder_トランザクションが開始していない場合_内部で開始する()
86  {
87    $order_id = '1001';
88
89    $this->helper->cancelOrder($order_id, ORDER_NEW);
90
91    $this->actual['testResult'] = $_SESSION['testResult'];
92    $this->actual['productClass'] = $this->objQuery->select(
93      'stock', 'dtb_products_class',
94      'product_class_id in (?, ?)', array('1001', '1002')
95    );
96    $this->expected = array(
97      'testResult' => array(
98        'registerOrder' => array(
99          'order_id' => '1001',
100          'params' => array(
101            'status' => ORDER_NEW
102          )
103        ),
104        'getOrderDetail' => array(
105          'order_id' => '1001'
106        )
107      ),
108      'productClass' => array(
109        array('stock' => '105'),
110        array('stock' => '51')
111      )
112    );
113
114    $this->verify();
115  }
116
117  public function testCancelOrder_削除フラグが立っている場合_DB更新時に削除フラグが立てられる()
118  {
119    $order_id = '1001';
120    $this->objQuery->begin();
121
122    $this->helper->cancelOrder($order_id, ORDER_DELIV, true);
123
124    $this->actual['testResult'] = $_SESSION['testResult'];
125    $this->actual['productClass'] = $this->objQuery->select(
126      'stock', 'dtb_products_class',
127      'product_class_id in (?, ?)', array('1001', '1002')
128    );
129    $this->expected = array(
130      'testResult' => array(
131        'registerOrder' => array(
132          'order_id' => '1001',
133          'params' => array(
134            'status' => ORDER_DELIV,
135            'del_flg' => '1'
136          )
137        ),
138        'getOrderDetail' => array(
139          'order_id' => '1001'
140        )
141      ),
142      'productClass' => array(
143        array('stock' => '105'),
144        array('stock' => '51')
145      )
146    );
147
148    $this->verify();
149  }
150
151  //////////////////////////////////////////
152
153}
154
155class SC_Helper_Purchase_cancelOrderMock extends SC_Helper_Purchase
156{
157
158  function registerOrder($order_id, $params)
159  {
160    $_SESSION['testResult']['registerOrder'] = array(
161      'order_id' => $order_id,
162      'params' => $params
163    );
164  }
165
166  function getOrderDetail($order_id)
167  {
168    $_SESSION['testResult']['getOrderDetail'] = array(
169      'order_id' => $order_id
170    );
171
172    return array(
173      array(
174        'product_class_id' => '1001',
175        'quantity' => '5'
176      ),
177      array(
178        'product_class_id' => '1002',
179        'quantity' => '1'
180      )
181    );
182  }
183}
184
Note: See TracBrowser for help on using the repository browser.