source: branches/version-2_12-dev/tests/class/util/SC_Utils/SC_Utils_sfGetAddressTest.php @ 22567

Revision 22567, 5.1 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/Common_TestCase.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_Utils::sfGetAddress()のテストクラス.
29 *
30 *
31 * @author Hiroko Tamagawa
32 * @version $Id$
33 */
34class SC_Utils_sfGetAddressTest extends Common_TestCase
35{
36
37
38  protected function setUp()
39  {
40    parent::setUp();
41    $this->setUpAddress();
42  }
43
44  protected function tearDown()
45  {
46    parent::tearDown();
47  }
48
49  /////////////////////////////////////////
50  public function test_住所がヒットしない場合_空の配列が返る()
51  {
52    $this->expected = array();
53    $this->actual = SC_Utils::sfGetAddress('9999999');
54
55    $this->verify('郵便番号検索結果');
56  }
57
58  public function test_住所が一件だけヒットする場合_住所データが取得できる()
59  {
60    $this->expected = array(
61      array(
62        'state' => '1',    // 北海道
63        'city' => '札幌市中央区',
64        'town' => '大通東'
65      )
66    );
67    $this->actual = SC_Utils::sfGetAddress('0600041');
68
69    $this->verify('郵便番号検索結果');
70  }
71
72  // TODO 二件目に関しては件名のIDへの変換と町名の削除が行われない。
73  // 今の仕様ではこれでOKかもしれないが、そもそも一件目しか使わないのなら
74  // $data_list[0]を返した方が良いのでは?
75  /**
76  public function test_住所が二件以上ヒットする場合_町名を消した住所データが取得できる()
77  {
78    $this->expected = array(
79      array(
80        'state' => '5',    // 秋田県
81        'city' => '秋田市',
82        'town' => ''
83      ),
84      array(
85        'state' => '5',
86        'city' => '秋田市',
87        'town' => ''
88      )
89    );
90    $this->actual = SC_Utils::sfGetAddress('0110951');
91
92    $this->verify('郵便番号検索結果');
93  }
94  */
95
96  public function test_住所に但し書きが含まれる場合_但し書きが消去される()
97  {
98    $this->expected = array(
99      array(
100        'state' => '1',    // 北海道
101        'city' => '札幌市中央区',
102        'town' => '大通西'
103      )
104    );
105    $this->actual = SC_Utils::sfGetAddress('0600042');
106
107    $this->verify('郵便番号検索結果');
108  }
109
110  public function test_住所に注意文言がある場合_町名が消去される()
111  {
112    $this->expected = array(
113      array(
114        'state' => '1',    // 北海道
115        'city' => '札幌市中央区',
116        'town' => ''
117      )
118    );
119    $this->actual = SC_Utils::sfGetAddress('0600000');
120
121    $this->verify('郵便番号検索結果');
122  }
123
124  public function test_住所に番地の説明が含まれる場合_町名が消去される()
125  {
126    $this->expected = array(
127      array(
128        'state' => '8',    // 茨城県
129        'city' => '猿島郡堺町',
130        'town' => ''
131      )
132    );
133    $this->actual = SC_Utils::sfGetAddress('3060433');
134
135    $this->verify('郵便番号検索結果');
136  }
137
138  //////////////////////////////////////////
139
140  protected function setUpAddress()
141  {
142
143    $address = array(
144      array(
145        'zip_id' => '2',
146        'zipcode' => '0600041',
147        'state' => '北海道',
148        'city' => '札幌市中央区',
149        'town' => '大通東'
150      ),
151      array(
152        'zip_id' => '3',
153        'zipcode' => '0600042',
154        'state' => '北海道',
155        'city' => '札幌市中央区',
156        'town' => '大通西(1〜19丁目)'
157      ),
158      array(
159        'zip_id' => '0',
160        'zipcode' => '0600000',
161        'state' => '北海道',
162        'city' => '札幌市中央区',
163        'town' => '以下に掲載がない場合'
164      ),
165      array(
166        'zip_id' => '26867',
167        'zipcode' => '3060433',
168        'state' => '茨城県',
169        'city' => '猿島郡堺町',
170        'town' => '堺町の次に番地がくる場合'
171      ),
172      array(
173        'zip_id' => '16223',
174        'zipcode' => '0110951',
175        'state' => '秋田県',
176        'city' => '秋田市',
177        'town' => '土崎港相染町'
178      ),
179      array(
180        'zip_id' => '16226',
181        'zipcode' => '0110951',
182        'state' => '秋田県',
183        'city' => '秋田市',
184        'town' => '土崎港古川町'
185      )
186    );
187
188    $this->objQuery->delete('mtb_zip');
189    foreach ($address as $item) {
190      $this->objQuery->insert('mtb_zip', $item);
191    }
192  }
193}
194
Note: See TracBrowser for help on using the repository browser.