CoordinatesTest   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 113
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 4
dl 0
loc 113
rs 10
c 0
b 0
f 0

3 Methods

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