1 | <?php |
||
22 | class GeoArrayTest extends TestCase |
||
23 | { |
||
24 | /** |
||
25 | * @var GeoArray |
||
26 | */ |
||
27 | private $dumper; |
||
28 | |||
29 | protected function setUp() |
||
30 | { |
||
31 | $this->dumper = new GeoArray(); |
||
32 | } |
||
33 | |||
34 | public function testDump() |
||
35 | { |
||
36 | $address = Address::createFromArray([]); |
||
37 | $expected = [ |
||
38 | 'type' => 'Feature', |
||
39 | 'geometry' => [ |
||
40 | 'type' => 'Point', |
||
41 | 'coordinates' => [0, 0], |
||
42 | ], |
||
43 | 'properties' => [ |
||
44 | 'providedBy' => 'n/a', |
||
45 | ], |
||
46 | ]; |
||
47 | |||
48 | $result = $this->dumper->dump($address); |
||
49 | |||
50 | $this->assertInternalType('array', $result); |
||
51 | $this->assertEquals($expected, $result); |
||
52 | } |
||
53 | |||
54 | public function testDumpWithData() |
||
55 | { |
||
56 | $address = Address::createFromArray([ |
||
57 | 'latitude' => 48.8631507, |
||
58 | 'longitude' => 2.3889114, |
||
59 | ]); |
||
60 | |||
61 | $expected = [ |
||
62 | 'type' => 'Feature', |
||
63 | 'geometry' => [ |
||
64 | 'type' => 'Point', |
||
65 | 'coordinates' => [2.3889114, 48.8631507], |
||
66 | ], |
||
67 | 'properties' => [ |
||
68 | 'providedBy' => 'n/a', |
||
69 | ], |
||
70 | ]; |
||
71 | |||
72 | $result = $this->dumper->dump($address); |
||
73 | |||
74 | $this->assertInternalType('array', $result); |
||
75 | $this->assertEquals($expected, $result); |
||
76 | } |
||
77 | |||
78 | public function testDumpWithBounds() |
||
79 | { |
||
80 | $address = Address::createFromArray([ |
||
81 | 'latitude' => 48.8631507, |
||
82 | 'longitude' => 2.3889114, |
||
83 | 'bounds' => [ |
||
84 | 'south' => 48.8631507, |
||
85 | 'west' => 2.3889114, |
||
86 | 'north' => 48.8631507, |
||
87 | 'east' => 2.388911, |
||
88 | ], |
||
89 | ]); |
||
90 | |||
91 | $expected = [ |
||
92 | 'type' => 'Feature', |
||
93 | 'geometry' => [ |
||
94 | 'type' => 'Point', |
||
95 | 'coordinates' => [2.3889114, 48.8631507], |
||
96 | ], |
||
97 | 'properties' => [ |
||
98 | 'providedBy' => 'n/a', |
||
99 | ], |
||
100 | 'bounds' => [ |
||
101 | 'south' => 48.8631507, |
||
102 | 'west' => 2.3889114, |
||
103 | 'north' => 48.8631507, |
||
104 | 'east' => 2.388911, |
||
105 | ], |
||
106 | ]; |
||
107 | |||
108 | $result = $this->dumper->dump($address); |
||
109 | |||
110 | $this->assertInternalType('array', $result); |
||
111 | $this->assertEquals($expected, $result); |
||
112 | } |
||
113 | |||
114 | public function testDumpWithProperties() |
||
115 | { |
||
116 | $address = Address::createFromArray([ |
||
117 | 'latitude' => 48.8631507, |
||
118 | 'longitude' => 2.3889114, |
||
119 | 'bounds' => [ |
||
120 | 'south' => 48.8631507, |
||
121 | 'west' => 2.3889114, |
||
122 | 'north' => 48.8631507, |
||
123 | 'east' => 2.388911, |
||
124 | ], |
||
125 | 'locality' => 'Paris', |
||
126 | 'country' => 'France', |
||
127 | ]); |
||
128 | |||
129 | $expected = [ |
||
130 | 'type' => 'Feature', |
||
131 | 'geometry' => [ |
||
132 | 'type' => 'Point', |
||
133 | 'coordinates' => [2.3889114, 48.8631507], |
||
134 | ], |
||
135 | 'properties' => [ |
||
136 | 'locality' => 'Paris', |
||
137 | 'country' => 'France', |
||
138 | 'providedBy' => 'n/a', |
||
139 | ], |
||
140 | 'bounds' => [ |
||
141 | 'south' => 48.8631507, |
||
142 | 'west' => 2.3889114, |
||
143 | 'north' => 48.8631507, |
||
144 | 'east' => 2.388911, |
||
145 | ], |
||
146 | ]; |
||
147 | |||
148 | $result = $this->dumper->dump($address); |
||
149 | |||
150 | $this->assertInternalType('array', $result); |
||
151 | $this->assertEquals($expected, $result); |
||
152 | } |
||
153 | } |
||
154 |