* Fix wrong type hint Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> * Use $this instead of parent Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> * setUp should be a protected method Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> * onNotSuccessfulTest should be protected Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> * $command doesn't need to be a property Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> * Give alertText() proper return type Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> * Use null-safe operator Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> * Call Message static constructors statically Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> * Call StorageEngine methods statically Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> * Add better type hints in PrivilegesController Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> * Use packed (without keys) arrays in tests Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> * Use type casts instead of function casts Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> * Use const instead of private property Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> * Use const instead of private property Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> * Fix testAuthFailsTooLongPass() Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> * Replace loop with array_shift Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> * Use ob_get_clean Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> * Remove duplicated code Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> * Use assert instead of phpdoc Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> --------- Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
89 lines
2.6 KiB
PHP
89 lines
2.6 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace PhpMyAdmin\Tests\Controllers\Server;
|
|
|
|
use PhpMyAdmin\Config;
|
|
use PhpMyAdmin\Controllers\Server\ShowEngineController;
|
|
use PhpMyAdmin\Current;
|
|
use PhpMyAdmin\DatabaseInterface;
|
|
use PhpMyAdmin\Html\MySQLDocumentation;
|
|
use PhpMyAdmin\Http\Factory\ServerRequestFactory;
|
|
use PhpMyAdmin\StorageEngine;
|
|
use PhpMyAdmin\Template;
|
|
use PhpMyAdmin\Tests\AbstractTestCase;
|
|
use PhpMyAdmin\Tests\Stubs\DbiDummy;
|
|
use PhpMyAdmin\Tests\Stubs\ResponseRenderer;
|
|
use PHPUnit\Framework\Attributes\CoversClass;
|
|
|
|
use function __;
|
|
use function htmlspecialchars;
|
|
|
|
#[CoversClass(ShowEngineController::class)]
|
|
class ShowEngineControllerTest extends AbstractTestCase
|
|
{
|
|
protected DatabaseInterface $dbi;
|
|
|
|
protected DbiDummy $dummyDbi;
|
|
|
|
protected function setUp(): void
|
|
{
|
|
parent::setUp();
|
|
|
|
$this->setGlobalConfig();
|
|
|
|
$this->dummyDbi = $this->createDbiDummy();
|
|
$this->dbi = $this->createDatabaseInterface($this->dummyDbi);
|
|
DatabaseInterface::$instance = $this->dbi;
|
|
}
|
|
|
|
public function testShowEngine(): void
|
|
{
|
|
Current::$database = 'db';
|
|
Current::$table = 'table';
|
|
Config::getInstance()->selectedServer['DisableIS'] = false;
|
|
|
|
$response = new ResponseRenderer();
|
|
$this->dummyDbi->addSelectDb('mysql');
|
|
$request = ServerRequestFactory::create()->createServerRequest('GET', 'http://example.com/')
|
|
->withAttribute('routeVars', ['engine' => 'Pbxt', 'page' => 'page']);
|
|
|
|
(new ShowEngineController($response, new Template(), DatabaseInterface::getInstance()))($request);
|
|
|
|
$this->dummyDbi->assertAllSelectsConsumed();
|
|
$actual = $response->getHTMLResult();
|
|
|
|
$enginePlugin = StorageEngine::getEngine('Pbxt');
|
|
|
|
self::assertStringContainsString(
|
|
htmlspecialchars($enginePlugin->getTitle()),
|
|
$actual,
|
|
);
|
|
|
|
self::assertStringContainsString(
|
|
MySQLDocumentation::show($enginePlugin->getMysqlHelpPage()),
|
|
$actual,
|
|
);
|
|
|
|
self::assertStringContainsString(
|
|
htmlspecialchars($enginePlugin->getComment()),
|
|
$actual,
|
|
);
|
|
|
|
self::assertStringContainsString(
|
|
__('Variables'),
|
|
$actual,
|
|
);
|
|
self::assertStringContainsString('index.php?route=/server/engines/Pbxt/Documentation', $actual);
|
|
self::assertStringContainsString(
|
|
$enginePlugin->getSupportInformationMessage(),
|
|
$actual,
|
|
);
|
|
self::assertStringContainsString(
|
|
'There is no detailed status information available for this storage engine.',
|
|
$actual,
|
|
);
|
|
}
|
|
}
|