This allows better handling of the user's config loading and validation. Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
54 lines
1.6 KiB
PHP
54 lines
1.6 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace PhpMyAdmin\Tests\Controllers\Table\Maintenance;
|
|
|
|
use PhpMyAdmin\Controllers\Table\Maintenance\ChecksumController;
|
|
use PhpMyAdmin\Http\ServerRequest;
|
|
use PhpMyAdmin\Table\Maintenance;
|
|
use PhpMyAdmin\Template;
|
|
use PhpMyAdmin\Tests\AbstractTestCase;
|
|
use PhpMyAdmin\Tests\Stubs\ResponseRenderer;
|
|
|
|
/**
|
|
* @covers \PhpMyAdmin\Controllers\Table\Maintenance\ChecksumController
|
|
*/
|
|
class ChecksumControllerTest extends AbstractTestCase
|
|
{
|
|
/**
|
|
* @param string[][]|string[]|string|null $tables
|
|
*
|
|
* @dataProvider providerForTestNoTableSelected
|
|
*/
|
|
public function testNoTableSelected($tables): void
|
|
{
|
|
$request = $this->createStub(ServerRequest::class);
|
|
$request->method('getParsedBodyParam')->willReturnMap([['selected_tbl', null, $tables]]);
|
|
$dbi = $this->createDatabaseInterface();
|
|
$GLOBALS['dbi'] = $dbi;
|
|
$response = new ResponseRenderer();
|
|
$controller = new ChecksumController($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 function providerForTestNoTableSelected(): array
|
|
{
|
|
return [
|
|
[null],
|
|
[''],
|
|
['table'],
|
|
[[]],
|
|
[['']],
|
|
[['table', '']],
|
|
[[['table']]],
|
|
];
|
|
}
|
|
}
|