Remove some useless comments
[phpmyadmin.git] / test / classes / Gis / GisMultiPointTest.php
blobfc630b2b630eaaea388f5c6280ba5f30714c13eb
1 <?php
3 declare(strict_types=1);
5 namespace PhpMyAdmin\Tests\Gis;
7 use PhpMyAdmin\Gis\GisMultiPoint;
8 use TCPDF;
9 use function function_exists;
10 use function imagecreatetruecolor;
11 use function preg_match;
13 class GisMultiPointTest extends GisGeomTestCase
15 /**
16 * @var GisMultiPoint
17 * @access protected
19 protected $object;
21 /**
22 * Sets up the fixture, for example, opens a network connection.
23 * This method is called before a test is executed.
25 * @access protected
27 protected function setUp(): void
29 parent::setUp();
30 $this->object = GisMultiPoint::singleton();
33 /**
34 * Tears down the fixture, for example, closes a network connection.
35 * This method is called after a test is executed.
37 * @access protected
39 protected function tearDown(): void
41 parent::tearDown();
42 unset($this->object);
45 /**
46 * data provider for testGenerateWkt
48 * @return array data for testGenerateWkt
50 public function providerForTestGenerateWkt(): array
52 $gis_data1 = [
53 0 => [
54 'MULTIPOINT' => [
55 'no_of_points' => 2,
56 0 => [
57 'x' => 5.02,
58 'y' => 8.45,
60 1 => [
61 'x' => 1.56,
62 'y' => 4.36,
68 $gis_data2 = $gis_data1;
69 $gis_data2[0]['MULTIPOINT']['no_of_points'] = -1;
71 return [
73 $gis_data1,
75 null,
76 'MULTIPOINT(5.02 8.45,1.56 4.36)',
79 $gis_data2,
81 null,
82 'MULTIPOINT(5.02 8.45)',
87 /**
88 * test getShape method
90 public function testGetShape(): void
92 $gis_data = [
93 'numpoints' => 2,
94 'points' => [
95 0 => [
96 'x' => 5.02,
97 'y' => 8.45,
99 1 => [
100 'x' => 6.14,
101 'y' => 0.15,
106 $this->assertEquals(
107 $this->object->getShape($gis_data),
108 'MULTIPOINT(5.02 8.45,6.14 0.15)'
113 * data provider for testGenerateParams
115 * @return array data for testGenerateParams
117 public function providerForTestGenerateParams(): array
119 $temp1 = [
120 'MULTIPOINT' => [
121 'no_of_points' => 2,
122 0 => [
123 'x' => '5.02',
124 'y' => '8.45',
126 1 => [
127 'x' => '6.14',
128 'y' => '0.15',
132 $temp2 = $temp1;
133 $temp2['gis_type'] = 'MULTIPOINT';
135 return [
137 "'MULTIPOINT(5.02 8.45,6.14 0.15)',124",
138 null,
140 'srid' => '124',
141 0 => $temp1,
145 'MULTIPOINT(5.02 8.45,6.14 0.15)',
147 [2 => $temp2],
153 * data provider for testScaleRow
155 * @return array data for testScaleRow
157 public function providerForTestScaleRow(): array
159 return [
161 'MULTIPOINT(12 35,48 75,69 23,25 45,14 53,35 78)',
163 'minX' => 12,
164 'maxX' => 69,
165 'minY' => 23,
166 'maxY' => 78,
173 * test case for prepareRowAsPng() method
175 * @param string $spatial GIS MULTIPOINT object
176 * @param string $label label for the GIS MULTIPOINT object
177 * @param string $point_color color for the GIS MULTIPOINT object
178 * @param array $scale_data array containing data related to scaling
179 * @param resource $image image object
181 * @dataProvider providerForPrepareRowAsPng
183 public function testPrepareRowAsPng(
184 string $spatial,
185 string $label,
186 string $point_color,
187 array $scale_data,
188 $image
189 ): void {
190 $return = $this->object->prepareRowAsPng(
191 $spatial,
192 $label,
193 $point_color,
194 $scale_data,
195 $image
197 $this->assertImage($return);
201 * data provider for testPrepareRowAsPng() test case
203 * @return array test data for testPrepareRowAsPng() test case
205 public function providerForPrepareRowAsPng(): array
207 if (! function_exists('imagecreatetruecolor')) {
208 $this->markTestSkipped('GD extension missing!');
211 return [
213 'MULTIPOINT(12 35,48 75,69 23,25 45,14 53,35 78)',
214 'image',
215 '#B02EE0',
217 'x' => 12,
218 'y' => 69,
219 'scale' => 2,
220 'height' => 150,
222 imagecreatetruecolor(120, 150),
228 * test case for prepareRowAsPdf() method
230 * @param string $spatial GIS MULTIPOINT object
231 * @param string $label label for the GIS MULTIPOINT object
232 * @param string $point_color color for the GIS MULTIPOINT object
233 * @param array $scale_data array containing data related to scaling
234 * @param TCPDF $pdf TCPDF instance
236 * @dataProvider providerForPrepareRowAsPdf
238 public function testPrepareRowAsPdf(
239 string $spatial,
240 string $label,
241 string $point_color,
242 array $scale_data,
243 TCPDF $pdf
244 ): void {
245 $return = $this->object->prepareRowAsPdf(
246 $spatial,
247 $label,
248 $point_color,
249 $scale_data,
250 $pdf
252 $this->assertInstanceOf('TCPDF', $return);
256 * data provider for testPrepareRowAsPdf() test case
258 * @return array test data for testPrepareRowAsPdf() test case
260 public function providerForPrepareRowAsPdf(): array
262 return [
264 'MULTIPOINT(12 35,48 75,69 23,25 45,14 53,35 78)',
265 'pdf',
266 '#B02EE0',
268 'x' => 12,
269 'y' => 69,
270 'scale' => 2,
271 'height' => 150,
273 new TCPDF(),
279 * test case for prepareRowAsSvg() method
281 * @param string $spatial GIS MULTIPOINT object
282 * @param string $label label for the GIS MULTIPOINT object
283 * @param string $pointColor color for the GIS MULTIPOINT object
284 * @param array $scaleData array containing data related to scaling
285 * @param string $output expected output
287 * @dataProvider providerForPrepareRowAsSvg
289 public function testPrepareRowAsSvg(
290 string $spatial,
291 string $label,
292 string $pointColor,
293 array $scaleData,
294 string $output
295 ): void {
296 $string = $this->object->prepareRowAsSvg(
297 $spatial,
298 $label,
299 $pointColor,
300 $scaleData
302 $this->assertEquals(1, preg_match($output, $string));
306 * data provider for testPrepareRowAsSvg() test case
308 * @return array test data for testPrepareRowAsSvg() test case
310 public function providerForPrepareRowAsSvg(): array
312 return [
314 'MULTIPOINT(12 35,48 75,69 23,25 45,14 53,35 78)',
315 'svg',
316 '#B02EE0',
318 'x' => 12,
319 'y' => 69,
320 'scale' => 2,
321 'height' => 150,
323 '/^(<circle cx="72" cy="138" r="3" name="svg" class="multipoint '
324 . 'vector" fill="white" stroke="#B02EE0" stroke-width="2" id="svg)'
325 . '(\d+)("\/><circle cx="114" cy="242" r="3" name="svg" class="mult'
326 . 'ipoint vector" fill="white" stroke="#B02EE0" stroke-width="2" id'
327 . '="svg)(\d+)("\/><circle cx="26" cy="198" r="3" name="svg" class='
328 . '"multipoint vector" fill="white" stroke="#B02EE0" stroke-width='
329 . '"2" id="svg)(\d+)("\/><circle cx="4" cy="182" r="3" name="svg" '
330 . 'class="multipoint vector" fill="white" stroke="#B02EE0" stroke-'
331 . 'width="2" id="svg)(\d+)("\/><circle cx="46" cy="132" r="3" name='
332 . '"svg" class="multipoint vector" fill="white" stroke="#B02EE0" '
333 . 'stroke-width="2" id="svg)(\d+)("\/>)$/',
339 * test case for prepareRowAsOl() method
341 * @param string $spatial GIS MULTIPOINT object
342 * @param int $srid spatial reference ID
343 * @param string $label label for the GIS MULTIPOINT object
344 * @param array $point_color color for the GIS MULTIPOINT object
345 * @param array $scale_data array containing data related to scaling
346 * @param string $output expected output
348 * @dataProvider providerForPrepareRowAsOl
350 public function testPrepareRowAsOl(
351 string $spatial,
352 int $srid,
353 string $label,
354 array $point_color,
355 array $scale_data,
356 string $output
357 ): void {
358 $this->assertEquals(
359 $output,
360 $this->object->prepareRowAsOl(
361 $spatial,
362 $srid,
363 $label,
364 $point_color,
365 $scale_data
371 * data provider for testPrepareRowAsOl() test case
373 * @return array test data for testPrepareRowAsOl() test case
375 public function providerForPrepareRowAsOl(): array
377 return [
379 'MULTIPOINT(12 35,48 75,69 23,25 45,14 53,35 78)',
380 4326,
381 'Ol',
382 [176, 46, 224],
384 'minX' => '0',
385 'minY' => '0',
386 'maxX' => '1',
387 'maxY' => '1',
389 'var fill = new ol.style.Fill({"color":"white"});var stroke = new ol.style.Stroke({'
390 . '"color":[176,46,224],"width":2});var style = new ol.style.Style({image: new ol.s'
391 . 'tyle.Circle({fill: fill,stroke: stroke,radius: 3}),fill: fill,stroke: stroke,tex'
392 . 't: new ol.style.Text({"text":"Ol","offsetY":-9})});var minLoc = [0, 0];var maxLo'
393 . 'c = [1, 1];var ext = ol.extent.boundingExtent([minLoc, maxLoc]);ext = ol.proj.tr'
394 . 'ansformExtent(ext, ol.proj.get("EPSG:4326"), ol.proj.get(\'EPSG:3857\'));map.get'
395 . 'View().fit(ext, map.getSize());var multiPoint = new ol.geom.MultiPoint(new Array'
396 . '((new ol.geom.Point([12,35]).transform(ol.proj.get("EPSG:4326"), ol.proj.get(\'E'
397 . 'PSG:3857\'))).getCoordinates(), (new ol.geom.Point([48,75]).transform(ol.proj.ge'
398 . 't("EPSG:4326"), ol.proj.get(\'EPSG:3857\'))).getCoordinates(), (new ol.geom.Poin'
399 . 't([69,23]).transform(ol.proj.get("EPSG:4326"), ol.proj.get(\'EPSG:3857\'))).getC'
400 . 'oordinates(), (new ol.geom.Point([25,45]).transform(ol.proj.get("EPSG:4326"), ol'
401 . '.proj.get(\'EPSG:3857\'))).getCoordinates(), (new ol.geom.Point([14,53]).transfo'
402 . 'rm(ol.proj.get("EPSG:4326"), ol.proj.get(\'EPSG:3857\'))).getCoordinates(), (new'
403 . ' ol.geom.Point([35,78]).transform(ol.proj.get("EPSG:4326"), ol.proj.get(\'EPSG:3'
404 . '857\'))).getCoordinates()));var feature = new ol.Feature({geometry: multiPoint})'
405 . ';feature.setStyle(style);vectorLayer.addFeature(feature);',