Fix tests for server_engine

Signed-off-by: Leonardo Strozzi <laps15@inf.ufpr.br>
This commit is contained in:
Leonardo Strozzi 2018-06-29 20:14:02 -03:00
parent 36ceaee55a
commit 7dc44b2ea9
2 changed files with 41 additions and 31 deletions

View File

@ -43,7 +43,6 @@ class ServerEnginesController extends Controller
'type' => 'engines',
])
);
$html = '';
/**
* Did the user request information about a certain storage engine?
@ -56,24 +55,36 @@ class ServerEnginesController extends Controller
]);
} 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'],
]);
}
}

View File

@ -47,6 +47,7 @@ class ServerEnginesControllerTest extends PmaTestCase
$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());
@ -54,21 +55,18 @@ class ServerEnginesControllerTest extends PmaTestCase
}
/**
* 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 @@ class ServerEnginesControllerTest extends PmaTestCase
*
* @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'),