diff options
author | Maurício Meneghini Fauth <mauricio@fauth.dev> | 2021-09-09 23:58:00 +0300 |
---|---|---|
committer | Maurício Meneghini Fauth <mauricio@fauth.dev> | 2021-09-09 23:58:00 +0300 |
commit | 94e714a49ba306461d2935906e6fc1a7b8f4addb (patch) | |
tree | 46b8eec7e9fb543a43016829ec5c184089c3d210 /test | |
parent | dd0f63f18cd47ea359ad33b426b9d0faf5cbc2ce (diff) |
Extract the `Server\ShowEngineController` class
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
Diffstat (limited to 'test')
-rw-r--r-- | test/classes/Controllers/Server/EnginesControllerTest.php | 62 | ||||
-rw-r--r-- | test/classes/Controllers/Server/ShowEngineControllerTest.php | 85 |
2 files changed, 86 insertions, 61 deletions
diff --git a/test/classes/Controllers/Server/EnginesControllerTest.php b/test/classes/Controllers/Server/EnginesControllerTest.php index dd92c9929e..e246a958ee 100644 --- a/test/classes/Controllers/Server/EnginesControllerTest.php +++ b/test/classes/Controllers/Server/EnginesControllerTest.php @@ -5,16 +5,10 @@ declare(strict_types=1); namespace PhpMyAdmin\Tests\Controllers\Server; use PhpMyAdmin\Controllers\Server\EnginesController; -use PhpMyAdmin\Html\MySQLDocumentation; -use PhpMyAdmin\Http\ServerRequest; -use PhpMyAdmin\StorageEngine; use PhpMyAdmin\Template; use PhpMyAdmin\Tests\AbstractTestCase; use PhpMyAdmin\Tests\Stubs\ResponseRenderer; -use function __; -use function htmlspecialchars; - /** * @covers \PhpMyAdmin\Controllers\Server\EnginesController */ @@ -46,7 +40,7 @@ class EnginesControllerTest extends AbstractTestCase $controller = new EnginesController($response, new Template(), $dbi); $this->dummyDbi->addSelectDb('mysql'); - $controller->index(); + $controller->__invoke(); $this->assertAllSelectsConsumed(); $actual = $response->getHTMLResult(); @@ -86,58 +80,4 @@ class EnginesControllerTest extends AbstractTestCase $actual ); } - - public function testShow(): void - { - global $dbi; - - $response = new ResponseRenderer(); - - $controller = new EnginesController($response, new Template(), $dbi); - - $request = $this->createMock(ServerRequest::class); - - $this->dummyDbi->addSelectDb('mysql'); - $controller->show($request, [ - 'engine' => 'Pbxt', - 'page' => 'page', - ]); - $this->assertAllSelectsConsumed(); - $actual = $response->getHTMLResult(); - - $enginePlugin = StorageEngine::getEngine('Pbxt'); - - $this->assertStringContainsString( - htmlspecialchars($enginePlugin->getTitle()), - $actual - ); - - $this->assertStringContainsString( - MySQLDocumentation::show($enginePlugin->getMysqlHelpPage()), - $actual - ); - - $this->assertStringContainsString( - htmlspecialchars($enginePlugin->getComment()), - $actual - ); - - $this->assertStringContainsString( - __('Variables'), - $actual - ); - $this->assertStringContainsString( - 'index.php?route=/server/engines/Pbxt/Documentation', - $actual - ); - $this->assertStringContainsString( - $enginePlugin->getSupportInformationMessage(), - $actual - ); - $this->assertStringContainsString( - 'There is no detailed status information available for this ' - . 'storage engine.', - $actual - ); - } } diff --git a/test/classes/Controllers/Server/ShowEngineControllerTest.php b/test/classes/Controllers/Server/ShowEngineControllerTest.php new file mode 100644 index 0000000000..6b67bd2ed2 --- /dev/null +++ b/test/classes/Controllers/Server/ShowEngineControllerTest.php @@ -0,0 +1,85 @@ +<?php + +declare(strict_types=1); + +namespace PhpMyAdmin\Tests\Controllers\Server; + +use PhpMyAdmin\Controllers\Server\ShowEngineController; +use PhpMyAdmin\Html\MySQLDocumentation; +use PhpMyAdmin\Http\ServerRequest; +use PhpMyAdmin\StorageEngine; +use PhpMyAdmin\Template; +use PhpMyAdmin\Tests\AbstractTestCase; +use PhpMyAdmin\Tests\Stubs\ResponseRenderer; + +use function __; +use function htmlspecialchars; + +/** + * @covers \PhpMyAdmin\Controllers\Server\ShowEngineController + */ +class ShowEngineControllerTest extends AbstractTestCase +{ + public function testShowEngine(): void + { + parent::setUp(); + $GLOBALS['text_dir'] = 'ltr'; + parent::setGlobalConfig(); + parent::setTheme(); + + global $dbi; + + $GLOBALS['server'] = 1; + $GLOBALS['db'] = 'db'; + $GLOBALS['table'] = 'table'; + $GLOBALS['PMA_PHP_SELF'] = 'index.php'; + $GLOBALS['cfg']['Server']['DisableIS'] = false; + + $response = new ResponseRenderer(); + $request = $this->createMock(ServerRequest::class); + $this->dummyDbi->addSelectDb('mysql'); + + (new ShowEngineController($response, new Template(), $dbi))($request, [ + 'engine' => 'Pbxt', + 'page' => 'page', + ]); + + $this->assertAllSelectsConsumed(); + $actual = $response->getHTMLResult(); + + $enginePlugin = StorageEngine::getEngine('Pbxt'); + + $this->assertStringContainsString( + htmlspecialchars($enginePlugin->getTitle()), + $actual + ); + + $this->assertStringContainsString( + MySQLDocumentation::show($enginePlugin->getMysqlHelpPage()), + $actual + ); + + $this->assertStringContainsString( + htmlspecialchars($enginePlugin->getComment()), + $actual + ); + + $this->assertStringContainsString( + __('Variables'), + $actual + ); + $this->assertStringContainsString( + 'index.php?route=/server/engines/Pbxt/Documentation', + $actual + ); + $this->assertStringContainsString( + $enginePlugin->getSupportInformationMessage(), + $actual + ); + $this->assertStringContainsString( + 'There is no detailed status information available for this ' + . 'storage engine.', + $actual + ); + } +} |