From 3e83565cf22332f5968cf77ac6861e8d3bd354ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Thu, 13 Mar 2014 13:47:30 +0100 Subject: [PATCH 1/3] Fix order of params to assertEquals MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Michal Čihař --- test/classes/PMA_Advisor_test.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/classes/PMA_Advisor_test.php b/test/classes/PMA_Advisor_test.php index 30f8e93139..7cdaf9c3e0 100644 --- a/test/classes/PMA_Advisor_test.php +++ b/test/classes/PMA_Advisor_test.php @@ -130,10 +130,10 @@ class Advisor_Test extends PHPUnit_Framework_TestCase $advisor->variables['value'] = 0; $advisor->addRule('fired', $rule); if (isset($advisor->runResult['errors']) || !is_null($error)) { - $this->assertEquals($advisor->runResult['errors'], array($error)); + $this->assertEquals(array($error), $advisor->runResult['errors']); } if (isset($advisor->runResult['fired']) || $expected != array()) { - $this->assertEquals($advisor->runResult['fired'], array($expected)); + $this->assertEquals(array($expected), $advisor->runResult['fired']); } } From 3d0f2370318702b27f3a36b42ab3cb38adb727c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Thu, 13 Mar 2014 13:50:54 +0100 Subject: [PATCH 2/3] Fix expected message to match code MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Michal Čihař --- test/classes/PMA_Advisor_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/classes/PMA_Advisor_test.php b/test/classes/PMA_Advisor_test.php index 7cdaf9c3e0..a13c68c698 100644 --- a/test/classes/PMA_Advisor_test.php +++ b/test/classes/PMA_Advisor_test.php @@ -236,7 +236,7 @@ class Advisor_Test extends PHPUnit_Framework_TestCase array(), 'Failed formatting string for rule \'Failure\'. PHP threw ' . 'following error: Use of undefined constant fsafdsa - ' . - 'assumed \'fsafdsa\'', + 'assumed \'fsafdsa\'
Executed code: $value = fsafdsa;', ), array( array( From 53cc186591f574299fe1951873fa9458b291b6e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Thu, 13 Mar 2014 13:51:40 +0100 Subject: [PATCH 3/3] Fixed ob_start/eval problems in phpunit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When running in phpunit, the eval can raise exception, so treat it same as it would be output returned by the eval. Without catching it, output buffering gets one more level of nesting leading to occassional timeouts in Travis-CI. Signed-off-by: Michal Čihař --- libraries/Advisor.class.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/libraries/Advisor.class.php b/libraries/Advisor.class.php index 4c96108387..f372522e3c 100644 --- a/libraries/Advisor.class.php +++ b/libraries/Advisor.class.php @@ -353,8 +353,14 @@ class Advisor // Actually evaluate the code ob_start(); - eval('$value = ' . $expr . ';'); - $err = ob_get_contents(); + try { + eval('$value = ' . $expr . ';'); + $err = ob_get_contents(); + } catch (Exception $e) { + // In normal operation, there is just output in the buffer, + // but when running under phpunit, error in eval raises exception + $err = $e->getMessage(); + } ob_end_clean(); // Error handling