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

Revision 22796, 5.1 KB checked in by h_yoshimoto, 11 years ago (diff)

#2236 2.12.3リリース以降の2.12-devへのコミット差し戻し

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