Skip to content

Commit

Permalink
Fix test cases after backupGlobals = false
Browse files Browse the repository at this point in the history
Signed-off-by: William Desportes <williamdes@wdes.fr>
  • Loading branch information
williamdes committed May 21, 2020
1 parent a7490fc commit 8f7d3d1
Show file tree
Hide file tree
Showing 103 changed files with 236 additions and 1 deletion.
5 changes: 5 additions & 0 deletions test/classes/AbstractTestCase.php
Expand Up @@ -125,6 +125,11 @@ protected function setProxySettings(): void
// phpcs:enable
}

protected function setUpEnv(): void
{
require ROOT_PATH . 'test/bootstrap-dist.php';
}

/**
* Desctroys the environment built for the test.
* Clean all variables
Expand Down
2 changes: 2 additions & 0 deletions test/classes/AdvisorTest.php
Expand Up @@ -147,6 +147,8 @@ public function testAdvisorTimespanFormat()
*/
public function testAddRule($rule, $expected, $error): void
{
parent::loadDefaultConfig();
parent::setLanguage();
$advisor = new Advisor($GLOBALS['dbi'], new ExpressionLanguage());
$parseResult = $advisor->parseRulesFile(Advisor::GENERIC_RULES_FILE);
$this->assertEquals($parseResult['errors'], []);
Expand Down
1 change: 1 addition & 0 deletions test/classes/CharsetsTest.php
Expand Up @@ -17,6 +17,7 @@ class CharsetsTest extends AbstractTestCase
protected function setUp(): void
{
parent::setUp();
parent::setUpEnv();
$GLOBALS['cfg']['DBG']['sql'] = false;
$GLOBALS['cfg']['Server']['DisableIS'] = false;
}
Expand Down
1 change: 1 addition & 0 deletions test/classes/Config/ConfigFileTest.php
Expand Up @@ -39,6 +39,7 @@ class ConfigFileTest extends PmaTestCase
protected function setUp(): void
{
parent::setUp();
parent::loadDefaultConfig();
$GLOBALS['server'] = 1;
$this->object = new ConfigFile();
}
Expand Down
1 change: 1 addition & 0 deletions test/classes/Config/FormDisplayTemplateTest.php
Expand Up @@ -27,6 +27,7 @@ class FormDisplayTemplateTest extends AbstractTestCase
protected function setUp(): void
{
parent::setUp();
parent::setLanguage();
$this->config = new Config();
$this->formDisplayTemplate = new FormDisplayTemplate($this->config);
}
Expand Down
2 changes: 2 additions & 0 deletions test/classes/Config/FormDisplayTest.php
Expand Up @@ -31,6 +31,8 @@ class FormDisplayTest extends PmaTestCase
protected function setUp(): void
{
parent::setUp();
parent::setTheme();
parent::loadDefaultConfig();
$GLOBALS['pmaThemePath'] = $GLOBALS['PMA_Theme']->getPath();
$GLOBALS['PMA_Config'] = new Config();
$GLOBALS['server'] = 0;
Expand Down
2 changes: 2 additions & 0 deletions test/classes/Config/FormTest.php
Expand Up @@ -29,6 +29,8 @@ class FormTest extends PmaTestCase
protected function setUp(): void
{
parent::setUp();
parent::setTheme();
parent::loadDefaultConfig();
$GLOBALS['pmaThemePath'] = $GLOBALS['PMA_Theme']->getPath();
$GLOBALS['PMA_Config'] = new Config();
$GLOBALS['server'] = 0;
Expand Down
1 change: 1 addition & 0 deletions test/classes/Config/Forms/FormListTest.php
Expand Up @@ -18,6 +18,7 @@ class FormListTest extends PmaTestCase
protected function setUp(): void
{
parent::setUp();
parent::loadDefaultConfig();
$GLOBALS['PMA_Config'] = new Config();
$GLOBALS['server'] = 1;
}
Expand Down
1 change: 1 addition & 0 deletions test/classes/Config/PageSettingsTest.php
Expand Up @@ -21,6 +21,7 @@ class PageSettingsTest extends PmaTestCase
protected function setUp(): void
{
parent::setUp();
parent::setLanguage();
$GLOBALS['PMA_Config'] = new Config();
$GLOBALS['PMA_Config']->enableBc();
$GLOBALS['server'] = 1;
Expand Down
1 change: 1 addition & 0 deletions test/classes/ConfigTest.php
Expand Up @@ -56,6 +56,7 @@ class ConfigTest extends PmaTestCase
protected function setUp(): void
{
parent::setUp();
parent::setTheme();
$_SERVER['HTTP_USER_AGENT'] = '';
$this->object = new Config();
$GLOBALS['server'] = 0;
Expand Down
10 changes: 10 additions & 0 deletions test/classes/Controllers/Database/PrivilegesControllerTest.php
Expand Up @@ -12,6 +12,16 @@

class PrivilegesControllerTest extends PmaTestCase
{
/**
* Configures global environment.
*/
protected function setUp(): void
{
parent::setUp();
parent::loadDefaultConfig();
parent::setLanguage();
}

public function testIndex(): void
{
global $dbi, $db, $server, $cfg, $PMA_PHP_SELF, $is_grantuser, $is_createuser;
Expand Down
2 changes: 2 additions & 0 deletions test/classes/Controllers/Database/StructureControllerTest.php
Expand Up @@ -61,6 +61,8 @@ class StructureControllerTest extends PmaTestCase
protected function setUp(): void
{
parent::setUp();
parent::loadDefaultConfig();
$GLOBALS['text_dir'] = 'ltr';
$GLOBALS['server'] = 1;
$GLOBALS['cfg']['Server']['DisableIS'] = false;
$GLOBALS['table'] = 'table';
Expand Down
1 change: 1 addition & 0 deletions test/classes/Controllers/Server/BinlogControllerTest.php
Expand Up @@ -26,6 +26,7 @@ class BinlogControllerTest extends AbstractTestCase
protected function setUp(): void
{
parent::setUp();
$GLOBALS['text_dir'] = 'ltr';
$GLOBALS['PMA_Config'] = new Config();
$GLOBALS['PMA_Config']->enableBc();

Expand Down
1 change: 1 addition & 0 deletions test/classes/Controllers/Server/EnginesControllerTest.php
Expand Up @@ -26,6 +26,7 @@ class EnginesControllerTest extends AbstractTestCase
protected function setUp(): void
{
parent::setUp();
$GLOBALS['text_dir'] = 'ltr';
$GLOBALS['PMA_Config'] = new Config();
$GLOBALS['PMA_Config']->enableBc();

Expand Down
1 change: 1 addition & 0 deletions test/classes/Controllers/Server/PluginsControllerTest.php
Expand Up @@ -25,6 +25,7 @@ class PluginsControllerTest extends AbstractTestCase
protected function setUp(): void
{
parent::setUp();
$GLOBALS['text_dir'] = 'ltr';
$GLOBALS['PMA_Config'] = new Config();
$GLOBALS['PMA_Config']->enableBc();

Expand Down
Expand Up @@ -31,6 +31,7 @@ class AdvisorControllerTest extends AbstractTestCase
protected function setUp(): void
{
parent::setUp();
$GLOBALS['text_dir'] = 'ltr';
$GLOBALS['PMA_Config'] = new Config();
$GLOBALS['PMA_Config']->enableBc();

Expand Down
Expand Up @@ -23,6 +23,7 @@ class MonitorControllerTest extends AbstractTestCase
protected function setUp(): void
{
parent::setUp();
$GLOBALS['text_dir'] = 'ltr';
$GLOBALS['PMA_Config'] = new Config();
$GLOBALS['PMA_Config']->enableBc();

Expand Down
Expand Up @@ -24,6 +24,7 @@ class ProcessesControllerTest extends AbstractTestCase
protected function setUp(): void
{
parent::setUp();
$GLOBALS['text_dir'] = 'ltr';
$GLOBALS['PMA_Config'] = new Config();
$GLOBALS['PMA_Config']->enableBc();

Expand Down
Expand Up @@ -25,6 +25,7 @@ class QueriesControllerTest extends AbstractTestCase
protected function setUp(): void
{
parent::setUp();
$GLOBALS['text_dir'] = 'ltr';
$GLOBALS['PMA_Config'] = new Config();
$GLOBALS['PMA_Config']->enableBc();

Expand Down
Expand Up @@ -21,6 +21,7 @@ class StatusControllerTest extends AbstractTestCase
protected function setUp(): void
{
parent::setUp();
$GLOBALS['text_dir'] = 'ltr';
$GLOBALS['PMA_Config'] = new Config();
$GLOBALS['PMA_Config']->enableBc();

Expand Down
Expand Up @@ -25,6 +25,7 @@ protected function setUp(): void
$GLOBALS['PMA_Config'] = new Config();
$GLOBALS['PMA_Config']->enableBc();

$GLOBALS['text_dir'] = 'ltr';
$GLOBALS['server'] = 1;
$GLOBALS['db'] = 'db';
$GLOBALS['table'] = 'table';
Expand Down
Expand Up @@ -31,6 +31,7 @@ protected function setUp(): void
$GLOBALS['PMA_Config'] = new Config();
$GLOBALS['PMA_Config']->enableBc();

$GLOBALS['text_dir'] = 'ltr';
$GLOBALS['server'] = 1;
$GLOBALS['db'] = 'db';
$GLOBALS['table'] = 'table';
Expand Down
3 changes: 3 additions & 0 deletions test/classes/Controllers/Table/IndexesControllerTest.php
Expand Up @@ -33,12 +33,15 @@ class IndexesControllerTest extends PmaTestCase
protected function setUp(): void
{
parent::setUp();
parent::loadDefaultConfig();

/**
* SET these to avoid undefined index error
*/
$GLOBALS['server'] = 1;
$GLOBALS['db'] = 'db';
$GLOBALS['table'] = 'table';
$GLOBALS['text_dir'] = 'ltr';
$GLOBALS['PMA_PHP_SELF'] = 'index.php';
$GLOBALS['cfg']['Server']['pmadb'] = '';
$GLOBALS['cfg']['Server']['DisableIS'] = false;
Expand Down
11 changes: 11 additions & 0 deletions test/classes/Controllers/Table/PrivilegesControllerTest.php
Expand Up @@ -12,8 +12,19 @@

class PrivilegesControllerTest extends PmaTestCase
{

/**
* Configures global environment.
*/
protected function setUp(): void
{
parent::setUp();
parent::loadDefaultConfig();
}

public function testIndex(): void
{

global $dbi, $db, $table, $server, $cfg, $PMA_PHP_SELF, $is_grantuser, $is_createuser;

$db = 'db';
Expand Down
3 changes: 3 additions & 0 deletions test/classes/Controllers/Table/RelationControllerTest.php
Expand Up @@ -32,9 +32,12 @@ class RelationControllerTest extends PmaTestCase
protected function setUp(): void
{
parent::setUp();
parent::loadDefaultConfig();

$GLOBALS['server'] = 0;
$GLOBALS['db'] = 'db';
$GLOBALS['table'] = 'table';
$GLOBALS['text_dir'] = 'ltr';
$GLOBALS['PMA_PHP_SELF'] = 'index.php';
$GLOBALS['cfg']['Server']['DisableIS'] = false;
//$_SESSION
Expand Down
3 changes: 3 additions & 0 deletions test/classes/Controllers/Table/SearchControllerTest.php
Expand Up @@ -35,6 +35,8 @@ class SearchControllerTest extends PmaTestCase
protected function setUp(): void
{
parent::setUp();
parent::loadDefaultConfig();

/**
* SET these to avoid undefined index error
*/
Expand All @@ -43,6 +45,7 @@ protected function setUp(): void
$GLOBALS['server'] = 1;
$GLOBALS['db'] = 'PMA';
$GLOBALS['table'] = 'PMA_BookMark';
$GLOBALS['text_dir'] = 'ltr';
$GLOBALS['PMA_PHP_SELF'] = 'index.php';
$relation = new Relation($GLOBALS['dbi']);
$GLOBALS['cfgRelation'] = $relation->getRelationsParam();
Expand Down
2 changes: 2 additions & 0 deletions test/classes/Controllers/Table/StructureControllerTest.php
Expand Up @@ -39,6 +39,8 @@ class StructureControllerTest extends PmaTestCase
protected function setUp(): void
{
parent::setUp();
parent::loadDefaultConfig();
$GLOBALS['text_dir'] = 'ltr';
$GLOBALS['server'] = 1;
$GLOBALS['db'] = 'db';
$GLOBALS['table'] = 'table';
Expand Down
Expand Up @@ -24,6 +24,7 @@ class TransformationOverviewControllerTest extends AbstractTestCase
protected function setUp(): void
{
parent::setUp();
$GLOBALS['text_dir'] = 'ltr';
$GLOBALS['PMA_Config'] = new Config();
$GLOBALS['PMA_Config']->enableBc();

Expand Down
2 changes: 2 additions & 0 deletions test/classes/CoreTest.php
Expand Up @@ -30,6 +30,8 @@ class CoreTest extends PmaTestCase
protected function setUp(): void
{
parent::setUp();
parent::loadDefaultConfig();

$GLOBALS['server'] = 0;
$GLOBALS['db'] = '';
$GLOBALS['table'] = '';
Expand Down
1 change: 1 addition & 0 deletions test/classes/CreateAddFieldTest.php
Expand Up @@ -23,6 +23,7 @@ class CreateAddFieldTest extends AbstractTestCase
protected function setUp(): void
{
parent::setUp();
parent::setUpEnv();
$this->createAddField = new CreateAddField($GLOBALS['dbi']);
}

Expand Down
1 change: 1 addition & 0 deletions test/classes/Database/QbeTest.php
Expand Up @@ -30,6 +30,7 @@ class QbeTest extends PmaTestCase
protected function setUp(): void
{
parent::setUp();
parent::setUpEnv();
$GLOBALS['server'] = 0;
$GLOBALS['db'] = 'pma_test';
$this->object = new Qbe(new Relation($GLOBALS['dbi']), new Template(), $GLOBALS['dbi'], 'pma_test');
Expand Down
2 changes: 2 additions & 0 deletions test/classes/Database/RoutinesTest.php
Expand Up @@ -23,6 +23,7 @@ class RoutinesTest extends AbstractTestCase
protected function setUp(): void
{
parent::setUp();
parent::setUpEnv();
$GLOBALS['PMA_Config'] = new Config();
$GLOBALS['PMA_Config']->enableBc();
$GLOBALS['cfg']['Server']['DisableIS'] = false;
Expand All @@ -31,6 +32,7 @@ protected function setUp(): void
$GLOBALS['db'] = 'db';
$GLOBALS['table'] = 'table';
$GLOBALS['PMA_PHP_SELF'] = 'index.php';
$GLOBALS['text_dir'] = 'ltr';

$this->routines = new Routines(
$GLOBALS['dbi'],
Expand Down
2 changes: 2 additions & 0 deletions test/classes/Database/SearchTest.php
Expand Up @@ -29,6 +29,8 @@ class SearchTest extends PmaTestCase
protected function setUp(): void
{
parent::setUp();
parent::loadDefaultConfig();

$GLOBALS['server'] = 0;
$GLOBALS['db'] = 'pma';
$GLOBALS['_POST'] = [];
Expand Down
1 change: 1 addition & 0 deletions test/classes/Database/TriggersTest.php
Expand Up @@ -21,6 +21,7 @@ class TriggersTest extends AbstractTestCase
protected function setUp(): void
{
parent::setUp();
parent::setUpEnv();
$GLOBALS['PMA_Config'] = new Config();
$GLOBALS['PMA_Config']->enableBc();
$GLOBALS['cfg']['Server']['DisableIS'] = false;
Expand Down
1 change: 1 addition & 0 deletions test/classes/DatabaseInterfaceTest.php
Expand Up @@ -27,6 +27,7 @@ class DatabaseInterfaceTest extends PmaTestCase
protected function setUp(): void
{
parent::setUp();
parent::loadDefaultConfig();
$GLOBALS['server'] = 0;
$extension = new DbiDummy();
$this->_dbi = new DatabaseInterface($extension);
Expand Down
1 change: 1 addition & 0 deletions test/classes/Display/ExportTest.php
Expand Up @@ -29,6 +29,7 @@ class ExportTest extends AbstractTestCase
protected function setUp(): void
{
parent::setUp();
parent::setLanguage();
$GLOBALS['PMA_Config'] = new Config();
$GLOBALS['PMA_Config']->enableBc();
$GLOBALS['cfg']['Server']['host'] = 'localhost';
Expand Down
1 change: 1 addition & 0 deletions test/classes/Display/ResultsTest.php
Expand Up @@ -37,6 +37,7 @@ class ResultsTest extends PmaTestCase
protected function setUp(): void
{
parent::setUp();
parent::setLanguage();
$GLOBALS['server'] = 0;
$GLOBALS['db'] = 'db';
$GLOBALS['table'] = 'table';
Expand Down
1 change: 1 addition & 0 deletions test/classes/Engines/InnodbTest.php
Expand Up @@ -26,6 +26,7 @@ class InnodbTest extends PmaTestCase
protected function setUp(): void
{
parent::setUp();
parent::setUpEnv();
$GLOBALS['server'] = 0;
$this->object = new Innodb('innodb');
}
Expand Down
2 changes: 2 additions & 0 deletions test/classes/Engines/PbxtTest.php
Expand Up @@ -28,6 +28,8 @@ class PbxtTest extends PmaTestCase
protected function setUp(): void
{
parent::setUp();
parent::loadDefaultConfig();

$GLOBALS['server'] = 0;
$this->object = new Pbxt('pbxt');
}
Expand Down
4 changes: 3 additions & 1 deletion test/classes/ErrorHandlerTest.php
Expand Up @@ -30,8 +30,11 @@ class ErrorHandlerTest extends PmaTestCase
protected function setUp(): void
{
parent::setUp();
parent::loadDefaultConfig();
$this->object = new ErrorHandler();
$_SESSION['errors'] = [];
$GLOBALS['server'] = 0;
$GLOBALS['cfg']['SendErrorReports'] = 'always';
}

/**
Expand Down Expand Up @@ -167,7 +170,6 @@ public function testGetDispErrorsForDisplayTrue(
*/
public function testCheckSavedErrors()
{
$_SESSION['errors'] = [];

$this->_callProtectedFunction(
'checkSavedErrors',
Expand Down

0 comments on commit 8f7d3d1

Please sign in to comment.