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

Revision 22567, 5.6 KB checked in by shutta, 11 years ago (diff)

#2043 (typo修正・ソース整形・ソースコメントの改善 for 2.12.4)
Zend Framework PHP 標準コーディング規約のコーディングスタイルへ準拠。
classおよびfunctionの開始波括弧「{」のスタイルを修正。

  • 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    );
117    $helper = new SC_Helper_Purchase();
118    $helper->copyFromCustomer($dest, $this->customer);
119    $this->actual = $dest;
120
121    $this->verify();
122  }
123
124  public function testCopyFromCustomer_モバイルかつモバイルのメールアドレスがない場合_通常のメールアドレスを設定する()
125  {
126    $dest = array();
127    $prefix = 'order';
128    // キーを絞る
129    $keys = array('name01', 'email');
130    User_Utils::setLoginState(TRUE, $this->customer_array, $this->objQuery);
131    User_Utils::setDeviceType(DEVICE_TYPE_MOBILE);
132
133    $this->expected = array(
134      'order_name01' => '姓01',
135      'order_email' => 'test@example.com',
136      'customer_id' => '1001',
137      'update_date' => 'CURRENT_TIMESTAMP'
138    );
139    $helper = new SC_Helper_Purchase();
140    $helper->copyFromCustomer($dest, $this->customer, $prefix, $keys);
141    $this->actual = $dest;
142
143    $this->verify();
144  }
145
146  public function testCopyFromCustomer_モバイルでない場合_通常のメールアドレスをそのまま設定する()
147  {
148    $dest = array();
149    $prefix = 'prefix';
150    // キーを絞る
151    $keys = array('name01', 'email');
152    User_Utils::setLoginState(TRUE, $this->customer_array, $this->objQuery);
153    User_Utils::setDeviceType(DEVICE_TYPE_PC);
154    $this->customer->setValue('email_mobile', 'mobile@example.com');
155
156    $this->expected = array(
157      'prefix_name01' => '姓01',
158      'prefix_email' => 'test@example.com',
159      'customer_id' => '1001',
160      'update_date' => 'CURRENT_TIMESTAMP'
161    );
162    $helper = new SC_Helper_Purchase();
163    $helper->copyFromCustomer($dest, $this->customer, $prefix, $keys);
164    $this->actual = $dest;
165
166    $this->verify();
167  }
168
169  //////////////////////////////////////////
170
171}
172
Note: See TracBrowser for help on using the repository browser.