Skip to content

Commit

Permalink
Fix some tests when running them in isolation
Browse files Browse the repository at this point in the history
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
  • Loading branch information
MauricioFauth committed Dec 27, 2019
1 parent d10b384 commit 3f522e8
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 17 deletions.
23 changes: 11 additions & 12 deletions libraries/classes/Header.php
Expand Up @@ -125,18 +125,18 @@ class Header
*/
public function __construct()
{
global $db, $table;

$this->template = new Template();

$this->_isEnabled = true;
$this->_isAjax = false;
$this->_bodyId = '';
$this->_title = '';
$this->_console = new Console();
$db = strlen($GLOBALS['db']) ? $GLOBALS['db'] : '';
$table = strlen($GLOBALS['table']) ? $GLOBALS['table'] : '';
$this->_menu = new Menu(
$db,
$table
$db ?? '',
$table ?? ''
);
$this->_menuEnabled = true;
$this->_warningsEnabled = true;
Expand Down Expand Up @@ -226,8 +226,8 @@ private function _addDefaultScripts(): void
*/
public function getJsParams(): array
{
$db = strlen($GLOBALS['db']) ? $GLOBALS['db'] : '';
$table = strlen($GLOBALS['table']) ? $GLOBALS['table'] : '';
global $db, $table;

$pftext = $_SESSION['tmpval']['pftext'] ?? '';

$params = [
Expand All @@ -238,8 +238,8 @@ public function getJsParams(): array
),
'lang' => $GLOBALS['lang'],
'server' => $GLOBALS['server'],
'table' => $table,
'db' => $db,
'table' => $table ?? '',
'db' => $db ?? '',
'token' => $_SESSION[' PMA_token '],
'text_dir' => $GLOBALS['text_dir'],
'show_databases_navigation_as_tree' => $GLOBALS['cfg']['ShowDatabasesNavigationAsTree'],
Expand Down Expand Up @@ -400,6 +400,8 @@ public function enablePrintView(): void
*/
public function getDisplay(): string
{
global $db, $table;

if (! $this->_headerIsSent) {
if (! $this->_isAjax && $this->_isEnabled) {
$this->sendHttpHeaders();
Expand Down Expand Up @@ -451,10 +453,7 @@ public function getDisplay(): string
$messages = $this->getMessage();
}
if ($this->_isEnabled && empty($_REQUEST['recent_table'])) {
$recentTable = $this->_addRecentTable(
$GLOBALS['db'],
$GLOBALS['table']
);
$recentTable = $this->_addRecentTable($db, $table);
}
return $this->template->render('header', [
'is_ajax' => $this->_isAjax,
Expand Down
5 changes: 0 additions & 5 deletions test/classes/Controllers/Server/EnginesControllerTest.php
Expand Up @@ -95,11 +95,6 @@ public function testIndex(): void
*/
public function testShow(): void
{
$dbi = $this->getMockBuilder(DatabaseInterface::class)
->disableOriginalConstructor()
->getMock();
$GLOBALS['dbi'] = $dbi;

$controller = new EnginesController(
Response::getInstance(),
$GLOBALS['dbi'],
Expand Down
4 changes: 4 additions & 0 deletions test/classes/Stubs/DbiDummy.php
Expand Up @@ -636,6 +636,10 @@ private function init(): void
[''],
],
],
[
'query' => 'SHOW GLOBAL VARIABLES ;',
'result' => [],
],
[
'query' => 'SHOW GLOBAL VARIABLES LIKE \'innodb_file_per_table\';',
'result' => [
Expand Down

0 comments on commit 3f522e8

Please sign in to comment.