From 8e635922b0ad7dd7de13463443ab2afa7a7ae559 Mon Sep 17 00:00:00 2001 From: Rouslan Placella Date: Sat, 22 Dec 2012 23:10:30 +0000 Subject: [PATCH] Fixed unit tests for PMA_Scripts class --- test/classes/PMA_Scripts_test.php | 67 +++++++++---------------------- 1 file changed, 20 insertions(+), 47 deletions(-) diff --git a/test/classes/PMA_Scripts_test.php b/test/classes/PMA_Scripts_test.php index 142d2d2bc4..b3749bcfff 100644 --- a/test/classes/PMA_Scripts_test.php +++ b/test/classes/PMA_Scripts_test.php @@ -10,6 +10,8 @@ */ require_once 'libraries/Scripts.class.php'; +require_once 'libraries/js_escape.lib.php'; + class PMA_Scripts_test extends PHPUnit_Framework_TestCase { @@ -28,6 +30,9 @@ class PMA_Scripts_test extends PHPUnit_Framework_TestCase protected function setUp() { $this->object = new PMA_Scripts(); + if (! defined('PMA_USR_BROWSER_AGENT')) { + define('PMA_USR_BROWSER_AGENT', 'MOZILLA'); + } } /** @@ -61,61 +66,30 @@ class PMA_Scripts_test extends PHPUnit_Framework_TestCase /** * Test for _includeFile * - * @param tring $url Location of javascript, relative to js/ folder. - * @param int $timestamp The date when the file was last modified - * @param string $ie_conditional true - wrap with IE conditional comment - * 'lt 9' etc. - wrap for specific IE version - * @param string $output output from the _includeFile method + * @param array $files A list of files to include + * @param string $output output from the _includeFile method * * @return void - * - * @dataProvider providerForTestIncludeFile */ - public function testIncludeFile($url, $timestamp, $ie_conditional, $output) + public function testIncludeFile() { $this->assertEquals( - $output, + '', $this->_callPrivateFunction( - '_includeFile', - array($url, $timestamp, $ie_conditional) + '_includeFiles', + array( + array( + array( + 'has_onload' => false, + 'filename' => 'common.js', + 'conditional_ie' => false + ) + ) + ) ) ); } - /** - * @return array data for testIncludeFile - */ - public function providerForTestIncludeFile() - { - return array( - array( - 'common.js', - null, - true, - ' -' - ), - array( - 'common.js', - null, - 7, - ' -' - ), - array( - 'common.js', - null, - false, - ' -' - ) - ); - } - /** * Test for getDisplay * @@ -128,8 +102,7 @@ class PMA_Scripts_test extends PHPUnit_Framework_TestCase $this->object->addEvent('onClick', 'doSomething'); $this->assertRegExp( - '@ -