phpmyadmin/tests/classes/Controllers/Table/Maintenance/AnalyzeControllerTest.php
Maurício Meneghini Fauth 1d1c55e250
Move test directory to tests
- Related to #18512

Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2023-11-30 10:47:42 -03:00

42 lines
1.6 KiB
PHP

<?php
declare(strict_types=1);
namespace PhpMyAdmin\Tests\Controllers\Table\Maintenance;
use PhpMyAdmin\Controllers\Table\Maintenance\AnalyzeController;
use PhpMyAdmin\DatabaseInterface;
use PhpMyAdmin\Http\ServerRequest;
use PhpMyAdmin\Table\Maintenance;
use PhpMyAdmin\Template;
use PhpMyAdmin\Tests\AbstractTestCase;
use PhpMyAdmin\Tests\Stubs\ResponseRenderer;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
#[CoversClass(AnalyzeController::class)]
class AnalyzeControllerTest extends AbstractTestCase
{
/** @param string[][]|string[]|string|null $tables */
#[DataProvider('providerForTestNoTableSelected')]
public function testNoTableSelected(array|string|null $tables): void
{
$request = $this->createStub(ServerRequest::class);
$request->method('getParsedBodyParam')->willReturnMap([['selected_tbl', null, $tables]]);
$dbi = $this->createDatabaseInterface();
DatabaseInterface::$instance = $dbi;
$response = new ResponseRenderer();
$controller = new AnalyzeController($response, new Template(), new Maintenance($dbi), $this->createConfig());
$controller($request);
$this->assertFalse($response->hasSuccessState());
$this->assertSame(['message' => 'No table selected.'], $response->getJSONResult());
$this->assertSame('', $response->getHTMLResult());
}
/** @return array<int, array{string[][]|string[]|string|null}> */
public static function providerForTestNoTableSelected(): array
{
return [[null], [''], ['table'], [[]], [['']], [['table', '']], [[['table']]]];
}
}