From f580c8fb9411cfd2937f94d3cfdee121f265bb74 Mon Sep 17 00:00:00 2001 From: minhaz Date: Tue, 4 Mar 2014 00:49:57 +0530 Subject: [PATCH 1/4] Correcting test for Config.class.php The constant used to load config file i.e CONFIG_FILE was config.inc.php while it did not exist in code base, which was causing two similar test-case with no config-file. CONFIG_FILE has been replaced with "config.sample.inc.php" which can be tested for. Signed-off-by: A V Minhaz --- test/classes/PMA_Config_test.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/test/classes/PMA_Config_test.php b/test/classes/PMA_Config_test.php index 4c9af24c30..e75d698aee 100644 --- a/test/classes/PMA_Config_test.php +++ b/test/classes/PMA_Config_test.php @@ -46,7 +46,7 @@ class PMA_ConfigTest extends PHPUnit_Framework_TestCase $this->object = new PMA_Config; $GLOBALS['server'] = 0; $_SESSION['is_git_revision'] = true; - $GLOBALS['PMA_Config'] = new PMA_Config(CONFIG_FILE); + $GLOBALS['PMA_Config'] = new PMA_Config("./config.sample.inc.php"); } /** @@ -958,7 +958,9 @@ class PMA_ConfigTest extends PHPUnit_Framework_TestCase //load file permissions for the current permissions file $perms = @fileperms($GLOBALS['PMA_Config']->getSource()); - + //testing for permissions + $this->assertTrue(!($perms === false) && ($perms & 2)); + //if the above assertion is true then applying further assertions if(!($perms === false) && ($perms & 2)) { $this->assertFalse($GLOBALS['PMA_Config']->get('PMA_IS_WINDOWS') == 0); From 586804986731bee2c4c4185deba391f65b886d9d Mon Sep 17 00:00:00 2001 From: minhaz Date: Wed, 5 Mar 2014 23:01:05 +0530 Subject: [PATCH 2/4] Update PMA_Config_test.php As per discussion in mailing list, another object is used to check for file permission while global object remains same! Signed-off-by: A V Minhaz --- test/classes/PMA_Config_test.php | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/test/classes/PMA_Config_test.php b/test/classes/PMA_Config_test.php index e75d698aee..f06eeffd54 100644 --- a/test/classes/PMA_Config_test.php +++ b/test/classes/PMA_Config_test.php @@ -34,6 +34,13 @@ class PMA_ConfigTest extends PHPUnit_Framework_TestCase * @var PMA_Config */ protected $object; + + /** + * @var object to test file permission + */ + protected $permTestObj; + + /** * Sets up the fixture, for example, opens a network connection. @@ -46,7 +53,10 @@ class PMA_ConfigTest extends PHPUnit_Framework_TestCase $this->object = new PMA_Config; $GLOBALS['server'] = 0; $_SESSION['is_git_revision'] = true; - $GLOBALS['PMA_Config'] = new PMA_Config("./config.sample.inc.php"); + $GLOBALS['PMA_Config'] = new PMA_Config(CONFIG_FILE); + + //for testing file permissions + $this->permTestObj = new PMA_Config("./config.sample.inc.php"); } /** @@ -58,6 +68,7 @@ class PMA_ConfigTest extends PHPUnit_Framework_TestCase protected function tearDown() { unset($this->object); + unset($this->permTestObj); } /** @@ -957,13 +968,13 @@ class PMA_ConfigTest extends PHPUnit_Framework_TestCase $this->assertFalse(!($perms === false) && ($perms & 2)); //load file permissions for the current permissions file - $perms = @fileperms($GLOBALS['PMA_Config']->getSource()); + $perms = @fileperms($this->permTestObj->getSource()); //testing for permissions $this->assertTrue(!($perms === false) && ($perms & 2)); //if the above assertion is true then applying further assertions if(!($perms === false) && ($perms & 2)) { - $this->assertFalse($GLOBALS['PMA_Config']->get('PMA_IS_WINDOWS') == 0); + $this->assertFalse($this->permTestObj->get('PMA_IS_WINDOWS') == 0); } } From 13baf4ea1806d3abe1f61d74590118f4d65e934b Mon Sep 17 00:00:00 2001 From: minhaz Date: Thu, 6 Mar 2014 00:44:37 +0530 Subject: [PATCH 3/4] testing permission for test object Signed-off-by: A V Minhaz --- test/classes/PMA_Config_test.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/classes/PMA_Config_test.php b/test/classes/PMA_Config_test.php index f06eeffd54..8d454592d6 100644 --- a/test/classes/PMA_Config_test.php +++ b/test/classes/PMA_Config_test.php @@ -969,6 +969,11 @@ class PMA_ConfigTest extends PHPUnit_Framework_TestCase //load file permissions for the current permissions file $perms = @fileperms($this->permTestObj->getSource()); + + //todo: remove this line after one test run + //for testing purpose + var_dump($perms); + //testing for permissions $this->assertTrue(!($perms === false) && ($perms & 2)); From 06e7aa4c2685c7e9286f15bb623841f06d60a80c Mon Sep 17 00:00:00 2001 From: minhaz Date: Thu, 6 Mar 2014 12:08:48 +0530 Subject: [PATCH 4/4] Test case for Config.class.php fixed Testcases modified: Two test cases - one for no config file , other with config file Signed-off-by: A V Minhaz --- test/classes/PMA_Config_test.php | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/test/classes/PMA_Config_test.php b/test/classes/PMA_Config_test.php index 8d454592d6..2f967fcb1a 100644 --- a/test/classes/PMA_Config_test.php +++ b/test/classes/PMA_Config_test.php @@ -969,15 +969,10 @@ class PMA_ConfigTest extends PHPUnit_Framework_TestCase //load file permissions for the current permissions file $perms = @fileperms($this->permTestObj->getSource()); - - //todo: remove this line after one test run - //for testing purpose - var_dump($perms); - //testing for permissions - $this->assertTrue(!($perms === false) && ($perms & 2)); + $this->assertFalse(!($perms === false) && ($perms & 2)); - //if the above assertion is true then applying further assertions + //if the above assertion is false then applying further assertions if(!($perms === false) && ($perms & 2)) { $this->assertFalse($this->permTestObj->get('PMA_IS_WINDOWS') == 0); }