From 4fc8d2b37e046ac7de5805ff28df2b830730de12 Mon Sep 17 00:00:00 2001 From: ayushchd Date: Fri, 12 Jul 2013 13:07:01 +0545 Subject: [PATCH 1/2] Fix failing tests because of static variable --- libraries/user_preferences.lib.php | 4 ++++ test/libraries/PMA_user_preferences_test.php | 16 +++++++++++++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/libraries/user_preferences.lib.php b/libraries/user_preferences.lib.php index 8697a75b8b..910e603dae 100644 --- a/libraries/user_preferences.lib.php +++ b/libraries/user_preferences.lib.php @@ -175,6 +175,10 @@ function PMA_readUserprefsFieldNames(array $forms = null) { static $names; + if (defined('TESTSUITE')) { + $names = null; + } + // return cached results if ($names !== null) { return $names; diff --git a/test/libraries/PMA_user_preferences_test.php b/test/libraries/PMA_user_preferences_test.php index f71420aa63..5320ba5976 100644 --- a/test/libraries/PMA_user_preferences_test.php +++ b/test/libraries/PMA_user_preferences_test.php @@ -293,16 +293,26 @@ class PMA_User_Preferences_Test extends PHPUnit_Framework_TestCase /** * Test for PMA_readUserprefsFieldNames - * This test would only work when executed with other tests. - * This is to test "static" nature of this function * * @return void */ public function testReadUserprefsFieldNames() { + $this->assertCount( + 216, + PMA_readUserprefsFieldNames() + ); + + $forms = array( + 'form1' => array( + array('Servers/1/hide_db', 'bar'), + array('test' => 'val') + ) + ); + $this->assertEquals( array('Servers/1/hide_db', 'bar', 'test'), - PMA_readUserprefsFieldNames(array()) + PMA_readUserprefsFieldNames($forms) ); } From 550a6064432b531df59c39209a939bdd6cf31c1b Mon Sep 17 00:00:00 2001 From: ayushchd Date: Fri, 12 Jul 2013 13:07:30 +0545 Subject: [PATCH 2/2] Improve tests and coverage --- test/libraries/PMA_ConfigGenerator_test.php | 1 + test/libraries/PMA_FormDisplay_tpl_test.php | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/test/libraries/PMA_ConfigGenerator_test.php b/test/libraries/PMA_ConfigGenerator_test.php index c6a8a8aad2..41912fa0a4 100644 --- a/test/libraries/PMA_ConfigGenerator_test.php +++ b/test/libraries/PMA_ConfigGenerator_test.php @@ -39,6 +39,7 @@ class PMA_ConfigGenerator_Test extends PHPUnit_Framework_TestCase $GLOBALS['server'] = 0; $cf = ConfigFile::getInstance(); + $_SESSION['ConfigFile0'] = array('a', 'b', 'c'); $_SESSION['ConfigFile0']['Servers'] = array( array(1, 2, 3) ); diff --git a/test/libraries/PMA_FormDisplay_tpl_test.php b/test/libraries/PMA_FormDisplay_tpl_test.php index 97ceed7d8d..72d492505c 100644 --- a/test/libraries/PMA_FormDisplay_tpl_test.php +++ b/test/libraries/PMA_FormDisplay_tpl_test.php @@ -233,6 +233,7 @@ class PMA_FormDisplay_Tpl_Test extends PHPUnit_Framework_TestCase $opts['doc'] = "http://doclink"; $opts['wiki'] = "http://wikilink"; $opts['comment'] = "testComment"; + $opts['comment_warning'] = true; $opts['show_restore_default'] = true; ob_start(); PMA_displayInput( @@ -319,7 +320,7 @@ class PMA_FormDisplay_Tpl_Test extends PHPUnit_Framework_TestCase $this->assertTag( $this->_getTagArray( - '', + '', array('content' => 'i') ), $result