Skip to content

Commit 9cb8f23

Browse files
committed
Fixed: tests and enhanced test cover
1 parent 7e3394e commit 9cb8f23

File tree

3 files changed

+52
-2
lines changed

3 files changed

+52
-2
lines changed

tests/Geocoder/Tests/GeocoderTest.php

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ public function testGeocodeReturnsInstanceOfResultInterface()
105105
$this->assertInstanceOf('Geocoder\Result\Geocoded', $this->geocoder->geocode('foobar'));
106106
}
107107

108-
public function testEmpty()
108+
public function testGeocodeEmpty()
109109
{
110110
$this->geocoder->registerProvider(new MockProviderWithRequestCount('test2'));
111111
$this->assertEmptyResult($this->geocoder->geocode(''));
@@ -114,6 +114,22 @@ public function testEmpty()
114114
$this->assertEquals(0, $this->geocoder->getProvider('test2')->geocodeCount);
115115
}
116116

117+
public function testReverseReturnsInstanceOfResultInterface()
118+
{
119+
$this->geocoder->registerProvider(new MockProvider('test1'));
120+
$this->assertInstanceOf('Geocoder\Result\ResultInterface', $this->geocoder->reverse(1, 2));
121+
$this->assertInstanceOf('Geocoder\Result\Geocoded', $this->geocoder->reverse(1, 2));
122+
}
123+
124+
public function testReverseEmpty()
125+
{
126+
$this->geocoder->registerProvider(new MockProviderWithRequestCount('test2'));
127+
$this->assertEmptyResult($this->geocoder->reverse('', ''));
128+
$this->assertEquals(0, $this->geocoder->getProvider('test2')->geocodeCount);
129+
$this->assertEmptyResult($this->geocoder->reverse(null, null));
130+
$this->assertEquals(0, $this->geocoder->getProvider('test2')->geocodeCount);
131+
}
132+
117133
public function testUseCustomResultFactory()
118134
{
119135
$factoryMock = $this->getMock('Geocoder\Result\ResultFactory');

tests/Geocoder/Tests/Provider/OpenStreetMapsProviderTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ public function testGetGeocodedDataWithRealIPv4WithLocale()
193193
$this->assertEquals(43.6156005859375, $result['bounds']['north'], '', 0.01);
194194
$this->assertEquals(1.45262920856476, $result['bounds']['east'], '', 0.01);
195195
$this->assertNull($result['streetNumber']);
196-
$this->assertEquals('Avenue de Lyon', $result['streetName']);
196+
$this->assertEquals('Rue du Faubourg Bonnefoy', $result['streetName']);
197197
$this->assertEquals(31506, $result['zipcode']);
198198
$this->assertEquals(4, $result['cityDistrict']);
199199
$this->assertEquals('Toulouse', $result['city']);

tests/Geocoder/Tests/Result/GeocodedTest.php

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,26 @@ public function testFromArray()
2929
'east' => 0.1
3030
),
3131
'city' => 'FOo CITY',
32+
'cityDistrict' => 'fOo city District',
33+
'streetName' => 'foo bar street',
3234
'zipcode' => '65943',
3335
'region' => 'FOO region',
36+
'county' => 'foo county',
37+
'countyCode' => 'foo',
3438
'regionCode' => 'FOO',
3539
'country' => 'FOO Country',
40+
'countryCode' => 'foo',
3641
'timezone' => 'FOO/Timezone'
3742
);
3843

3944
$this->geocoded->fromArray($array);
4045

46+
$coordinates = $this->geocoded->getCoordinates();
4147
$bounds = $this->geocoded->getBounds();
4248

49+
$this->assertTrue(is_array($coordinates));
50+
$this->assertEquals(0.001, $coordinates[0]);
51+
$this->assertEquals(1, $coordinates[1]);
4352
$this->assertEquals(0.001, $this->geocoded->getLatitude());
4453
$this->assertEquals(1, $this->geocoded->getLongitude());
4554
$this->assertArrayHasKey('south', $bounds);
@@ -51,9 +60,14 @@ public function testFromArray()
5160
$this->assertEquals(3, $bounds['north']);
5261
$this->assertEquals(0.1, $bounds['east']);
5362
$this->assertEquals('Foo City', $this->geocoded->getCity());
63+
$this->assertEquals('Foo City District', $this->geocoded->getCityDistrict());
64+
$this->assertEquals('Foo Bar Street', $this->geocoded->getStreetName());
5465
$this->assertEquals('65943', $this->geocoded->getZipcode());
5566
$this->assertEquals('Foo Region', $this->geocoded->getRegion());
67+
$this->assertEquals('Foo County', $this->geocoded->getCounty());
68+
$this->assertEquals('FOO', $this->geocoded->getCountyCode());
5669
$this->assertEquals('Foo Country', $this->geocoded->getCountry());
70+
$this->assertEquals('FOO', $this->geocoded->getCountryCode());
5771
$this->assertEquals('FOO/Timezone', $this->geocoded->getTimezone());
5872
$this->assertEquals('FOO', $this->geocoded->getRegionCode());
5973
}
@@ -235,4 +249,24 @@ public function testFromArrayWithLettersInStreetNumber()
235249
$this->geocoded->fromArray($array);
236250
$this->assertEquals('1A', $this->geocoded->getStreetNumber());
237251
}
252+
253+
public function testLowerizeViaReflection()
254+
{
255+
$method = new \ReflectionMethod(
256+
$this->geocoded, 'lowerize'
257+
);
258+
$method->setAccessible(true);
259+
260+
$this->assertEquals('foo', $method->invoke($this->geocoded, 'FOO'));
261+
}
262+
263+
public function testUpperizeViaReflection()
264+
{
265+
$method = new \ReflectionMethod(
266+
$this->geocoded, 'upperize'
267+
);
268+
$method->setAccessible(true);
269+
270+
$this->assertEquals('FOO', $method->invoke($this->geocoded, 'foo'));
271+
}
238272
}

0 commit comments

Comments
 (0)