Completed
Push — MediaWikiFileUrlFinderTest ( 394f02...a6ffe6 )
by Jeroen De
11:13 queued 04:54
created

CoordinatesTest::getInstance()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Maps\Tests\Integration\MediaWiki\ParserHooks;
4
5
use DataValues\Geo\Values\LatLongValue;
6
use Maps\MediaWiki\ParserHooks\CoordinatesFunction;
7
use ParamProcessor\ParamDefinition;
8
9
/**
10
 * @covers CoordinatesFunction
11
 *
12
 * @licence GNU GPL v2+
13
 * @author Jeroen De Dauw < [email protected] >
14
 */
15
class CoordinatesTest extends ParserHookTest {
16
17
	/**
18
	 * @see ParserHookTest::parametersProvider
19
	 */
20
	public function parametersProvider() {
21
		$paramLists = [];
22
23
		$paramLists[] = [
24
			[
25
				'location' => '4,2',
26
				'format' => 'dms',
27
				'directional' => 'no',
28
			],
29
			'4° 0\' 0.00", 2° 0\' 0.00"'
30
		];
31
32
		$paramLists[] = [
33
			[
34
				'location' => '55 S, 37.6176330 W',
35
				'format' => 'dms',
36
				'directional' => 'no',
37
			],
38
			'-55° 0\' 0.00", -37° 37\' 3.48"'
39
		];
40
41
		$paramLists[] = [
42
			[
43
				'location' => '4,2',
44
				'format' => 'float',
45
				'directional' => 'no',
46
			],
47
			'4, 2'
48
		];
49
50
		$paramLists[] = [
51
			[
52
				'location' => '-4,-2',
53
				'format' => 'float',
54
				'directional' => 'yes',
55
			],
56
			'4 S, 2 W'
57
		];
58
59
		$paramLists[] = [
60
			[
61
				'location' => '55 S, 37.6176330 W',
62
				'directional' => 'yes',
63
			],
64
			'55° 0\' 0.00" S, 37° 37\' 3.48" W'
65
		];
66
67
		return $paramLists;
68
	}
69
70
	/**
71
	 * @see ParserHookTest::processingProvider
72
	 */
73
	public function processingProvider() {
74
		$definitions = ParamDefinition::getCleanDefinitions( $this->getInstance()->getParamDefinitions() );
75
		$argLists = [];
76
77
		$values = [
78
			'location' => '4,2',
79
		];
80
81
		$expected = [
82
			'location' => new LatLongValue( 4, 2 ),
83
		];
84
85
		$argLists[] = [ $values, $expected ];
86
87
		$values = [
88
			'location' => '4,2',
89
			'directional' => $definitions['directional']->getDefault() ? 'no' : 'yes',
90
			'format' => 'dd',
91
		];
92
93
		$expected = [
94
			'location' => new LatLongValue( 4, 2 ),
95
			'directional' => !$definitions['directional']->getDefault(),
96
			'format' => 'dd',
97
		];
98
99
		$argLists[] = [ $values, $expected ];
100
101
		$values = [
102
			'location' => '4,2',
103
			'directional' => $definitions['directional']->getDefault() ? 'NO' : 'YES',
104
			'format' => ' DD ',
105
		];
106
107
		$expected = [
108
			'location' => new LatLongValue( 4, 2 ),
109
			'directional' => !$definitions['directional']->getDefault(),
110
			'format' => 'dd',
111
		];
112
113
		$argLists[] = [ $values, $expected ];
114
115
		return $argLists;
116
	}
117
118
	/**
119
	 * @see ParserHookTest::getInstance
120
	 */
121
	protected function getInstance() {
122
		return new \Maps\MediaWiki\ParserHooks\CoordinatesFunction();
123
	}
124
125
}