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

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