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

Revision 22247, 3.5 KB checked in by shift_hiroko.tamagawa, 11 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-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::registerOrderDetail()のテストクラス.
29 *
30 * @author Hiroko Tamagawa
31 * @version $Id$
32 */
33class SC_Helper_Purchase_registerOrderDetailTest extends SC_Helper_Purchase_TestBase {
34
35  protected function setUp() {
36    parent::setUp();
37    $this->setUpOrderDetail();
38  }
39
40  protected function tearDown() {
41    parent::tearDown();
42  }
43
44  /////////////////////////////////////////
45  public function testRegisterOrderDetail_該当の受注が存在する場合_削除後に新しい情報が登録される() {
46    $params = array(
47      array(
48      'order_id' => '1001',
49      'hoge' => '999', // DBに存在しないカラム
50      'product_id' => '9001',
51      'product_class_id' => '9001',
52      'product_name' => '製品名9001'
53      )
54    );
55    SC_Helper_Purchase::registerOrderDetail('1001', $params);
56
57    $this->expected['count'] = '2'; // 同じorder_idのものが消されるので1行減る
58    $this->expected['content'] = array(
59      'order_id' => '1001',
60      'product_id' => '9001',
61      'product_class_id' => '9001',
62      'product_name' => '製品名9001',
63      'product_code' => null // 古いデータにはあるが、deleteされたので消えている
64    );
65
66    $this->actual['count'] = $this->objQuery->count('dtb_order_detail');
67    $result = $this->objQuery->select(
68      'order_id, product_id, product_class_id, product_name, product_code',
69      'dtb_order_detail',
70      'order_id = ?',
71      array('1001')
72    );
73    $this->actual['content'] = $result[0];
74
75    $this->verify();
76  }
77
78  public function testRegisterOrderDetail_該当の受注が存在しない場合_新しい情報が追加登録される() {
79    $params = array(
80      array(
81      'order_id' => '1003',
82      'hoge' => '999', // DBに存在しないカラム
83      'product_id' => '9003',
84      'product_class_id' => '9003',
85      'product_name' => '製品名9003'
86      )
87    );
88    SC_Helper_Purchase::registerOrderDetail('1003', $params);
89
90    $this->expected['count'] = '4';
91    $this->expected['content'] = array(
92      'order_id' => '1003',
93      'product_id' => '9003',
94      'product_class_id' => '9003',
95      'product_name' => '製品名9003',
96      'product_code' => null
97    );
98
99    $this->actual['count'] = $this->objQuery->count('dtb_order_detail');
100    $result = $this->objQuery->select(
101      'order_id, product_id, product_class_id, product_name, product_code',
102      'dtb_order_detail',
103      'order_id = ?',
104      array('1003')
105    );
106    $this->actual['content'] = $result[0];
107
108    $this->verify();
109  }
110  //////////////////////////////////////////
111
112}
113
Note: See TracBrowser for help on using the repository browser.