source: branches/camp/camp-2_13-tests/tests/class/helper/SC_Helper_DB/SC_Helper_DB_sfGetBasisDataCacheTest.php @ 22726

Revision 22726, 10.9 KB checked in by poego, 11 years ago (diff)

#2185 SC_Helper_DBの一部テストケースをコミット

RevLine 
[22726]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::sfGetBasisDataCache()のテストクラス.
29 *
30 * @author Hiroko Tamagawa
31 * @version $Id: SC_Helper_DB_sfGetBasisDataCache.php 22567 2013-02-18 10:09:54Z shutta $
32 */
33class SC_Helper_DB_sfGetBasisDataCache extends SC_Helper_DB_TestBase
34{
35
36    protected function setUp()
37    {
38        parent::setUp();
39        $this->helper = new SC_Helper_DB_sfGetBasisDataCacheMock();
40        $this->cashFilePath = MASTER_DATA_REALDIR . 'dtb_baseinfo.serial';
41    }
42
43    protected function tearDown()
44    {
45        parent::tearDown();
46    }
47
48    /////////////////////////////////////////
49    public function testSfGetBasisDataCache_キャッシュがなく生成もしない場合_空を返す()
50    {
51        $this->setUpBasisData();
52        unlink($this->cashFilePath);
53        $this->expected = array();
54        $this->actual = $this->helper->sfGetBasisDataCache();
55        $this->verify();
56    }
57   
58    public function testSfGetBasisDataCache_キャッシュがなく生成する場合_キャッシュの値を返す()
59    {
60        $this->setUpBasisData();
61        unlink($this->cashFilePath);
62        $this->expected = array(
63            'id' => '1',
64            'company_name' => 'testshop',
65            'company_kana' => 'テストショップ',
66            'zip01' => '530',
67            'zip02' => '0001',
68            'pref' => '1',
69            'addr01' => 'testaddr01',
70            'addr02' => 'testaddr02',
71            'tel01' => '11',
72            'tel02' => '2222',
73            'tel03' => '3333',
74            'fax01' => '11',
75            'fax02' => '2222',
76            'fax03' => '3333',
77            'business_hour' => '09-18',
78            'law_company' => 'lawcampanyname',
79            'law_manager' => 'lawmanager',
80            'law_zip01' => '530',
81            'law_zip02' => '0001',
82            'law_pref' => '1',
83            'law_addr01' => 'lawaddr01',
84            'law_addr02' => 'lawaddr02',
85            'law_tel01' => '11',
86            'law_tel02' => '2222',
87            'law_tel03' => '3333',
88            'law_fax01' => '11',
89            'law_fax02' => '2222',
90            'law_fax03' => '3333',
91            'law_email' => 'test@test.com',
92            'law_url' => 'http://test.test',
93            'law_term01' => 'lawterm01',
94            'law_term02' => 'lawterm02',
95            'law_term03' => 'lawterm03',
96            'law_term04' => 'lawterm04',
97            'law_term05' => 'lawterm05',
98            'law_term06' => 'lawterm06',
99            'law_term07' => 'lawterm07',
100            'law_term08' => 'lawterm08',
101            'law_term09' => 'lawterm09',
102            'law_term10' => 'lawterm10',
103            'tax' => '5',
104            'tax_rule' => '1',
105            'email01' => 'test1@test.com',
106            'email02' => 'test2@test.com',
107            'email03' => 'test3@test.com',
108            'email04' => 'test4@test.com',
109            'email05' => 'test5@test.com',
110            'free_rule' => '1000',
111            'shop_name' => 'shopname',
112            'shop_kana' => 'ショップネーム',
113            'shop_name_eng' => 'shopnameeng',
114            'point_rate' => '10',
115            'welcome_point' => '100',
116            'update_date' => '2012-02-14 11:22:33',
117            'top_tpl' => 'top.tpl',
118            'product_tpl' => 'product.tpl',
119            'detail_tpl' => 'detail.tpl',
120            'mypage_tpl' => 'mypage.tpl',
121            'good_traded' => 'goodtraded',
122            'message' => 'message',
123            'regular_holiday_ids' => '0|6',
124            'latitude' => '30.0001',
125            'longitude' => '45.0001',
126            'downloadable_days' => '10',
127            'downloadable_days_unlimited' => '0'
128        );
129        $this->actual = $this->helper->sfGetBasisDataCache(true);
130        $this->verify();
131    }
132   
133    public function testSfGetBasisDataCache_キャッシュがある場合_キャッシュの値を返す()
134    {
135        $this->setUpBasisData();
136        unlink($this->cashFilePath);
137        $this->helper->sfCreateBasisDataCache();
138        $this->expected = array(
139            'id' => '1',
140            'company_name' => 'testshop',
141            'company_kana' => 'テストショップ',
142            'zip01' => '530',
143            'zip02' => '0001',
144            'pref' => '1',
145            'addr01' => 'testaddr01',
146            'addr02' => 'testaddr02',
147            'tel01' => '11',
148            'tel02' => '2222',
149            'tel03' => '3333',
150            'fax01' => '11',
151            'fax02' => '2222',
152            'fax03' => '3333',
153            'business_hour' => '09-18',
154            'law_company' => 'lawcampanyname',
155            'law_manager' => 'lawmanager',
156            'law_zip01' => '530',
157            'law_zip02' => '0001',
158            'law_pref' => '1',
159            'law_addr01' => 'lawaddr01',
160            'law_addr02' => 'lawaddr02',
161            'law_tel01' => '11',
162            'law_tel02' => '2222',
163            'law_tel03' => '3333',
164            'law_fax01' => '11',
165            'law_fax02' => '2222',
166            'law_fax03' => '3333',
167            'law_email' => 'test@test.com',
168            'law_url' => 'http://test.test',
169            'law_term01' => 'lawterm01',
170            'law_term02' => 'lawterm02',
171            'law_term03' => 'lawterm03',
172            'law_term04' => 'lawterm04',
173            'law_term05' => 'lawterm05',
174            'law_term06' => 'lawterm06',
175            'law_term07' => 'lawterm07',
176            'law_term08' => 'lawterm08',
177            'law_term09' => 'lawterm09',
178            'law_term10' => 'lawterm10',
179            'tax' => '5',
180            'tax_rule' => '1',
181            'email01' => 'test1@test.com',
182            'email02' => 'test2@test.com',
183            'email03' => 'test3@test.com',
184            'email04' => 'test4@test.com',
185            'email05' => 'test5@test.com',
186            'free_rule' => '1000',
187            'shop_name' => 'shopname',
188            'shop_kana' => 'ショップネーム',
189            'shop_name_eng' => 'shopnameeng',
190            'point_rate' => '10',
191            'welcome_point' => '100',
192            'update_date' => '2012-02-14 11:22:33',
193            'top_tpl' => 'top.tpl',
194            'product_tpl' => 'product.tpl',
195            'detail_tpl' => 'detail.tpl',
196            'mypage_tpl' => 'mypage.tpl',
197            'good_traded' => 'goodtraded',
198            'message' => 'message',
199            'regular_holiday_ids' => '0|6',
200            'latitude' => '30.0001',
201            'longitude' => '45.0001',
202            'downloadable_days' => '10',
203            'downloadable_days_unlimited' => '0'
204        );
205        $this->actual = $this->helper->sfGetBasisDataCache();
206        unlink($this->cashFilePath);
207        $this->verify();
208    }
209   
210}
211
212class SC_Helper_DB_sfGetBasisDataCacheMock extends SC_Helper_DB_Ex
213{
214    function sfCreateBasisDataCache()
215    {
216        // テーブル名
217        $name = 'dtb_baseinfo';
218        // キャッシュファイルパス
219        $filepath = MASTER_DATA_REALDIR . $name . '.serial';
220        // データ取得
221        $arrData = array(
222            'id' => '1',
223            'company_name' => 'testshop',
224            'company_kana' => 'テストショップ',
225            'zip01' => '530',
226            'zip02' => '0001',
227            'pref' => '1',
228            'addr01' => 'testaddr01',
229            'addr02' => 'testaddr02',
230            'tel01' => '11',
231            'tel02' => '2222',
232            'tel03' => '3333',
233            'fax01' => '11',
234            'fax02' => '2222',
235            'fax03' => '3333',
236            'business_hour' => '09-18',
237            'law_company' => 'lawcampanyname',
238            'law_manager' => 'lawmanager',
239            'law_zip01' => '530',
240            'law_zip02' => '0001',
241            'law_pref' => '1',
242            'law_addr01' => 'lawaddr01',
243            'law_addr02' => 'lawaddr02',
244            'law_tel01' => '11',
245            'law_tel02' => '2222',
246            'law_tel03' => '3333',
247            'law_fax01' => '11',
248            'law_fax02' => '2222',
249            'law_fax03' => '3333',
250            'law_email' => 'test@test.com',
251            'law_url' => 'http://test.test',
252            'law_term01' => 'lawterm01',
253            'law_term02' => 'lawterm02',
254            'law_term03' => 'lawterm03',
255            'law_term04' => 'lawterm04',
256            'law_term05' => 'lawterm05',
257            'law_term06' => 'lawterm06',
258            'law_term07' => 'lawterm07',
259            'law_term08' => 'lawterm08',
260            'law_term09' => 'lawterm09',
261            'law_term10' => 'lawterm10',
262            'tax' => '5',
263            'tax_rule' => '1',
264            'email01' => 'test1@test.com',
265            'email02' => 'test2@test.com',
266            'email03' => 'test3@test.com',
267            'email04' => 'test4@test.com',
268            'email05' => 'test5@test.com',
269            'free_rule' => '1000',
270            'shop_name' => 'shopname',
271            'shop_kana' => 'ショップネーム',
272            'shop_name_eng' => 'shopnameeng',
273            'point_rate' => '10',
274            'welcome_point' => '100',
275            'update_date' => '2012-02-14 11:22:33',
276            'top_tpl' => 'top.tpl',
277            'product_tpl' => 'product.tpl',
278            'detail_tpl' => 'detail.tpl',
279            'mypage_tpl' => 'mypage.tpl',
280            'good_traded' => 'goodtraded',
281            'message' => 'message',
282            'regular_holiday_ids' => '0|6',
283            'latitude' => '30.0001',
284            'longitude' => '45.0001',
285            'downloadable_days' => '10',
286            'downloadable_days_unlimited' => '0'
287        );
288        // シリアライズ
289        $data = serialize($arrData);
290        // ファイルを書き出しモードで開く
291        $handle = fopen($filepath, 'w');
292        if (!$handle) {
293            // ファイル生成失敗
294            return false;
295        }
296        // ファイルの内容を書き出す.
297        $res = fwrite($handle, $data);
298        // ファイルを閉じる
299        fclose($handle);
300        if ( $res === false) {
301            // ファイル生成失敗
302            return false;
303        }
304        // ファイル生成成功
305        return true;
306    }
307}
Note: See TracBrowser for help on using the repository browser.