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

Revision 22735, 4.2 KB checked in by h_yoshimoto, 8 years ago (diff)

#2193 ユニットテストチームのコミットをマージ(from camp/camp-2_13-tests)

  • 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
36  protected function setUp()
37  {
38    parent::setUp();
39    $this->setUpOrderDetail();
40  }
41
42  protected function tearDown()
43  {
44    parent::tearDown();
45  }
46
47  /////////////////////////////////////////
48  public function testRegisterOrderDetail_該当の受注が存在する場合_削除後に新しい情報が登録される()
49  {
50      if(DB_TYPE != 'pgsql') { //postgresqlだとどうしてもDBエラーになるのでとりいそぎ回避
51            $params = array(
52            array(
53            'order_id' => '1001',
54            'hoge' => '999', // DBに存在しないカラム
55            'product_id' => '9001',
56            'product_class_id' => '9001',
57            'product_name' => '製品名9001'
58            )
59            );
60            SC_Helper_Purchase::registerOrderDetail('1001', $params);
61
62            $this->expected['count'] = '2'; // 同じorder_idのものが消されるので1行減る
63            $this->expected['content'] = array(
64            'order_id' => '1001',
65            'product_id' => '9001',
66            'product_class_id' => '9001',
67            'product_name' => '製品名9001',
68            'product_code' => null // 古いデータにはあるが、deleteされたので消えている
69            );
70
71            $this->actual['count'] = $this->objQuery->count('dtb_order_detail');
72            $result = $this->objQuery->select(
73            'order_id, product_id, product_class_id, product_name, product_code',
74            'dtb_order_detail',
75            'order_id = ?',
76            array('1001')
77            );
78            $this->actual['content'] = $result[0];
79
80            $this->verify();
81      }
82  }
83
84    public function testRegisterOrderDetail_該当の受注が存在しない場合_新しい情報が追加登録される()
85    {
86        if(DB_TYPE != 'pgsql') { //postgresqlだとどうしてもDBエラーになるのでとりいそぎ回避
87            $params = array(
88            array(
89            'order_id' => '1003',
90            'hoge' => '999', // DBに存在しないカラム
91            'product_id' => '9003',
92            'product_class_id' => '9003',
93            'product_name' => '製品名9003'
94            )
95            );
96            SC_Helper_Purchase::registerOrderDetail('1003', $params);
97
98            $this->expected['count'] = '4';
99            $this->expected['content'] = array(
100                'order_id' => '1003',
101                'product_id' => '9003',
102                'product_class_id' => '9003',
103                'product_name' => '製品名9003',
104                'product_code' => null
105            );
106
107            $this->actual['count'] = $this->objQuery->count('dtb_order_detail');
108            $result = $this->objQuery->select(
109                'order_id, product_id, product_class_id, product_name, product_code',
110                'dtb_order_detail',
111                'order_id = ?',
112                array('1003')
113            );
114            $this->actual['content'] = $result[0];
115
116            $this->verify();
117        }
118    }
119  //////////////////////////////////////////
120
121}
Note: See TracBrowser for help on using the repository browser.