@@ -10,15 +10,15 @@ public function testConstructorShouldAcceptArrayOfLatLngs()
1010 new LatLng (0 , 0 ),
1111 array ('latitude ' => 0 , 'longitude ' => 1 ),
1212 '1, 1 ' ,
13- array (1 , 0 )
13+ ' key ' => array (1 , 0 )
1414 );
1515
1616 $ polygon = new Polygon ($ points );
1717
1818 $ this ->assertEquals ($ points [0 ], $ polygon [0 ]);
1919 $ this ->assertEquals (0 , $ polygon [1 ]->getLatitude ());
2020 $ this ->assertEquals (1 , $ polygon [2 ]->getLatitude ());
21- $ this ->assertEquals (1 , $ polygon [3 ]->getLatitude ());
21+ $ this ->assertEquals (1 , $ polygon [' key ' ]->getLatitude ());
2222 }
2323
2424 public function testConstructorThrowsExceptionForInvalidLatLng ()
@@ -224,6 +224,17 @@ public function containsDataProvider()
224224 array ('lng ' => 0.5 , 'lat ' => 0.5 ),
225225 false
226226 ),
227+
228+ // Assoc polygon
229+ array (
230+ array (
231+ 'polygon1 ' => array ('lng ' => 1 , 'lat ' => 1 ),
232+ 'polygon2 ' => array ('lng ' => 3 , 'lat ' => 2 ),
233+ 'polygon3 ' => array ('lng ' => 2 , 'lat ' => 3 )
234+ ),
235+ array ('lng ' => 1.5 , 'lat ' => 1.5 ),
236+ true
237+ ),
227238 );
228239 }
229240
@@ -255,7 +266,7 @@ public function testToBoundsThrowsExceptionForEmptyPolygon()
255266 $ polygon ->toBounds ();
256267 }
257268
258- public function testArrayAccess ()
269+ public function testArrayAccessNumeric ()
259270 {
260271 $ points = array (
261272 new LatLng (0 , 0 )
@@ -268,6 +279,19 @@ public function testArrayAccess()
268279 $ this ->assertEquals ($ points [0 ], $ polygon [0 ]);
269280 }
270281
282+ public function testArrayAccessAssoc ()
283+ {
284+ $ points = array (
285+ 'key ' => new LatLng (0 , 0 )
286+ );
287+
288+ $ polygon = new Polygon ($ points );
289+
290+ $ this ->assertTrue (isset ($ polygon ['key ' ]));
291+ $ this ->assertNotNull ($ polygon ['key ' ]);
292+ $ this ->assertEquals ($ points ['key ' ], $ polygon ['key ' ]);
293+ }
294+
271295 public function testOffsetGetThrowsExceptionForInvalidKey ()
272296 {
273297 $ this ->setExpectedException ('\InvalidArgumentException ' , 'Invalid offset 0. ' );
0 commit comments