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

Revision 22567, 5.8 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::registerOrder()のテストクラス.
29 *
30 *
31 * @author Hiroko Tamagawa
32 * @version $Id$
33 */
34class SC_Helper_Purchase_registerOrderTest extends SC_Helper_Purchase_TestBase
35{
36
37  private $helper;
38
39  protected function setUp()
40  {
41    parent::setUp();
42    $this->setUpOrder();
43    $this->helper = new SC_Helper_Purchase_registerOrderMock();
44  }
45
46  protected function tearDown()
47  {
48    parent::tearDown();
49  }
50
51  /////////////////////////////////////////
52  public function testRegisterOrder_既に受注IDが存在する場合_情報が更新される()
53  {
54    $order_id = '1001';
55    $arrParams = array(
56      'status' => '1',
57      'add_point' => 10,
58      'use_point' => 20,
59      'order_name01' => '受注情報01_更新'
60    );
61
62    $this->helper->registerOrder($order_id, $arrParams);
63
64    $this->expected = array(
65      'sfUpdateOrderStatus' => array(
66        'order_id' => '1001',
67        'status' => '1',
68        'add_point' => 10,
69        'use_point' => 20
70      ),
71      'sfUpdateOrderNameCol' => '1001',
72      'count' => '2',
73      'content' => array(
74        'order_id' => '1001',
75        'customer_id' => '1001',
76        'status' => '1',
77        'add_point' => '10',
78        'use_point' => '20',
79        'order_name01' => '受注情報01_更新'
80      )
81    );
82    $this->actual = $_SESSION['testResult'];
83    $this->actual['count'] = $this->objQuery->count('dtb_order');
84    $result = $this->objQuery->select(
85      'order_id, customer_id, status, order_name01, add_point, use_point',
86      'dtb_order',
87      'order_id = ?',
88      array($order_id)
89    );
90    $this->actual['content'] = $result[0];
91
92    $this->verify();
93  }
94
95  public function testRegisterOrder_存在しない受注IDを指定した場合_新規に登録される()
96  {
97    $order_id = '1003';
98    $arrParams = array(
99      'customer_id' => '1003',
100      'status' => '2',
101      'add_point' => 100,
102      'use_point' => 200,
103      'order_name01' => '受注情報03'
104    );
105
106    $this->helper->registerOrder($order_id, $arrParams);
107
108    $this->expected = array(
109      'sfUpdateOrderStatus' => array(
110        'order_id' => '1003',
111        'status' => '2',
112        'add_point' => 100,
113        'use_point' => 200
114      ),
115      'sfUpdateOrderNameCol' => '1003',
116      'count' => '3',
117      'content' => array(
118        'order_id' => '1003',
119        'customer_id' => '1003',
120        'status' => null,         // ここではsfUpdateOrderStatusをモックにしているので更新されない
121        'add_point' => '100',
122        'use_point' => '200',
123        'order_name01' => '受注情報03'
124      )
125    );
126    $this->actual = $_SESSION['testResult'];
127    $this->actual['count'] = $this->objQuery->count('dtb_order');
128    $result = $this->objQuery->select(
129      'order_id, customer_id, status, order_name01, add_point, use_point',
130      'dtb_order',
131      'order_id = ?',
132      array($order_id)
133    );
134    $this->actual['content'] = $result[0];
135
136    $this->verify();
137  }
138
139  public function testRegisterOrder_受注IDが未指定の場合_新たにIDが発行される()
140  {
141    $order_id = '';
142    $arrParams = array( // 顧客IDも未指定
143      'status' => '2',
144      'add_point' => 100,
145      'use_point' => 200,
146      'order_name01' => '受注情報03'
147    );
148
149    // SEQの値を取得
150    $new_order_id = $this->helper->getNextOrderID() + 1;
151
152    $this->helper->registerOrder($order_id, $arrParams);
153
154    $this->expected = array(
155      'sfUpdateOrderStatus' => array(
156        'order_id' => $new_order_id,
157        'status' => '2',
158        'add_point' => 100,
159        'use_point' => 200
160      ),
161      'sfUpdateOrderNameCol' => $new_order_id,
162      'count' => '3',
163      'content' => array(
164        'order_id' => $new_order_id,
165        'customer_id' => '0',
166        'status' => null,         // ここではsfUpdateOrderStatusをモックにしているので更新されない
167        'add_point' => '100',
168        'use_point' => '200',
169        'order_name01' => '受注情報03'
170      )
171    );
172    $this->actual = $_SESSION['testResult'];
173    $this->actual['count'] = $this->objQuery->count('dtb_order');
174    $result = $this->objQuery->select(
175      'order_id, customer_id, status, order_name01, add_point, use_point',
176      'dtb_order',
177      'order_id = ?',
178      array($new_order_id)
179    );
180    $this->actual['content'] = $result[0];
181
182    $this->verify();
183
184  }
185
186  //////////////////////////////////////////
187
188}
189
190class SC_Helper_Purchase_registerOrderMock extends SC_Helper_Purchase
191{
192  function sfUpdateOrderStatus($order_id, $status, $add_point, $use_point, $values)
193  {
194    $_SESSION['testResult']['sfUpdateOrderStatus'] = array(
195      'order_id' => $order_id,
196      'status' => $status,
197      'add_point' => $add_point,
198      'use_point' => $use_point,
199    );
200  }
201
202  function sfUpdateOrderNameCol($order_id)
203  {
204   $_SESSION['testResult']['sfUpdateOrderNameCol'] = $order_id;
205  }
206}
207
Note: See TracBrowser for help on using the repository browser.