@@ -29,57 +29,6 @@ public function testGetPoints()
2929 $ this ->assertInstanceOf (Point::class, $ multipoint ->getPoints ()[0 ]);
3030 }
3131
32- public function testToArray ()
33- {
34- $ multipoint = MultiPoint::fromWKT ('MULTIPOINT((0 0),(1 0),(1 1)) ' );
35-
36- $ this ->assertInstanceOf (Point::class, $ multipoint ->toArray ()[0 ]);
37- }
38-
39- public function testIteratorAggregate ()
40- {
41- $ multipoint = MultiPoint::fromWKT ('MULTIPOINT((0 0),(1 0),(1 1)) ' );
42-
43- foreach ($ multipoint as $ value ) {
44- $ this ->assertInstanceOf (Point::class, $ value );
45- }
46- }
47-
48- public function testArrayAccess ()
49- {
50- $ point0 = new Point (0 , 0 );
51- $ point1 = new Point (1 , 1 );
52- $ multipoint = new MultiPoint ([$ point0 , $ point1 ]);
53-
54- $ this ->assertEquals ($ point0 , $ multipoint [0 ]);
55- $ this ->assertEquals ($ point1 , $ multipoint [1 ]);
56- $ point2 = new Point (2 , 2 );
57-
58- $ multipoint [] = $ point2 ;
59- $ this ->assertEquals ($ point2 , $ multipoint [2 ]);
60-
61- unset($ multipoint [0 ]);
62- $ this ->assertNull ($ multipoint [0 ]);
63- $ this ->assertEquals ($ point1 , $ multipoint [1 ]);
64- $ this ->assertEquals ($ point2 , $ multipoint [2 ]);
65-
66- $ point100 = new Point (100 , 100 );
67- $ multipoint [100 ] = $ point100 ;
68- $ this ->assertEquals ($ point100 , $ multipoint [100 ]);
69-
70- $ this ->assertException (InvalidArgumentException::class);
71- $ multipoint [] = 1 ;
72- }
73-
74- public function testToJson ()
75- {
76- $ collection = [new Point (0 , 0 ), new Point (0 , 1 ), new Point (1 , 1 )];
77-
78- $ multipoint = new MultiPoint ($ collection );
79-
80- $ this ->assertSame ('{"type":"MultiPoint","coordinates":[[0,0],[1,0],[1,1]]} ' , $ multipoint ->toJson ());
81- }
82-
8332 public function testJsonSerialize ()
8433 {
8534 $ collection = [new Point (0 , 0 ), new Point (0 , 1 ), new Point (1 , 1 )];
@@ -105,6 +54,26 @@ public function testInvalidArgumentExceptionNotArrayOfLineString()
10554 ]);
10655 }
10756
57+ public function testArrayAccess ()
58+ {
59+ $ point0 = new Point (0 , 0 );
60+ $ point1 = new Point (1 , 1 );
61+ $ multipoint = new MultiPoint ([$ point0 , $ point1 ]);
62+
63+ // assert getting
64+ $ this ->assertEquals ($ point0 , $ multipoint [0 ]);
65+ $ this ->assertEquals ($ point1 , $ multipoint [1 ]);
66+
67+ // assert setting
68+ $ point2 = new Point (2 , 2 );
69+ $ multipoint [] = $ point2 ;
70+ $ this ->assertEquals ($ point2 , $ multipoint [2 ]);
71+
72+ // assert invalid
73+ $ this ->assertException (InvalidArgumentException::class);
74+ $ multipoint [] = 1 ;
75+ }
76+
10877 public function testDeprecatedPrependPoint ()
10978 {
11079 $ point1 = new Point (1 , 1 );
0 commit comments