From 2bda1477b828e4a5612f5d887aa5885aa3ae609b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maur=C3=ADcio=20Meneghini=20Fauth?= Date: Wed, 20 Dec 2017 20:00:35 -0200 Subject: [PATCH 01/11] Fix AuthenticationConfigTest dependencies MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Maurício Meneghini Fauth --- test/classes/Plugins/Auth/AuthenticationConfigTest.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test/classes/Plugins/Auth/AuthenticationConfigTest.php b/test/classes/Plugins/Auth/AuthenticationConfigTest.php index c8cd6ffa7d..7ac788c782 100644 --- a/test/classes/Plugins/Auth/AuthenticationConfigTest.php +++ b/test/classes/Plugins/Auth/AuthenticationConfigTest.php @@ -26,11 +26,14 @@ class AuthenticationConfigTest extends PmaTestCase * * @return void */ - function setup() + protected function setUp() { $GLOBALS['PMA_Config'] = new Config(); $GLOBALS['PMA_Config']->enableBc(); $GLOBALS['server'] = 0; + $GLOBALS['db'] = 'db'; + $GLOBALS['table'] = 'table'; + $GLOBALS['PMA_PHP_SELF'] = 'index.php'; $GLOBALS['token_provided'] = true; $GLOBALS['token_mismatch'] = false; $this->object = new AuthenticationConfig(); From f737df8f958f6c9bf2b8468ace2eacd772ec4382 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maur=C3=ADcio=20Meneghini=20Fauth?= Date: Wed, 20 Dec 2017 20:03:41 -0200 Subject: [PATCH 02/11] Fix AuthenticationHttpTest global dependencies MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Maurício Meneghini Fauth --- test/classes/Plugins/Auth/AuthenticationHttpTest.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test/classes/Plugins/Auth/AuthenticationHttpTest.php b/test/classes/Plugins/Auth/AuthenticationHttpTest.php index 095c40231f..4fc2338d51 100644 --- a/test/classes/Plugins/Auth/AuthenticationHttpTest.php +++ b/test/classes/Plugins/Auth/AuthenticationHttpTest.php @@ -28,12 +28,15 @@ class AuthenticationHttpTest extends PmaTestCase * * @return void */ - function setup() + protected function setUp() { $GLOBALS['PMA_Config'] = new Config(); $GLOBALS['PMA_Config']->enableBc(); $GLOBALS['cfg']['Servers'] = array(); $GLOBALS['server'] = 0; + $GLOBALS['db'] = 'db'; + $GLOBALS['table'] = 'table'; + $GLOBALS['PMA_PHP_SELF'] = 'index.php'; $GLOBALS['lang'] = "en"; $GLOBALS['text_dir'] = "ltr"; $GLOBALS['token_provided'] = true; From 364ed60ee330ebefea71f516e7cea9b66bc84067 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maur=C3=ADcio=20Meneghini=20Fauth?= Date: Wed, 20 Dec 2017 20:05:32 -0200 Subject: [PATCH 03/11] Fix AuthenticationSignonTest global dependencies MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Maurício Meneghini Fauth --- test/classes/Plugins/Auth/AuthenticationSignonTest.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test/classes/Plugins/Auth/AuthenticationSignonTest.php b/test/classes/Plugins/Auth/AuthenticationSignonTest.php index f16e548b35..262dd2301e 100644 --- a/test/classes/Plugins/Auth/AuthenticationSignonTest.php +++ b/test/classes/Plugins/Auth/AuthenticationSignonTest.php @@ -25,11 +25,14 @@ class AuthenticationSignonTest extends PmaTestCase * * @return void */ - function setup() + protected function setUp() { $GLOBALS['PMA_Config'] = new Config(); $GLOBALS['PMA_Config']->enableBc(); $GLOBALS['server'] = 0; + $GLOBALS['db'] = 'db'; + $GLOBALS['table'] = 'table'; + $GLOBALS['PMA_PHP_SELF'] = 'index.php'; $this->object = new AuthenticationSignon(); } From 34ea196411f2ae307cd10f6d8864212565680123 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maur=C3=ADcio=20Meneghini=20Fauth?= Date: Wed, 20 Dec 2017 20:14:42 -0200 Subject: [PATCH 04/11] Fix ImportCsvTest global dependencies MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Maurício Meneghini Fauth --- test/classes/Plugins/Import/ImportCsvTest.php | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/test/classes/Plugins/Import/ImportCsvTest.php b/test/classes/Plugins/Import/ImportCsvTest.php index de3858dbfb..f74f4ae513 100644 --- a/test/classes/Plugins/Import/ImportCsvTest.php +++ b/test/classes/Plugins/Import/ImportCsvTest.php @@ -11,12 +11,6 @@ use PhpMyAdmin\Plugins\Import\ImportCsv; use PhpMyAdmin\Tests\PmaTestCase; use PhpMyAdmin\Theme; -/** - * we must set $GLOBALS['server'] here - * since 'check_user_privileges.inc.php' will use it globally - */ -$GLOBALS['server'] = 0; - /** * Tests for PhpMyAdmin\Plugins\Import\ImportCsv class * @@ -39,6 +33,7 @@ class ImportCsvTest extends PmaTestCase */ protected function setUp() { + $GLOBALS['server'] = 0; $GLOBALS['plugin_param'] = "csv"; $this->object = new ImportCsv(); From af07ea1b3e5a80eb91a7e09313b626753d551f0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maur=C3=ADcio=20Meneghini=20Fauth?= Date: Wed, 20 Dec 2017 22:18:26 -0200 Subject: [PATCH 05/11] Fix ImportLdiTest global dependencies MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Maurício Meneghini Fauth --- test/classes/Plugins/Import/ImportLdiTest.php | 52 +++++++++++-------- 1 file changed, 29 insertions(+), 23 deletions(-) diff --git a/test/classes/Plugins/Import/ImportLdiTest.php b/test/classes/Plugins/Import/ImportLdiTest.php index 8157080c25..cbd8721505 100644 --- a/test/classes/Plugins/Import/ImportLdiTest.php +++ b/test/classes/Plugins/Import/ImportLdiTest.php @@ -10,13 +10,6 @@ use PhpMyAdmin\File; use PhpMyAdmin\Plugins\Import\ImportLdi; use PhpMyAdmin\Tests\PmaTestCase; -/* - * we must set $GLOBALS['server'] here - * since 'check_user_privileges.inc.php' will use it globally - */ -$GLOBALS['server'] = 0; -$GLOBALS['plugin_param'] = "table"; - /** * Tests for PhpMyAdmin\Plugins\Import\ImportLdi class * @@ -29,6 +22,12 @@ class ImportLdiTest extends PmaTestCase */ protected $object; + /** + * @var \PhpMyAdmin\DatabaseInterface + * @access protected + */ + protected $dbi; + /** * Sets up the fixture, for example, opens a network connection. * This method is called before a test is executed. @@ -39,6 +38,8 @@ class ImportLdiTest extends PmaTestCase protected function setUp() { //setting + $GLOBALS['server'] = 0; + $GLOBALS['plugin_param'] = 'table'; $GLOBALS['finished'] = false; $GLOBALS['read_limit'] = 100000000; $GLOBALS['offset'] = 0; @@ -63,24 +64,10 @@ class ImportLdiTest extends PmaTestCase $GLOBALS['table'] = "phpmyadmintest"; //Mock DBI - $dbi = $this->getMockBuilder('PhpMyAdmin\DatabaseInterface') + $this->dbi = $this->getMockBuilder('PhpMyAdmin\DatabaseInterface') ->disableOriginalConstructor() ->getMock(); - - $dbi->expects($this->any())->method('tryQuery') - ->will($this->returnValue(true)); - - $dbi->expects($this->any())->method('numRows') - ->will($this->returnValue(10)); - - $fetchRowResult = array("ON"); - $dbi->expects($this->any())->method('fetchRow') - ->will($this->returnValue($fetchRowResult)); - - $dbi->expects($this->any())->method('escapeString') - ->will($this->returnArgument(0)); - - $GLOBALS['dbi'] = $dbi; + $GLOBALS['dbi'] = $this->dbi; $this->object = new ImportLdi(); } @@ -126,6 +113,17 @@ class ImportLdiTest extends PmaTestCase */ public function testGetPropertiesAutoLdi() { + $this->dbi->expects($this->any())->method('tryQuery') + ->will($this->returnValue(true)); + $this->dbi->expects($this->any())->method('numRows') + ->will($this->returnValue(10)); + + $fetchRowResult = array("ON"); + $this->dbi->expects($this->any())->method('fetchRow') + ->will($this->returnValue($fetchRowResult)); + + $GLOBALS['dbi'] = $this->dbi; + $GLOBALS['cfg']['Import']['ldi_local_option'] = 'auto'; $this->object = new ImportLdi(); $properties = $this->object->getProperties(); @@ -156,6 +154,10 @@ class ImportLdiTest extends PmaTestCase global $sql_query, $sql_query_disabled; $sql_query_disabled = false; + $this->dbi->expects($this->any())->method('escapeString') + ->will($this->returnArgument(0)); + $GLOBALS['dbi'] = $this->dbi; + //Test function called $this->object->doImport(); @@ -215,6 +217,10 @@ class ImportLdiTest extends PmaTestCase global $sql_query, $sql_query_disabled; $sql_query_disabled = false; + $this->dbi->expects($this->any())->method('escapeString') + ->will($this->returnArgument(0)); + $GLOBALS['dbi'] = $this->dbi; + $ldi_local_option = true; $ldi_replace = true; $ldi_ignore = true; From ba5118f6cdbd41ea7a5efc85f45088048fd7b4ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maur=C3=ADcio=20Meneghini=20Fauth?= Date: Wed, 20 Dec 2017 22:34:43 -0200 Subject: [PATCH 06/11] Fix Rte/EventsTest global dependencies MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Maurício Meneghini Fauth --- test/classes/Rte/EventsTest.php | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/test/classes/Rte/EventsTest.php b/test/classes/Rte/EventsTest.php index 70914970bf..0b9f9e5b79 100644 --- a/test/classes/Rte/EventsTest.php +++ b/test/classes/Rte/EventsTest.php @@ -23,13 +23,24 @@ class EventsTest extends TestCase * * @return void */ - public function setUp() + protected function setUp() { - $GLOBALS['tear_down']['server'] = false; - if (! isset($GLOBALS['cfg']['ServerDefault'])) { - $GLOBALS['cfg']['ServerDefault'] = ''; - $GLOBALS['tear_down']['server'] = true; - } + $GLOBALS['server'] = 0; + $GLOBALS['db'] = 'db'; + $GLOBALS['table'] = 'table'; + $GLOBALS['PMA_PHP_SELF'] = 'index.php'; + $GLOBALS['cfg']['AllowThirdPartyFraming'] = false; + $GLOBALS['cfg']['SendErrorReports'] = 'ask'; + $GLOBALS['cfg']['DefaultTabDatabase'] = 'structure'; + $GLOBALS['cfg']['ShowDatabasesNavigationAsTree'] = true; + $GLOBALS['cfg']['DefaultTabTable'] = 'browse'; + $GLOBALS['cfg']['NavigationTreeDefaultTabTable'] = 'structure'; + $GLOBALS['cfg']['NavigationTreeDefaultTabTable2'] = ''; + $GLOBALS['cfg']['LimitChars'] = 50; + $GLOBALS['cfg']['Confirm'] = true; + $GLOBALS['cfg']['LoginCookieValidity'] = 1440; + $GLOBALS['cfg']['ServerDefault'] = ''; + $GLOBALS['tear_down']['server'] = true; } /** From f7248e781ff94dc72d7696d337a5b3534a4c2b2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maur=C3=ADcio=20Meneghini=20Fauth?= Date: Wed, 20 Dec 2017 22:46:01 -0200 Subject: [PATCH 07/11] Fix Rte/RoutinesTest global dependencies MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Maurício Meneghini Fauth --- test/classes/Rte/RoutinesTest.php | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/test/classes/Rte/RoutinesTest.php b/test/classes/Rte/RoutinesTest.php index b0ff780e04..f624ef50a5 100644 --- a/test/classes/Rte/RoutinesTest.php +++ b/test/classes/Rte/RoutinesTest.php @@ -25,18 +25,29 @@ class RoutinesTest extends TestCase * * @return void */ - public function setUp() + protected function setUp() { - global $cfg; - - $cfg['ShowFunctionFields'] = false; - $cfg['ServerDefault'] = 1; - $cfg['DefaultFunctions']['FUNC_NUMBER'] = ''; - $cfg['DefaultFunctions']['FUNC_DATE'] = ''; - $cfg['DefaultFunctions']['FUNC_SPATIAL'] = 'GeomFromText'; - $GLOBALS['server'] = 0; - $GLOBALS['pmaThemePath'] = $GLOBALS['PMA_Theme']->getPath(); + $GLOBALS['cfg']['ShowFunctionFields'] = false; + $GLOBALS['cfg']['ServerDefault'] = 1; + $GLOBALS['cfg']['DefaultFunctions']['FUNC_NUMBER'] = ''; + $GLOBALS['cfg']['DefaultFunctions']['FUNC_DATE'] = ''; + $GLOBALS['cfg']['DefaultFunctions']['FUNC_SPATIAL'] = 'GeomFromText'; + $GLOBALS['cfg']['AllowThirdPartyFraming'] = false; + $GLOBALS['cfg']['SendErrorReports'] = 'ask'; + $GLOBALS['cfg']['DefaultTabDatabase'] = 'structure'; + $GLOBALS['cfg']['ShowDatabasesNavigationAsTree'] = true; + $GLOBALS['cfg']['DefaultTabTable'] = 'browse'; + $GLOBALS['cfg']['NavigationTreeDefaultTabTable'] = 'structure'; + $GLOBALS['cfg']['NavigationTreeDefaultTabTable2'] = ''; + $GLOBALS['cfg']['LimitChars'] = 50; + $GLOBALS['cfg']['Confirm'] = true; + $GLOBALS['cfg']['LoginCookieValidity'] = 1440; $GLOBALS['cfg']['Server']['DisableIS'] = false; + $GLOBALS['server'] = 0; + $GLOBALS['db'] = 'db'; + $GLOBALS['table'] = 'table'; + $GLOBALS['PMA_PHP_SELF'] = 'index.php'; + $GLOBALS['pmaThemePath'] = $GLOBALS['PMA_Theme']->getPath(); } /** From 6a4c5d379ce45808875ad8fbebff346c9422f4c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maur=C3=ADcio=20Meneghini=20Fauth?= Date: Wed, 20 Dec 2017 22:53:05 -0200 Subject: [PATCH 08/11] Fix Rte/TriggersTest global dependencies MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Maurício Meneghini Fauth --- test/classes/Rte/TriggersTest.php | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/test/classes/Rte/TriggersTest.php b/test/classes/Rte/TriggersTest.php index 9e100bc02e..1c4b9f60c5 100644 --- a/test/classes/Rte/TriggersTest.php +++ b/test/classes/Rte/TriggersTest.php @@ -23,11 +23,23 @@ class TriggersTest extends TestCase * * @return void */ - public function setUp() + protected function setUp() { $GLOBALS['cfg']['ServerDefault'] = ''; - $GLOBALS['cfg']['DBG']['sql'] = false; + $GLOBALS['cfg']['AllowThirdPartyFraming'] = false; + $GLOBALS['cfg']['SendErrorReports'] = 'ask'; + $GLOBALS['cfg']['DefaultTabDatabase'] = 'structure'; + $GLOBALS['cfg']['ShowDatabasesNavigationAsTree'] = true; + $GLOBALS['cfg']['DefaultTabTable'] = 'browse'; + $GLOBALS['cfg']['NavigationTreeDefaultTabTable'] = 'structure'; + $GLOBALS['cfg']['NavigationTreeDefaultTabTable2'] = ''; + $GLOBALS['cfg']['LimitChars'] = 50; + $GLOBALS['cfg']['Confirm'] = true; + $GLOBALS['cfg']['LoginCookieValidity'] = 1440; + $GLOBALS['cfg']['NaturalOrder'] = false; $GLOBALS['db'] = 'pma_test'; + $GLOBALS['table'] = 'table'; + $GLOBALS['PMA_PHP_SELF'] = 'index.php'; } /** From 435d8926e8ff3880fc4501b9a74185bc3425b13c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maur=C3=ADcio=20Meneghini=20Fauth?= Date: Wed, 20 Dec 2017 22:56:48 -0200 Subject: [PATCH 09/11] Fix Server/PrivilegesTest global dependency MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Maurício Meneghini Fauth --- test/classes/Server/PrivilegesTest.php | 1 + 1 file changed, 1 insertion(+) diff --git a/test/classes/Server/PrivilegesTest.php b/test/classes/Server/PrivilegesTest.php index d3b9d8c16d..65f123e5fe 100644 --- a/test/classes/Server/PrivilegesTest.php +++ b/test/classes/Server/PrivilegesTest.php @@ -68,6 +68,7 @@ class PrivilegesTest extends TestCase $GLOBALS['PMA_PHP_SELF'] = Core::getenv('PHP_SELF'); $GLOBALS['pmaThemeImage'] = 'image'; $GLOBALS['server'] = 1; + $GLOBALS['db'] = 'db'; $GLOBALS['hostname'] = "hostname"; $GLOBALS['username'] = "username"; $GLOBALS['text_dir'] = "text_dir"; From d185a1c7f58d6ed675e8016c4ebeeb751a9cd8bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maur=C3=ADcio=20Meneghini=20Fauth?= Date: Wed, 20 Dec 2017 22:59:48 -0200 Subject: [PATCH 10/11] Fix Server/UsersTest global dependency MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Maurício Meneghini Fauth --- test/classes/Server/UsersTest.php | 1 + 1 file changed, 1 insertion(+) diff --git a/test/classes/Server/UsersTest.php b/test/classes/Server/UsersTest.php index a1954fef38..af7b741b18 100644 --- a/test/classes/Server/UsersTest.php +++ b/test/classes/Server/UsersTest.php @@ -27,6 +27,7 @@ class UsersTest extends TestCase public function testGetHtmlForSubMenusOnUsersPage() { $GLOBALS['server'] = 1; + $GLOBALS['cfg']['ServerDefault'] = 1; $GLOBALS['cfg']['Server']['DisableIS'] = false; $html = Users::getHtmlForSubMenusOnUsersPage('server_privileges.php'); From 446e684035bb167bc0f66466b42fb83082ac2a0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maur=C3=ADcio=20Meneghini=20Fauth?= Date: Wed, 20 Dec 2017 23:01:44 -0200 Subject: [PATCH 11/11] Fix Setup/FormProcessingTest global dependencies MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Maurício Meneghini Fauth --- test/classes/Setup/FormProcessingTest.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/classes/Setup/FormProcessingTest.php b/test/classes/Setup/FormProcessingTest.php index c568e22204..9ba6f8af5e 100644 --- a/test/classes/Setup/FormProcessingTest.php +++ b/test/classes/Setup/FormProcessingTest.php @@ -25,6 +25,9 @@ class FormProcessingTest extends PmaTestCase public function setUp() { $GLOBALS['server'] = 1; + $GLOBALS['db'] = 'db'; + $GLOBALS['table'] = 'table'; + $GLOBALS['PMA_PHP_SELF'] = 'index.php'; $GLOBALS['cfg']['ServerDefault'] = 1; }