@@ -71,7 +71,41 @@ public function testArrayAccess()
7171 $ multipoint [] = 1 ;
7272 }
7373
74- public function testPrependPoint ()
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+
83+ public function testJsonSerialize ()
84+ {
85+ $ collection = [new Point (0 , 0 ), new Point (0 , 1 ), new Point (1 , 1 )];
86+
87+ $ multipoint = new MultiPoint ($ collection );
88+
89+ $ this ->assertInstanceOf (\GeoJson \Geometry \MultiPoint::class, $ multipoint ->jsonSerialize ());
90+ $ this ->assertSame ('{"type":"MultiPoint","coordinates":[[0,0],[1,0],[1,1]]} ' , json_encode ($ multipoint ));
91+ }
92+
93+ public function testInvalidArgumentExceptionAtLeastOneEntry ()
94+ {
95+ $ this ->assertException (InvalidArgumentException::class);
96+ $ multipoint = new MultiPoint ([]);
97+ }
98+
99+ public function testInvalidArgumentExceptionNotArrayOfLineString ()
100+ {
101+ $ this ->assertException (InvalidArgumentException::class);
102+ $ multipoint = new MultiPoint ([
103+ new Point (0 , 0 ),
104+ 1 ,
105+ ]);
106+ }
107+
108+ public function testDeprecatedPrependPoint ()
75109 {
76110 $ point1 = new Point (1 , 1 );
77111 $ point2 = new Point (2 , 2 );
@@ -80,12 +114,12 @@ public function testPrependPoint()
80114 $ point0 = new Point (0 , 0 );
81115 $ multipoint ->prependPoint ($ point0 );
82116
83- $ this ->assertEquals ($ point0 , $ multipoint-> getPoints () [0 ]);
84- $ this ->assertEquals ($ point1 , $ multipoint-> getPoints () [1 ]);
85- $ this ->assertEquals ($ point2 , $ multipoint-> getPoints () [2 ]);
117+ $ this ->assertEquals ($ point0 , $ multipoint [0 ]);
118+ $ this ->assertEquals ($ point1 , $ multipoint [1 ]);
119+ $ this ->assertEquals ($ point2 , $ multipoint [2 ]);
86120 }
87121
88- public function testAppendPoint ()
122+ public function testDeprecatedAppendPoint ()
89123 {
90124 $ point0 = new Point (0 , 0 );
91125 $ point1 = new Point (1 , 1 );
@@ -94,12 +128,12 @@ public function testAppendPoint()
94128 $ point2 = new Point (2 , 2 );
95129 $ multipoint ->appendPoint ($ point2 );
96130
97- $ this ->assertEquals ($ point0 , $ multipoint-> getPoints () [0 ]);
98- $ this ->assertEquals ($ point1 , $ multipoint-> getPoints () [1 ]);
99- $ this ->assertEquals ($ point2 , $ multipoint-> getPoints () [2 ]);
131+ $ this ->assertEquals ($ point0 , $ multipoint [0 ]);
132+ $ this ->assertEquals ($ point1 , $ multipoint [1 ]);
133+ $ this ->assertEquals ($ point2 , $ multipoint [2 ]);
100134 }
101135
102- public function testInsertPoint ()
136+ public function testDeprecatedInsertPoint ()
103137 {
104138 $ point1 = new Point (1 , 1 );
105139 $ point3 = new Point (3 , 3 );
@@ -108,36 +142,11 @@ public function testInsertPoint()
108142 $ point2 = new Point (2 , 2 );
109143 $ multipoint ->insertPoint (1 , $ point2 );
110144
111- $ this ->assertEquals ($ point1 , $ multipoint-> getPoints () [0 ]);
112- $ this ->assertEquals ($ point2 , $ multipoint-> getPoints () [1 ]);
113- $ this ->assertEquals ($ point3 , $ multipoint-> getPoints () [2 ]);
145+ $ this ->assertEquals ($ point1 , $ multipoint [0 ]);
146+ $ this ->assertEquals ($ point2 , $ multipoint [1 ]);
147+ $ this ->assertEquals ($ point3 , $ multipoint [2 ]);
114148
115149 $ this ->assertException (InvalidArgumentException::class);
116150 $ multipoint ->insertPoint (100 , new Point (100 , 100 ));
117151 }
118-
119- public function testJsonSerialize ()
120- {
121- $ collection = [new Point (0 , 0 ), new Point (0 , 1 ), new Point (1 , 1 )];
122-
123- $ multipoint = new MultiPoint ($ collection );
124-
125- $ this ->assertInstanceOf (\GeoJson \Geometry \MultiPoint::class, $ multipoint ->jsonSerialize ());
126- $ this ->assertSame ('{"type":"MultiPoint","coordinates":[[0,0],[1,0],[1,1]]} ' , json_encode ($ multipoint ));
127- }
128-
129- public function testInvalidArgumentExceptionAtLeastOneEntry ()
130- {
131- $ this ->assertException (InvalidArgumentException::class);
132- $ multipoint = new MultiPoint ([]);
133- }
134-
135- public function testInvalidArgumentExceptionNotArrayOfLineString ()
136- {
137- $ this ->assertException (InvalidArgumentException::class);
138- $ multipoint = new MultiPoint ([
139- new Point (0 , 0 ),
140- 1 ,
141- ]);
142- }
143152}
0 commit comments