Skip to content
Permalink
Browse files

Fix tests for server_engine

Signed-off-by: Leonardo Strozzi <laps15@inf.ufpr.br>
  • Loading branch information...
laps15 committed Jun 29, 2018
1 parent 36ceaee commit 7dc44b2ea945538dc456cdcb887cbf65f6bed395
@@ -43,7 +43,6 @@ public function indexAction()
'type' => 'engines',
])
);
$html = '';
/**
* Did the user request information about a certain storage engine?
@@ -56,24 +55,36 @@ public function indexAction()
]);
} else {
$engine = StorageEngine::getEngine($_REQUEST['engine']);
$page = isset($_REQUEST['page']) ? $_REQUEST['page'] : '';
$pageOutput = ! empty($page) ? $engine->getPage($page) : '';
/**
* Displays details about a given Storage Engine
*/
$html = $this->template->render('server/engines/show_engine', [
'title' => $engine->getTitle(),
'help_page' => $engine->getMysqlHelpPage(),
'comment' => $engine->getComment(),
'info_pages' => $engine->getInfoPages(),
'support' => $engine->getSupportInformationMessage(),
'variables' => $engine->getHtmlVariables(),
'page_output' => $pageOutput,
'page' => $page,
'engine' => $_REQUEST['engine'],
]);
$html = $this->_getHtmlForShowEngine($engine);
}
$this->response->addHTML($html);
}
/**
* Returns HTML code for engine inspect
*
* @param StorageEngine $engine engine beeing inspected
*
* @return void
*/
private function _getHtmlForShowEngine(StorageEngine $engine):string
{
$page = isset($_REQUEST['page']) ? $_REQUEST['page'] : '';
$pageOutput = ! empty($page) ? $engine->getPage($page) : '';
/**
* Displays details about a given Storage Engine
*/
return $this->template->render('server/engines/show_engine', [
'title' => $engine->getTitle(),
'help_page' => $engine->getMysqlHelpPage(),
'comment' => $engine->getComment(),
'info_pages' => $engine->getInfoPages(),
'support' => $engine->getSupportInformationMessage(),
'variables' => $engine->getHtmlVariables(),
'page_output' => $pageOutput,
'page' => $page,
'engine' => $_REQUEST['engine'],
]);
}
}
@@ -47,28 +47,26 @@ protected function setUp()
$GLOBALS['db'] = 'db';
$GLOBALS['table'] = 'table';
$GLOBALS['PMA_PHP_SELF'] = 'index.php';
$GLOBALS['cfg']['Server'] = array('DisableIS' => false);
$this->container = Container::getDefaultContainer();
$this->container->set('PhpMyAdmin\Response', new ResponseStub());
$this->container->alias('response', 'PhpMyAdmin\Response');
}
/**
* Tests for _getHtmlForAllServerEngines() method
* Tests for indexAction() method
*
* @return void
*/
public function testGetHtmlForAllServerEngines()
public function testHtmlForAllServerEngines()
{
$class = new ReflectionClass('\PhpMyAdmin\Controllers\Server\ServerEnginesController');
$method = $class->getMethod('_getHtmlForAllServerEngines');
$method->setAccessible(true);
$ctrl = new ServerEnginesController(
$class = new ServerEnginesController(
$this->container->get('response'),
$this->container->get('dbi')
);
$html = $method->invoke($ctrl);
$class->indexAction();
$html = $this->container->get('response')->getHTMLResult();
//validate 1: Item header
$this->assertContains(
@@ -114,20 +112,21 @@ public function testGetHtmlForAllServerEngines()
*
* @return void
*/
public function testGetHtmlForServerEngine()
public function testHtmlForServerEngine()
{
$_REQUEST['engine'] = "Pbxt";
$_REQUEST['page'] = "page";
$class = new ReflectionClass('PhpMyAdmin\Controllers\Server\ServerEnginesController');
$method = $class->getMethod('_getHtmlForShowEngine');
$method->setAccessible(true);
//Mock DBI
$dbi = $this->getMockBuilder('PhpMyAdmin\DatabaseInterface')
->disableOriginalConstructor()
->getMock();
$GLOBALS['dbi'] = $dbi;
$class = new ReflectionClass('\PhpMyAdmin\Controllers\Server\ServerEnginesController');
$method = $class->getMethod('_getHtmlForServerEngine');
$method->setAccessible(true);
$engine_plugin = StorageEngine::getEngine("Pbxt");
$ctrl = new ServerEnginesController(
$this->container->get('response'),

0 comments on commit 7dc44b2

Please sign in to comment.
You can’t perform that action at this time.