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\LatLongParser; |
||
6 | use DataValues\Geo\Values\LatLongValue; |
||
7 | |||
8 | /** |
||
9 | * @covers DataValues\Geo\Parsers\LatLongParser |
||
10 | * |
||
11 | * @group ValueParsers |
||
12 | * @group DataValueExtensions |
||
13 | * |
||
14 | * @license GPL-2.0+ |
||
15 | * @author Jeroen De Dauw < [email protected] > |
||
16 | */ |
||
17 | class LatLongParserTest extends ParserTestBase { |
||
0 ignored issues
–
show
|
|||
18 | |||
19 | /** |
||
20 | * @see ValueParserTestBase::getInstance |
||
21 | * |
||
22 | * @return LatLongParser |
||
23 | */ |
||
24 | protected function getInstance() { |
||
25 | return new LatLongParser(); |
||
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 | "1N 1E\n" => [ 1, 1 ], |
||
39 | ' 1N 1E ' => [ 1, 1 ], |
||
40 | |||
41 | // Float |
||
42 | '55.7557860 N, 37.6176330 W' => [ 55.7557860, -37.6176330 ], |
||
43 | '55.7557860, -37.6176330' => [ 55.7557860, -37.6176330 ], |
||
44 | '55 S, 37.6176330 W' => [ -55, -37.6176330 ], |
||
45 | '-55, -37.6176330' => [ -55, -37.6176330 ], |
||
46 | '5.5S,37W ' => [ -5.5, -37 ], |
||
47 | '-5.5,-37 ' => [ -5.5, -37 ], |
||
48 | '4,2' => [ 4, 2, 1 ], |
||
49 | '5.5S 37W ' => [ -5.5, -37 ], |
||
50 | '-5.5 -37 ' => [ -5.5, -37 ], |
||
51 | '4 2' => [ 4, 2, 1 ], |
||
52 | 'S5.5 W37 ' => [ -5.5, -37 ], |
||
53 | |||
54 | // DD |
||
55 | '55.7557860° N, 37.6176330° W' => [ 55.7557860, -37.6176330 ], |
||
56 | '55.7557860°, -37.6176330°' => [ 55.7557860, -37.6176330 ], |
||
57 | '55° S, 37.6176330 ° W' => [ -55, -37.6176330 ], |
||
58 | '-55°, -37.6176330 °' => [ -55, -37.6176330 ], |
||
59 | '5.5°S,37°W ' => [ -5.5, -37 ], |
||
60 | '-5.5°,-37° ' => [ -5.5, -37 ], |
||
61 | '-55° -37.6176330 °' => [ -55, -37.6176330 ], |
||
62 | '5.5°S 37°W ' => [ -5.5, -37 ], |
||
63 | '-5.5 ° -37 ° ' => [ -5.5, -37 ], |
||
64 | 'S5.5° W37°' => [ -5.5, -37 ], |
||
65 | |||
66 | // DMS |
||
67 | '55° 45\' 20.8296", 37° 37\' 3.4788"' => [ 55.755786, 37.6176330000 ], |
||
68 | '55° 45\' 20.8296", -37° 37\' 3.4788"' => [ 55.755786, -37.6176330000 ], |
||
69 | '-55° 45\' 20.8296", -37° 37\' 3.4788"' => [ -55.755786, -37.6176330000 ], |
||
70 | '-55° 45\' 20.8296", 37° 37\' 3.4788"' => [ -55.755786, 37.6176330000 ], |
||
71 | '55° 0\' 0", 37° 0\' 0"' => [ 55, 37 ], |
||
72 | '55° 30\' 0", 37° 30\' 0"' => [ 55.5, 37.5 ], |
||
73 | '55° 0\' 18", 37° 0\' 18"' => [ 55.005, 37.005 ], |
||
74 | '0° 0\' 0", 0° 0\' 0"' => [ 0, 0 ], |
||
75 | '0° 0\' 18" N, 0° 0\' 18" E' => [ 0.005, 0.005 ], |
||
76 | ' 0° 0\' 18" S , 0° 0\' 18" W ' => [ -0.005, -0.005 ], |
||
77 | '0° 0′ 18″ N, 0° 0′ 18″ E' => [ 0.005, 0.005 ], |
||
78 | '0° 0\' 18" N 0° 0\' 18" E' => [ 0.005, 0.005 ], |
||
79 | ' 0 ° 0 \' 18 " S 0 ° 0 \' 18 " W ' => [ -0.005, -0.005 ], |
||
80 | '0° 0′ 18″ N 0° 0′ 18″ E' => [ 0.005, 0.005 ], |
||
81 | 'N 0° 0\' 18" E 0° 0\' 18"' => [ 0.005, 0.005 ], |
||
82 | |||
83 | // DM |
||
84 | '55° 0\', 37° 0\'' => [ 55, 37 ], |
||
85 | '55° 30\', 37° 30\'' => [ 55.5, 37.5 ], |
||
86 | '0° 0\', 0° 0\'' => [ 0, 0 ], |
||
87 | '-55° 30\', -37° 30\'' => [ -55.5, -37.5 ], |
||
88 | '0° 0.3\' S, 0° 0.3\' W' => [ -0.005, -0.005 ], |
||
89 | '-55° 30′, -37° 30′' => [ -55.5, -37.5 ], |
||
90 | '-55 ° 30 \' -37 ° 30 \'' => [ -55.5, -37.5 ], |
||
91 | '0° 0.3\' S 0° 0.3\' W' => [ -0.005, -0.005 ], |
||
92 | '-55° 30′ -37° 30′' => [ -55.5, -37.5 ], |
||
93 | 'S 0° 0.3\' W 0° 0.3\'' => [ -0.005, -0.005 ], |
||
94 | ]; |
||
95 | |||
96 | foreach ( $valid as $value => $expected ) { |
||
97 | $expected = new LatLongValue( $expected[0], $expected[1] ); |
||
98 | $argLists[] = [ (string)$value, $expected ]; |
||
99 | } |
||
100 | |||
101 | return $argLists; |
||
102 | } |
||
103 | |||
104 | /** |
||
105 | * @see StringValueParserTest::invalidInputProvider |
||
106 | */ |
||
107 | public function invalidInputProvider() { |
||
108 | return [ |
||
109 | [ null ], |
||
110 | [ 1 ], |
||
111 | [ 0.1 ], |
||
112 | [ '~=[,,_,,]:3' ], |
||
113 | [ 'ohi there' ], |
||
114 | ]; |
||
115 | } |
||
116 | |||
117 | } |
||
118 |
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.