phpmyadmin/tests/classes/Controllers/GisDataEditorControllerTest.php
Maurício Meneghini Fauth ba72f543fd
Call PHPUnit static methods using static calls
Replaces $this->method() with self::method().

Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2024-01-31 17:17:38 -03:00

71 lines
1.9 KiB
PHP

<?php
declare(strict_types=1);
namespace PhpMyAdmin\Tests\Controllers;
use PhpMyAdmin\Controllers\GisDataEditorController;
use PhpMyAdmin\Current;
use PhpMyAdmin\DatabaseInterface;
use PhpMyAdmin\Template;
use PhpMyAdmin\Tests\AbstractTestCase;
use PhpMyAdmin\Tests\Stubs\ResponseRenderer;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Group;
#[CoversClass(GisDataEditorController::class)]
class GisDataEditorControllerTest extends AbstractTestCase
{
private GisDataEditorController|null $controller = null;
protected function setUp(): void
{
parent::setUp();
$GLOBALS['PMA_PHP_SELF'] = 'index.php';
Current::$database = 'db';
Current::$table = 'table';
DatabaseInterface::$instance = $this->createDatabaseInterface();
$this->controller = new GisDataEditorController(new ResponseRenderer(), new Template());
}
#[DataProvider('providerForTestValidateGisData')]
#[Group('gis')]
public function testValidateGisData(mixed $gisData, string $type, string|null $value, string $expected): void
{
/** @var string $gisData */
$gisData = $this->callFunction(
$this->controller,
GisDataEditorController::class,
'extractGisType',
[
$gisData,
$type,
$value,
],
);
self::assertEquals($expected, $gisData);
}
/** @return iterable<array{0:mixed,1:string,2:string|null,3:string}> */
public static function providerForTestValidateGisData(): iterable
{
yield [
null,
'GEOMETRY',
'GEOMETRYCOLLECTION()',
'GEOMETRYCOLLECTION',
];
yield [
null,
'GEOMETRY',
'GEOMETRYCOLLECTION EMPTY',
'GEOMETRYCOLLECTION',
];
}
}