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-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::copyFromCustomer()のテストクラス. |
---|
29 | * |
---|
30 | * |
---|
31 | * @author Hiroko Tamagawa |
---|
32 | * @version $Id$ |
---|
33 | */ |
---|
34 | class SC_Helper_Purchase_copyFromCustomerTest extends SC_Helper_Purchase_TestBase { |
---|
35 | |
---|
36 | var $customer; |
---|
37 | var $customer_array; |
---|
38 | |
---|
39 | protected function setUp() { |
---|
40 | parent::setUp(); |
---|
41 | $this->customer = new SC_Customer(); |
---|
42 | $this->customer->setValue('customer_id', '1001'); |
---|
43 | $this->customer->setValue('name01', '姓01'); |
---|
44 | $this->customer->setValue('name02', '名01'); |
---|
45 | $this->customer->setValue('kana01', 'セイ01'); |
---|
46 | $this->customer->setValue('kana02', 'メイ01'); |
---|
47 | $this->customer->setValue('sex', '1'); |
---|
48 | $this->customer->setValue('zip01', '123'); |
---|
49 | $this->customer->setValue('zip02', '4567'); |
---|
50 | $this->customer->setValue('pref', '東京都'); |
---|
51 | $this->customer->setValue('addr01', 'abc市'); |
---|
52 | $this->customer->setValue('addr02', 'def町'); |
---|
53 | $this->customer->setValue('tel01', '01'); |
---|
54 | $this->customer->setValue('tel02', '234'); |
---|
55 | $this->customer->setValue('tel03', '5678'); |
---|
56 | $this->customer->setValue('fax01', '02'); |
---|
57 | $this->customer->setValue('fax02', '345'); |
---|
58 | $this->customer->setValue('fax03', '6789'); |
---|
59 | $this->customer->setValue('job', '会社員'); |
---|
60 | $this->customer->setValue('birth', '2012-01-01'); |
---|
61 | $this->customer->setValue('email', 'test@example.com'); |
---|
62 | |
---|
63 | $this->customer_array = array('customer_id' => '1001', 'email' => 'test@example.com'); |
---|
64 | } |
---|
65 | |
---|
66 | protected function tearDown() { |
---|
67 | parent::tearDown(); |
---|
68 | } |
---|
69 | |
---|
70 | ///////////////////////////////////////// |
---|
71 | public function testCopyFromCustomer_ログインしていない場合_何もしない() { |
---|
72 | $dest = array(); |
---|
73 | User_Utils::setLoginState(FALSE, $this->customer_array, $this->objQuery); |
---|
74 | |
---|
75 | $this->expected = array(); |
---|
76 | $helper = new SC_Helper_Purchase(); |
---|
77 | $helper->copyFromCustomer($dest, $this->customer); |
---|
78 | $this->actual = $dest; |
---|
79 | |
---|
80 | $this->verify(); |
---|
81 | } |
---|
82 | |
---|
83 | public function testCopyFromCustomer_モバイルの場合_モバイルのメールアドレスを設定する() { |
---|
84 | $dest = array(); |
---|
85 | User_Utils::setLoginState(TRUE, $this->customer_array, $this->objQuery); |
---|
86 | User_Utils::setDeviceType(DEVICE_TYPE_MOBILE); |
---|
87 | $this->customer->setValue('email_mobile', 'mobile@example.com'); |
---|
88 | |
---|
89 | $this->expected = array( |
---|
90 | 'order_name01' => '姓01', |
---|
91 | 'order_name02' => '名01', |
---|
92 | 'order_kana01' => 'セイ01', |
---|
93 | 'order_kana02' => 'メイ01', |
---|
94 | 'order_sex' => '1', |
---|
95 | 'order_zip01' => '123', |
---|
96 | 'order_zip02' => '4567', |
---|
97 | 'order_pref' => '東京都', |
---|
98 | 'order_addr01' => 'abc市', |
---|
99 | 'order_addr02' => 'def町', |
---|
100 | 'order_tel01' => '01', |
---|
101 | 'order_tel02' => '234', |
---|
102 | 'order_tel03' => '5678', |
---|
103 | 'order_fax01' => '02', |
---|
104 | 'order_fax02' => '345', |
---|
105 | 'order_fax03' => '6789', |
---|
106 | 'order_job' => '会社員', |
---|
107 | 'order_birth' => '2012-01-01', |
---|
108 | 'order_email' => 'mobile@example.com', |
---|
109 | 'customer_id' => '1001', |
---|
110 | 'update_date' => 'CURRENT_TIMESTAMP' |
---|
111 | ); |
---|
112 | $helper = new SC_Helper_Purchase(); |
---|
113 | $helper->copyFromCustomer($dest, $this->customer); |
---|
114 | $this->actual = $dest; |
---|
115 | |
---|
116 | $this->verify(); |
---|
117 | } |
---|
118 | |
---|
119 | public function testCopyFromCustomer_モバイルかつモバイルのメールアドレスがない場合_通常のメールアドレスを設定する() { |
---|
120 | $dest = array(); |
---|
121 | $prefix = 'order'; |
---|
122 | // キーを絞る |
---|
123 | $keys = array('name01', 'email'); |
---|
124 | User_Utils::setLoginState(TRUE, $this->customer_array, $this->objQuery); |
---|
125 | User_Utils::setDeviceType(DEVICE_TYPE_MOBILE); |
---|
126 | |
---|
127 | $this->expected = array( |
---|
128 | 'order_name01' => '姓01', |
---|
129 | 'order_email' => 'test@example.com', |
---|
130 | 'customer_id' => '1001', |
---|
131 | 'update_date' => 'CURRENT_TIMESTAMP' |
---|
132 | ); |
---|
133 | $helper = new SC_Helper_Purchase(); |
---|
134 | $helper->copyFromCustomer($dest, $this->customer, $prefix, $keys); |
---|
135 | $this->actual = $dest; |
---|
136 | |
---|
137 | $this->verify(); |
---|
138 | } |
---|
139 | |
---|
140 | public function testCopyFromCustomer_モバイルでない場合_通常のメールアドレスをそのまま設定する() { |
---|
141 | $dest = array(); |
---|
142 | $prefix = 'prefix'; |
---|
143 | // キーを絞る |
---|
144 | $keys = array('name01', 'email'); |
---|
145 | User_Utils::setLoginState(TRUE, $this->customer_array, $this->objQuery); |
---|
146 | User_Utils::setDeviceType(DEVICE_TYPE_PC); |
---|
147 | $this->customer->setValue('email_mobile', 'mobile@example.com'); |
---|
148 | |
---|
149 | $this->expected = array( |
---|
150 | 'prefix_name01' => '姓01', |
---|
151 | 'prefix_email' => 'test@example.com', |
---|
152 | 'customer_id' => '1001', |
---|
153 | 'update_date' => 'CURRENT_TIMESTAMP' |
---|
154 | ); |
---|
155 | $helper = new SC_Helper_Purchase(); |
---|
156 | $helper->copyFromCustomer($dest, $this->customer, $prefix, $keys); |
---|
157 | $this->actual = $dest; |
---|
158 | |
---|
159 | $this->verify(); |
---|
160 | } |
---|
161 | |
---|
162 | ////////////////////////////////////////// |
---|
163 | |
---|
164 | } |
---|
165 | |
---|