From b7bc51d0583b7d216e663e3e93fed0ba3565fee7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Fri, 27 Apr 2012 09:58:21 +0200 Subject: [PATCH 1/6] Skip setcookie calls while running testsuite --- libraries/Config.class.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libraries/Config.class.php b/libraries/Config.class.php index 1d303eb106..55f22be82e 100644 --- a/libraries/Config.class.php +++ b/libraries/Config.class.php @@ -1565,6 +1565,9 @@ class PMA_Config */ function removeCookie($cookie) { + if (defined('TESTSUITE')) { + return true; + } return setcookie( $cookie, '', @@ -1614,6 +1617,9 @@ class PMA_Config } else { $v = time() + $validity; } + if (defined('TESTSUITE')) { + return true; + } return setcookie( $cookie, $value, From aaaaf3a6eda9d891d778e2e3b1f57eacd26717be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Fri, 27 Apr 2012 10:00:15 +0200 Subject: [PATCH 2/6] Set real value, not unsed global --- test/classes/PMA_Config_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/classes/PMA_Config_test.php b/test/classes/PMA_Config_test.php index edb392a76f..199b3eadbb 100644 --- a/test/classes/PMA_Config_test.php +++ b/test/classes/PMA_Config_test.php @@ -549,7 +549,7 @@ class PMA_ConfigTest extends PHPUnit_Framework_TestCase */ public function testSetUserValue() { - $this->object->setUserValue(null, 'lang', $GLOBALS['lang'], 'en'); + $this->object->setUserValue(null, 'lang', 'cs', 'en'); $this->object->setUserValue("TEST_COOKIE_USER_VAL", '', 'cfg_val_1'); // Remove the following lines when you implement this test. From f1cf8d440abfe093cfdef26132115896802d536b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Fri, 27 Apr 2012 10:11:04 +0200 Subject: [PATCH 3/6] Emulate cookies for tests --- libraries/Config.class.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libraries/Config.class.php b/libraries/Config.class.php index 55f22be82e..18afa03982 100644 --- a/libraries/Config.class.php +++ b/libraries/Config.class.php @@ -1566,6 +1566,9 @@ class PMA_Config function removeCookie($cookie) { if (defined('TESTSUITE')) { + if (isset($_COOKIE[$cookie])) { + unset($_COOKIE[$cookie]); + } return true; } return setcookie( @@ -1618,6 +1621,7 @@ class PMA_Config $v = time() + $validity; } if (defined('TESTSUITE')) { + $_COOKIE[$cookie] = $value; return true; } return setcookie( From 7959520987492ea637622574b17298256ddc0d49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Fri, 27 Apr 2012 10:11:16 +0200 Subject: [PATCH 4/6] Check for variable being set --- test/classes/PMA_Config_test.php | 1 + 1 file changed, 1 insertion(+) diff --git a/test/classes/PMA_Config_test.php b/test/classes/PMA_Config_test.php index 199b3eadbb..20ccd19fd3 100644 --- a/test/classes/PMA_Config_test.php +++ b/test/classes/PMA_Config_test.php @@ -551,6 +551,7 @@ class PMA_ConfigTest extends PHPUnit_Framework_TestCase { $this->object->setUserValue(null, 'lang', 'cs', 'en'); $this->object->setUserValue("TEST_COOKIE_USER_VAL", '', 'cfg_val_1'); + $this->assertEquals($this->object->getUserValue("TEST_COOKIE_USER_VAL", 'fail'), 'cfg_val_1'); // Remove the following lines when you implement this test. // $this->markTestIncomplete( From 4cfcf4563c1ffe5ad64d6ea74856feaf30bab575 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Fri, 27 Apr 2012 10:11:32 +0200 Subject: [PATCH 5/6] We test this --- test/classes/PMA_Config_test.php | 5 ----- 1 file changed, 5 deletions(-) diff --git a/test/classes/PMA_Config_test.php b/test/classes/PMA_Config_test.php index 20ccd19fd3..a2f9e539ae 100644 --- a/test/classes/PMA_Config_test.php +++ b/test/classes/PMA_Config_test.php @@ -552,11 +552,6 @@ class PMA_ConfigTest extends PHPUnit_Framework_TestCase $this->object->setUserValue(null, 'lang', 'cs', 'en'); $this->object->setUserValue("TEST_COOKIE_USER_VAL", '', 'cfg_val_1'); $this->assertEquals($this->object->getUserValue("TEST_COOKIE_USER_VAL", 'fail'), 'cfg_val_1'); - - // Remove the following lines when you implement this test. -// $this->markTestIncomplete( -// 'This test has not been implemented yet.' -// ); } /** From 4467d048c6a9e00caec207e7f8bbf51aa862d497 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Fri, 27 Apr 2012 10:11:56 +0200 Subject: [PATCH 6/6] Basic implementation of testGetUserValue --- test/classes/PMA_Config_test.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/test/classes/PMA_Config_test.php b/test/classes/PMA_Config_test.php index a2f9e539ae..ed736eb487 100644 --- a/test/classes/PMA_Config_test.php +++ b/test/classes/PMA_Config_test.php @@ -559,10 +559,7 @@ class PMA_ConfigTest extends PHPUnit_Framework_TestCase */ public function testGetUserValue() { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); + $this->assertEquals($this->object->getUserValue('test_val', 'val'), 'val'); } /**