These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace Tests\DataValues\Geo\Parsers; |
||
4 | |||
5 | use DataValues\Geo\Parsers\DmCoordinateParser; |
||
6 | use DataValues\Geo\Values\LatLongValue; |
||
7 | |||
8 | /** |
||
9 | * @covers DataValues\Geo\Parsers\DmCoordinateParser |
||
10 | * |
||
11 | * @group ValueParsers |
||
12 | * @group DataValueExtensions |
||
13 | * |
||
14 | * @license GPL-2.0+ |
||
15 | * @author Jeroen De Dauw < [email protected] > |
||
16 | */ |
||
17 | class DmCoordinateParserTest extends ParserTestBase { |
||
0 ignored issues
–
show
|
|||
18 | |||
19 | /** |
||
20 | * @see ValueParserTestBase::getInstance |
||
21 | * |
||
22 | * @return DmCoordinateParser |
||
23 | */ |
||
24 | protected function getInstance() { |
||
25 | return new DmCoordinateParser(); |
||
26 | } |
||
27 | |||
28 | /** |
||
29 | * @see ValueParserTestBase::validInputProvider |
||
30 | */ |
||
31 | public function validInputProvider() { |
||
32 | $argLists = []; |
||
33 | |||
34 | // TODO: test with different parser options |
||
35 | |||
36 | $valid = [ |
||
37 | // Whitespace |
||
38 | "1°0'N 1°0'E\n" => [ 1, 1 ], |
||
39 | " 1°0'N 1°0'E " => [ 1, 1 ], |
||
40 | |||
41 | "55° 0', 37° 0'" => [ 55, 37 ], |
||
42 | "55° 30', 37° 30'" => [ 55.5, 37.5 ], |
||
43 | "0° 0', 0° 0'" => [ 0, 0 ], |
||
44 | "-55° 30', -37° 30'" => [ -55.5, -37.5 ], |
||
45 | "0° 0.3' S, 0° 0.3' W" => [ -0.005, -0.005 ], |
||
46 | "55° 30′, 37° 30′" => [ 55.5, 37.5 ], |
||
47 | |||
48 | // Coordinate strings without separator: |
||
49 | "55° 0' 37° 0'" => [ 55, 37 ], |
||
50 | "55 ° 30 ' 37 ° 30 '" => [ 55.5, 37.5 ], |
||
51 | "0° 0' 0° 0'" => [ 0, 0 ], |
||
52 | "-55° 30 ' -37 ° 30'" => [ -55.5, -37.5 ], |
||
53 | "0° 0.3' S 0° 0.3' W" => [ -0.005, -0.005 ], |
||
54 | "55° 30′ 37° 30′" => [ 55.5, 37.5 ], |
||
55 | |||
56 | // Coordinate string starting with direction character: |
||
57 | "S 0° 0.3', W 0° 0.3'" => [ -0.005, -0.005 ], |
||
58 | "N 0° 0.3' E 0° 0.3'" => [ 0.005, 0.005 ], |
||
59 | ]; |
||
60 | |||
61 | foreach ( $valid as $value => $expected ) { |
||
62 | $expected = new LatLongValue( $expected[0], $expected[1] ); |
||
63 | $argLists[] = [ (string)$value, $expected ]; |
||
64 | } |
||
65 | |||
66 | return $argLists; |
||
67 | } |
||
68 | |||
69 | /** |
||
70 | * @see StringValueParserTest::invalidInputProvider |
||
71 | */ |
||
72 | public function invalidInputProvider() { |
||
73 | return [ |
||
74 | [ null ], |
||
75 | [ 1 ], |
||
76 | [ 0.1 ], |
||
77 | [ '~=[,,_,,]:3' ], |
||
78 | [ 'ohi there' ], |
||
79 | ]; |
||
80 | } |
||
81 | |||
82 | } |
||
83 |
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.