source: branches/version-2_13-dev/tests/class/helper/SC_Helper_DB/SC_Helper_DB_sfGetBasisDataTest.php @ 23032

Revision 23032, 7.9 KB checked in by nanasess, 11 years ago (diff)

#150 (ユニットテスト環境の整備)

  • 最近の改修で, テストが通らなかったのを修正
Line 
1<?php
2
3$HOME = realpath(dirname(__FILE__)) . "/../../../..";
4require_once($HOME . "/tests/class/helper/SC_Helper_DB/SC_Helper_DB_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_DB::sfGetBasisData()のテストクラス.
29 *
30 * @author Hiroko Tamagawa
31 * @version $Id: SC_Helper_DB_sfGetBasisData.php 22567 2013-02-18 10:09:54Z shutta $
32 */
33class SC_Helper_DB_sfGetBasisData extends SC_Helper_DB_TestBase
34{
35
36    protected function setUp()
37    {
38        parent::setUp();
39        $this->helper = new SC_Helper_DB_Ex();
40    }
41
42    protected function tearDown()
43    {
44        parent::tearDown();
45    }
46
47    /////////////////////////////////////////
48    public function testsfGetBasisData_条件を指定しない場合_baseinfoを全て返す()
49    {
50        $this->setUpBasisData();
51        $this->expected = array(
52            'id' => '1',
53            'company_name' => 'testshop',
54            'company_kana' => 'テストショップ',
55            'zip01' => '530',
56            'zip02' => '0001',
57            'country_id' => null,
58            'pref' => '1',
59            'addr01' => 'testaddr01',
60            'addr02' => 'testaddr02',
61            'tel01' => '11',
62            'tel02' => '2222',
63            'tel03' => '3333',
64            'fax01' => '11',
65            'fax02' => '2222',
66            'fax03' => '3333',
67            'business_hour' => '09-18',
68            'law_company' => 'lawcampanyname',
69            'law_manager' => 'lawmanager',
70            'law_zip01' => '530',
71            'law_zip02' => '0001',
72            'law_country_id' => null,
73            'law_pref' => '1',
74            'law_addr01' => 'lawaddr01',
75            'law_addr02' => 'lawaddr02',
76            'law_tel01' => '11',
77            'law_tel02' => '2222',
78            'law_tel03' => '3333',
79            'law_fax01' => '11',
80            'law_fax02' => '2222',
81            'law_fax03' => '3333',
82            'law_email' => 'test@test.com',
83            'law_url' => 'http://test.test',
84            'law_term01' => 'lawterm01',
85            'law_term02' => 'lawterm02',
86            'law_term03' => 'lawterm03',
87            'law_term04' => 'lawterm04',
88            'law_term05' => 'lawterm05',
89            'law_term06' => 'lawterm06',
90            'law_term07' => 'lawterm07',
91            'law_term08' => 'lawterm08',
92            'law_term09' => 'lawterm09',
93            'law_term10' => 'lawterm10',
94            'email01' => 'test1@test.com',
95            'email02' => 'test2@test.com',
96            'email03' => 'test3@test.com',
97            'email04' => 'test4@test.com',
98            'free_rule' => '1000',
99            'shop_name' => 'shopname',
100            'shop_kana' => 'ショップネーム',
101            'shop_name_eng' => 'shopnameeng',
102            'point_rate' => '10',
103            'welcome_point' => '100',
104            'update_date' => '2012-02-14 11:22:33',
105            'top_tpl' => 'top.tpl',
106            'product_tpl' => 'product.tpl',
107            'detail_tpl' => 'detail.tpl',
108            'mypage_tpl' => 'mypage.tpl',
109            'good_traded' => 'goodtraded',
110            'message' => 'message',
111            'regular_holiday_ids' => '0|6',
112            'latitude' => '30.0001',
113            'longitude' => '45.0001',
114            'downloadable_days' => '10',
115            'downloadable_days_unlimited' => '0',
116            'zipcode' => null,
117            'law_zipcode' => null
118        );
119        $this->actual = $this->helper->sfGetBasisData(true);
120        $this->verify();
121    }
122
123    /* r22841 の仕様変更により廃止
124    public function testsfGetBasisData_カラムを指定する場合_指定のカラムだけを返す()
125    {
126        $this->setUpBasisData();
127        $this->expected = array(
128            'id' => '1',
129            'company_name' => 'testshop'
130        );
131        $force = true;
132        $col = 'id, company_name';
133        $this->actual = $this->helper->sfGetBasisData($force, $col);
134        $this->verify();
135    }
136    */
137
138    public function testsfGetBasisData_baseinfoが空の場合_空を返す()
139    {
140        $this->objQuery->delete('dtb_baseinfo');
141        $this->expected = null;
142        $this->actual = $this->helper->sfGetBasisData(true);
143        $this->verify();
144    }
145   
146    public function testsfGetBasisData_forceがfalseの場合_キャッシュを返す()
147    {
148        $this->setUpBasisData();
149        $force = true;
150        //事前にキャッシュを生成
151        $this->actual = $this->helper->sfGetBasisData($force);
152        //baseinfoを空にしてしまう
153        $this->objQuery->delete('dtb_baseinfo');
154        $force = false;
155        $this->expected = array(
156            'id' => '1',
157            'company_name' => 'testshop',
158            'company_kana' => 'テストショップ',
159            'zip01' => '530',
160            'zip02' => '0001',
161            'pref' => '1',
162            'addr01' => 'testaddr01',
163            'addr02' => 'testaddr02',
164            'tel01' => '11',
165            'tel02' => '2222',
166            'tel03' => '3333',
167            'fax01' => '11',
168            'fax02' => '2222',
169            'fax03' => '3333',
170            'business_hour' => '09-18',
171            'law_company' => 'lawcampanyname',
172            'law_manager' => 'lawmanager',
173            'law_zip01' => '530',
174            'law_zip02' => '0001',
175            'law_pref' => '1',
176            'law_addr01' => 'lawaddr01',
177            'law_addr02' => 'lawaddr02',
178            'law_tel01' => '11',
179            'law_tel02' => '2222',
180            'law_tel03' => '3333',
181            'law_fax01' => '11',
182            'law_fax02' => '2222',
183            'law_fax03' => '3333',
184            'law_email' => 'test@test.com',
185            'law_url' => 'http://test.test',
186            'law_term01' => 'lawterm01',
187            'law_term02' => 'lawterm02',
188            'law_term03' => 'lawterm03',
189            'law_term04' => 'lawterm04',
190            'law_term05' => 'lawterm05',
191            'law_term06' => 'lawterm06',
192            'law_term07' => 'lawterm07',
193            'law_term08' => 'lawterm08',
194            'law_term09' => 'lawterm09',
195            'law_term10' => 'lawterm10',
196            'email01' => 'test1@test.com',
197            'email02' => 'test2@test.com',
198            'email03' => 'test3@test.com',
199            'email04' => 'test4@test.com',
200            'free_rule' => '1000',
201            'shop_name' => 'shopname',
202            'shop_kana' => 'ショップネーム',
203            'shop_name_eng' => 'shopnameeng',
204            'point_rate' => '10',
205            'welcome_point' => '100',
206            'update_date' => '2012-02-14 11:22:33',
207            'top_tpl' => 'top.tpl',
208            'product_tpl' => 'product.tpl',
209            'detail_tpl' => 'detail.tpl',
210            'mypage_tpl' => 'mypage.tpl',
211            'good_traded' => 'goodtraded',
212            'message' => 'message',
213            'regular_holiday_ids' => '0|6',
214            'latitude' => '30.0001',
215            'longitude' => '45.0001',
216            'downloadable_days' => '10',
217            'downloadable_days_unlimited' => '0',
218            'country_id' => null,
219            'law_country_id' => null,
220            'zipcode' => null,
221            'law_zipcode' => null
222        );
223        $this->actual = $this->helper->sfGetBasisData(false);
224        $this->verify();
225    }
226}
Note: See TracBrowser for help on using the repository browser.