summaryrefslogtreecommitdiff
path: root/www/wiki/extensions/Maps/tests/Integration/MediaWiki/ParserHooks/GeocodeTest.php
blob: 0469650c3b9b31c653b3ac5505229674fc0bcef0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?php

namespace Maps\Tests\Integration\MediaWiki\ParserHooks;

use DataValues\Geo\Values\LatLongValue;
use Jeroen\SimpleGeocoder\Geocoders\InMemoryGeocoder;
use Maps\MediaWiki\ParserHooks\GeocodeFunction;

/**
 * @covers GeocodeFunction
 *
 * @licence GNU GPL v2+
 * @author Jeroen De Dauw < jeroendedauw@gmail.com >
 */
class GeocodeTest extends ParserHookTest {

	/**
	 * @see ParserHookTest::parametersProvider
	 */
	public function parametersProvider() {
		$paramLists = [];

		$paramLists[] = [ 'location' => 'New York', '4, 2' ];
		$paramLists[] = [ 'location' => 'Brussels', '2, 3' ];
		$paramLists[] = [ 'location' => 'I am a tomato', 'Geocoding failed' ];

		return $this->arrayWrap( $paramLists );
	}

	/**
	 * @see ParserHookTest::processingProvider
	 */
	public function processingProvider() {
		$argLists = [];

		$argLists[] = [
			[
				'location' => '4,2',
				'directional' => 'yes',
			],
			[
				'location' => '4,2',
				'directional' => true,
			]
		];

		return $argLists;
	}

	/**
	 * @see ParserHookTest::getInstance
	 */
	protected function getInstance() {
		return new \Maps\MediaWiki\ParserHooks\GeocodeFunction(
			new InMemoryGeocoder(
				[
					'New York' => new LatLongValue( 4, 2 ),
					'Brussels' => new LatLongValue( 2, 3 ),
				]
			)
		);
	}

}