Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion tests/Geocoder/Tests/GeocoderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public function testGeocodeReturnsInstanceOfResultInterface()
$this->assertInstanceOf('Geocoder\Result\Geocoded', $this->geocoder->geocode('foobar'));
}

public function testEmpty()
public function testGeocodeEmpty()
{
$this->geocoder->registerProvider(new MockProviderWithRequestCount('test2'));
$this->assertEmptyResult($this->geocoder->geocode(''));
Expand All @@ -114,6 +114,22 @@ public function testEmpty()
$this->assertEquals(0, $this->geocoder->getProvider('test2')->geocodeCount);
}

public function testReverseReturnsInstanceOfResultInterface()
{
$this->geocoder->registerProvider(new MockProvider('test1'));
$this->assertInstanceOf('Geocoder\Result\ResultInterface', $this->geocoder->reverse(1, 2));
$this->assertInstanceOf('Geocoder\Result\Geocoded', $this->geocoder->reverse(1, 2));
}

public function testReverseEmpty()
{
$this->geocoder->registerProvider(new MockProviderWithRequestCount('test2'));
$this->assertEmptyResult($this->geocoder->reverse('', ''));
$this->assertEquals(0, $this->geocoder->getProvider('test2')->geocodeCount);
$this->assertEmptyResult($this->geocoder->reverse(null, null));
$this->assertEquals(0, $this->geocoder->getProvider('test2')->geocodeCount);
}

public function testUseCustomResultFactory()
{
$factoryMock = $this->getMock('Geocoder\Result\ResultFactory');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ public function testGetGeocodedDataWithRealIPv4WithLocale()
$this->assertEquals(43.6156005859375, $result['bounds']['north'], '', 0.01);
$this->assertEquals(1.45262920856476, $result['bounds']['east'], '', 0.01);
$this->assertNull($result['streetNumber']);
$this->assertEquals('Avenue de Lyon', $result['streetName']);
$this->assertEquals('Rue du Faubourg Bonnefoy', $result['streetName']);
$this->assertEquals(31506, $result['zipcode']);
$this->assertEquals(4, $result['cityDistrict']);
$this->assertEquals('Toulouse', $result['city']);
Expand Down
34 changes: 34 additions & 0 deletions tests/Geocoder/Tests/Result/GeocodedTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,26 @@ public function testFromArray()
'east' => 0.1
),
'city' => 'FOo CITY',
'cityDistrict' => 'fOo city District',
'streetName' => 'foo bar street',
'zipcode' => '65943',
'region' => 'FOO region',
'county' => 'foo county',
'countyCode' => 'foo',
'regionCode' => 'FOO',
'country' => 'FOO Country',
'countryCode' => 'foo',
'timezone' => 'FOO/Timezone'
);

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

$coordinates = $this->geocoded->getCoordinates();
$bounds = $this->geocoded->getBounds();

$this->assertTrue(is_array($coordinates));
$this->assertEquals(0.001, $coordinates[0]);
$this->assertEquals(1, $coordinates[1]);
$this->assertEquals(0.001, $this->geocoded->getLatitude());
$this->assertEquals(1, $this->geocoded->getLongitude());
$this->assertArrayHasKey('south', $bounds);
Expand All @@ -51,9 +60,14 @@ public function testFromArray()
$this->assertEquals(3, $bounds['north']);
$this->assertEquals(0.1, $bounds['east']);
$this->assertEquals('Foo City', $this->geocoded->getCity());
$this->assertEquals('Foo City District', $this->geocoded->getCityDistrict());
$this->assertEquals('Foo Bar Street', $this->geocoded->getStreetName());
$this->assertEquals('65943', $this->geocoded->getZipcode());
$this->assertEquals('Foo Region', $this->geocoded->getRegion());
$this->assertEquals('Foo County', $this->geocoded->getCounty());
$this->assertEquals('FOO', $this->geocoded->getCountyCode());
$this->assertEquals('Foo Country', $this->geocoded->getCountry());
$this->assertEquals('FOO', $this->geocoded->getCountryCode());
$this->assertEquals('FOO/Timezone', $this->geocoded->getTimezone());
$this->assertEquals('FOO', $this->geocoded->getRegionCode());
}
Expand Down Expand Up @@ -235,4 +249,24 @@ public function testFromArrayWithLettersInStreetNumber()
$this->geocoded->fromArray($array);
$this->assertEquals('1A', $this->geocoded->getStreetNumber());
}

public function testLowerizeViaReflection()
{
$method = new \ReflectionMethod(
$this->geocoded, 'lowerize'
);
$method->setAccessible(true);

$this->assertEquals('foo', $method->invoke($this->geocoded, 'FOO'));
}

public function testUpperizeViaReflection()
{
$method = new \ReflectionMethod(
$this->geocoded, 'upperize'
);
$method->setAccessible(true);

$this->assertEquals('FOO', $method->invoke($this->geocoded, 'foo'));
}
}