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

Revision 22856, 4.3 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::saveOrderTemp()のテストクラス.
29 *
30 *
31 * @author Hiroko Tamagawa
32 * @version $Id$
33 */
34class SC_Helper_Purchase_saveOrderTempTest extends SC_Helper_Purchase_TestBase
35{
36  private $helper;
37
38  protected function setUp()
39  {
40    parent::setUp();
41    $this->setUpOrderTemp();
42    $this->helper = new SC_Helper_Purchase_saveOrderTempMock();
43  }
44
45  protected function tearDown()
46  {
47    parent::tearDown();
48  }
49
50  /////////////////////////////////////////
51  public function testSaveOrderTemp_受注一時情報IDが空の場合_何もしない()
52  {
53    $this->helper->saveOrderTemp(null,
54      array(
55        'customer_id' => '1003',
56        'order_name01' => '受注情報03',
57        'update_date' => 'CURRENT_TIMESTAMP'
58      )
59    );
60
61    $this->expected = 2;
62    $this->actual = $this->objQuery->count('dtb_order_temp');   
63
64    $this->verify('件数が変わっていない');
65  }
66
67  public function testSaveOrderTemp_既存の情報がない場合_情報が新規登録される()
68  {
69    $this->helper->saveOrderTemp('1003',
70      array(
71        'customer_id' => '1003',
72        'order_name01' => '受注情報03',
73        'update_date' => 'CURRENT_TIMESTAMP'
74      )
75    );
76
77    $this->expected['count'] = '3';
78    $this->expected['content'] = array(
79        array(
80          'order_temp_id' => '1003',
81          'customer_id' => '1003',
82          'order_name01' => '受注情報03'
83        )
84      );
85    $this->actual['count'] = $this->objQuery->count('dtb_order_temp');   
86    $this->actual['content'] = $this->objQuery->select(
87      'order_temp_id, customer_id, order_name01',
88      'dtb_order_temp', 'order_temp_id = ?', array('1003'));
89
90    $this->verify('件数が一件増える');
91  }
92
93  public function testSaveOrderTemp_既存の情報がある場合_情報が更新される()
94  {
95    $this->helper->saveOrderTemp('1002',
96      array(
97        'customer_id' => '2002',
98        'order_name01' => '受注情報92',
99        'update_date' => 'CURRENT_TIMESTAMP'
100      )
101    );
102
103    $this->expected['count'] = '2';
104    $this->expected['content'] = array(
105        array(
106          'order_temp_id' => '1002',
107          'customer_id' => '2002',
108          'order_name01' => '受注情報92'
109        )
110      );
111    $this->actual['count'] = $this->objQuery->count('dtb_order_temp');   
112    $this->actual['content'] = $this->objQuery->select(
113      'order_temp_id, customer_id, order_name01',
114      'dtb_order_temp', 'order_temp_id = ?', array('1002'));
115
116    $this->verify('件数が変わらず更新される');
117  }
118
119  public function testSaveOrderTemp_注文者情報がある場合_情報がコピーされる()
120  {
121    $this->helper->saveOrderTemp('1003',
122      array(
123        'order_temp_id' => '1003',
124        'customer_id' => '1003',
125        'order_name01' => '受注情報03',
126        'update_date' => 'CURRENT_TIMESTAMP'
127      ),
128      new SC_Customer_Ex()
129    );
130
131    // function呼び出しを確認
132    $this->expectOutputString('COPY_FROM_CUSTOMER');
133
134    $this->expected = 3;
135    $this->actual = $this->objQuery->count('dtb_order_temp');   
136
137    $this->verify('件数が一件増える'); // 詳細な中身については他のテストで確認
138  }
139
140  //////////////////////////////////////////
141
142}
143
144class SC_Helper_Purchase_saveOrderTempMock extends SC_Helper_Purchase
145{
146  function copyFromCustomer($sqlval, $objCustomer)
147  {
148    echo('COPY_FROM_CUSTOMER');
149  }
150}
151
Note: See TracBrowser for help on using the repository browser.