1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
|
<?php
declare(strict_types=1);
namespace PhpMyAdmin\Tests\Controllers;
use PhpMyAdmin\Controllers\GisDataEditorController;
use PhpMyAdmin\Template;
use PhpMyAdmin\Tests\AbstractTestCase;
use PhpMyAdmin\Tests\Stubs\ResponseRenderer;
/**
* @covers \PhpMyAdmin\Controllers\GisDataEditorController
*/
#[\PHPUnit\Framework\Attributes\CoversClass(\PhpMyAdmin\Controllers\GisDataEditorController::class)]
class GisDataEditorControllerTest extends AbstractTestCase
{
/** @var GisDataEditorController|null */
private $controller = null;
protected function setUp(): void
{
parent::setUp();
$GLOBALS['server'] = 1;
$GLOBALS['text_dir'] = 'ltr';
$GLOBALS['PMA_PHP_SELF'] = 'index.php';
$GLOBALS['db'] = 'db';
$GLOBALS['table'] = 'table';
$this->controller = new GisDataEditorController(new ResponseRenderer(), new Template());
}
/**
* @param mixed[] $gis_data
* @param mixed[] $expected
*
* @group gis
* @dataProvider providerForTestValidateGisData
*/
#[\PHPUnit\Framework\Attributes\DataProvider('providerForTestValidateGisData')]
public function testValidateGisData(array $gis_data, string $type, ?string $value, array $expected): void
{
/** @var mixed[] $gisData */
$gisData = $this->callFunction(
$this->controller,
GisDataEditorController::class,
'validateGisData',
[
$gis_data,
$type,
$value,
]
);
self::assertSame($expected, $gisData);
}
/**
* @return list<list<mixed[]|string|null>>
* @psalm-return list<array{0:mixed[],1:string,2:string|null,3:mixed[]}>
*/
public static function providerForTestValidateGisData(): array
{
/** @psalm-var list<array{0:mixed[],1:string,2:string|null,3:mixed[]}> */
return [
[
[],
'GEOMETRY',
'GEOMETRYCOLLECTION()',
['gis_type' => 'GEOMETRYCOLLECTION'],
],
[
[],
'GEOMETRY',
'GEOMETRYCOLLECTION EMPTY',
['gis_type' => 'GEOMETRYCOLLECTION'],
],
];
}
}
|