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