Completed
Push — mawiki ( ed8c52 )
by Jeroen De
08:10
created

DecoratedGeocoderTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 37
rs 10
wmc 2
lcom 0
cbo 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testWhenInnerGeocoderHasResult_itGetsReturnedInArrayForm() 0 15 1
A testWhenInnerGeocoderHasNoResult_falseIsReturned() 0 9 1
1
<?php
2
3
namespace Maps\Test;
4
5
use DataValues\Geo\Values\LatLongValue;
6
use FileFetcher\InMemoryFileFetcher;
7
use Maps\Geocoders\InMemoryGeocoder;
8
use Maps\Geocoders\NominatimGeocoder;
9
10
/**
11
 * @covers MapsDecoratedGeocoder
12
 *
13
 * @group Maps
14
 *
15
 * @licence GNU GPL v2+
16
 * @author Jeroen De Dauw < [email protected] >
17
 */
18
class DecoratedGeocoderTest extends \PHPUnit_Framework_TestCase {
19
20
	public function testWhenInnerGeocoderHasResult_itGetsReturnedInArrayForm() {
21
		$geocoder = new InMemoryGeocoder( [
22
			'New York' => new LatLongValue( 40.7642499, -73.9545249 )
23
		] );
24
25
		$decoratedGeocoder = new \MapsDecoratedGeocoder( $geocoder, 'maw' );
26
27
		$this->assertSame(
28
			[
29
				'lat' => 40.7642499,
30
				'lon' => -73.9545249,
31
			],
32
			$decoratedGeocoder->geocode( 'New York' )
33
		);
34
	}
35
36
	public function testWhenInnerGeocoderHasNoResult_falseIsReturned() {
37
		$geocoder = new InMemoryGeocoder( [
38
			'New York' => new LatLongValue( 40.7642499, -73.9545249 )
39
		] );
40
41
		$decoratedGeocoder = new \MapsDecoratedGeocoder( $geocoder, 'maw' );
42
43
		$this->assertFalse( $decoratedGeocoder->geocode( 'durkadurkastan' ) );
44
	}
45
46
//	public function testWhenInnerGeocoderHasNoResult_falseIsReturned() {
47
//		$decoratedGeocoder = new \MapsDecoratedGeocoder( new InMemoryGeocoder( [] ), 'maw' );
48
//
49
//		$this->assertSame( [ 'maw' ], $decoratedGeocoder->getAliases() );
50
//	}
51
52
	// TODO: test exception case if we decided to not use null in the interface
53
54
}
55