Completed
Push — MediaWikiFileUrlFinderTest ( d58bee...394f02 )
by Jeroen De
08:48
created

GeodistanceTest::processingProvider()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 32

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 32
rs 9.408
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Maps\Tests\Integration\parserhooks;
4
5
use DataValues\Geo\Values\LatLongValue;
6
use Maps\Elements\Location;
7
use Maps\MediaWiki\ParserHooks\GeoDistanceFunction;
8
9
/**
10
 * @covers GeoDistanceFunction
11
 *
12
 * @licence GNU GPL v2+
13
 * @author Jeroen De Dauw < [email protected] >
14
 */
15
class GeodistanceTest extends ParserHookTest {
16
17
	/**
18
	 * @see ParserHookTest::parametersProvider
19
	 */
20
	public function parametersProvider() {
21
		$paramLists = [];
22
23
		$paramLists[] = [
24
			'location1' => '4,2',
25
			'location2' => '42,0',
26
		];
27
28
		$paramLists[] = [
29
			'4,2',
30
			'42,0',
31
		];
32
33
		return $this->arrayWrap( $paramLists );
34
	}
35
36
	/**
37
	 * @see ParserHookTest::processingProvider
38
	 * @since 3.0
39
	 * @return array
40
	 */
41
	public function processingProvider() {
42
		$argLists = [];
43
44
		$values = [
45
			'location1' => '4,2',
46
			'location2' => '42,0',
47
		];
48
49
		$expected = [
50
			'location1' => new Location( new LatLongValue( 4, 2 ) ),
51
			'location2' => new Location( new LatLongValue( 42, 0 ) ),
52
		];
53
54
		$argLists[] = [ $values, $expected ];
55
56
		$values = [
57
			'location1' => '4,2',
58
			'location2' => '42,0',
59
			'unit' => '~=[,,_,,]:3',
60
			'decimals' => '1',
61
		];
62
63
		$expected = [
64
			'location1' => new Location( new LatLongValue( 4, 2 ) ),
65
			'location2' => new Location( new LatLongValue( 42, 0 ) ),
66
			'decimals' => 1,
67
		];
68
69
		$argLists[] = [ $values, $expected ];
70
71
		return $argLists;
72
	}
73
74
	/**
75
	 * @see ParserHookTest::getInstance
76
	 */
77
	protected function getInstance() {
78
		return new \Maps\MediaWiki\ParserHooks\GeoDistanceFunction();
79
	}
80
81
}