FinddestinationTest::getInstance()   A
last analyzed

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
declare( strict_types = 1 );
4
5
namespace Maps\Tests\Integration\ParserHooks;
6
7
use DataValues\Geo\Parsers\LatLongParser;
8
use Maps\LegacyModel\Location;
9
use Maps\ParserHooks\FindDestinationFunction;
10
11
/**
12
 * @covers FindDestinationFunction
13
 *
14
 * @licence GNU GPL v2+
15
 * @author Jeroen De Dauw < [email protected] >
16
 */
17
class FinddestinationTest extends ParserHookTest {
18
19
	/**
20
	 * @var string[]
21
	 */
22
	private $locations = [
23
		'4,2',
24
		'4.2,-42',
25
	];
26
27
	private $bearings = [
28
		1,
29
		42,
30
		-42,
31
		0,
32
		4.2,
33
	];
34
35
	private $distances = [
36
		'42' => 42,
37
		'0' => 0,
38
		'42 m' => 42,
39
		'42 km' => 42000,
40
		'4.2 km' => 4200,
41
	];
42
43
	/**
44
	 * @see ParserHookTest::parametersProvider
45
	 */
46
	public function parametersProvider() {
47
		$paramLists = [];
48
49
		$paramLists[] = [
50
			'location' => '4,2',
51
			'bearing' => '1',
52
			'distance' => '42 km'
53
		];
54
55
		return $this->arrayWrap( $paramLists );
56
	}
57
58
	/**
59
	 * @see ParserHookTest::processingProvider
60
	 */
61
	public function processingProvider() {
62
		$argLists = [];
63
64
		$coordinateParser = new LatLongParser();
65
66
		foreach ( $this->distances as $distance => $expectedDistance ) {
67
			foreach ( $this->bearings as $bearing ) {
68
				foreach ( $this->locations as $locationString ) {
69
					$values = [
70
						'distance' => (string)$distance,
71
						'bearing' => (string)$bearing,
72
						'location' => (string)$locationString,
73
					];
74
75
					$expected = [
76
						'distance' => $expectedDistance,
77
						'bearing' => (float)$bearing,
78
						'location' => new Location( $coordinateParser->parse( $locationString )->getValue() ),
79
					];
80
81
					$argLists[] = [ $values, $expected ];
82
				}
83
			}
84
		}
85
86
		return $argLists;
87
	}
88
89
	/**
90
	 * @see ParserHookTest::getInstance
91
	 */
92
	protected function getInstance() {
93
		return new \Maps\ParserHooks\FindDestinationFunction();
94
	}
95
96
}
97