3 declare(strict_types
=1);
5 namespace PhpMyAdmin\Tests\Gis
;
7 use PhpMyAdmin\Gis\GisMultiPoint
;
9 use function function_exists
;
10 use function imagecreatetruecolor
;
11 use function preg_match
;
13 class GisMultiPointTest
extends GisGeomTestCase
22 * Sets up the fixture, for example, opens a network connection.
23 * This method is called before a test is executed.
27 protected function setUp(): void
30 $this->object = GisMultiPoint
::singleton();
34 * Tears down the fixture, for example, closes a network connection.
35 * This method is called after a test is executed.
39 protected function tearDown(): void
46 * data provider for testGenerateWkt
48 * @return array data for testGenerateWkt
50 public function providerForTestGenerateWkt(): array
68 $gis_data2 = $gis_data1;
69 $gis_data2[0]['MULTIPOINT']['no_of_points'] = -1;
76 'MULTIPOINT(5.02 8.45,1.56 4.36)',
82 'MULTIPOINT(5.02 8.45)',
88 * test getShape method
90 public function testGetShape(): void
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
133 $temp2['gis_type'] = 'MULTIPOINT';
137 "'MULTIPOINT(5.02 8.45,6.14 0.15)',124",
145 'MULTIPOINT(5.02 8.45,6.14 0.15)',
153 * data provider for testScaleRow
155 * @return array data for testScaleRow
157 public function providerForTestScaleRow(): array
161 'MULTIPOINT(12 35,48 75,69 23,25 45,14 53,35 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(
190 $return = $this->object->prepareRowAsPng(
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!');
213 'MULTIPOINT(12 35,48 75,69 23,25 45,14 53,35 78)',
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(
245 $return = $this->object->prepareRowAsPdf(
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
264 'MULTIPOINT(12 35,48 75,69 23,25 45,14 53,35 78)',
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(
296 $string = $this->object->prepareRowAsSvg(
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
314 'MULTIPOINT(12 35,48 75,69 23,25 45,14 53,35 78)',
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(
360 $this->object->prepareRowAsOl(
371 * data provider for testPrepareRowAsOl() test case
373 * @return array test data for testPrepareRowAsOl() test case
375 public function providerForPrepareRowAsOl(): array
379 'MULTIPOINT(12 35,48 75,69 23,25 45,14 53,35 78)',
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);',