From 84538ac10a06a2c2883fab9179d6f86b722911fa Mon Sep 17 00:00:00 2001 From: Juan Basso Date: Wed, 27 Apr 2011 00:26:42 -0400 Subject: [PATCH] Fixed the tests of MediaView in console/web. --- lib/Cake/tests/Case/View/MediaViewTest.php | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/lib/Cake/tests/Case/View/MediaViewTest.php b/lib/Cake/tests/Case/View/MediaViewTest.php index 47f6b9b9b..d0f4be960 100644 --- a/lib/Cake/tests/Case/View/MediaViewTest.php +++ b/lib/Cake/tests/Case/View/MediaViewTest.php @@ -117,7 +117,7 @@ class MediaViewTest extends CakeTestCase { * @return void */ function testRenderWithUnknownFileTypeGeneric() { - $currentUserAgent = $_SERVER['HTTP_USER_AGENT']; + $currentUserAgent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : null; $_SERVER['HTTP_USER_AGENT'] = 'Some generic browser'; $this->MediaView->viewVars = array( 'path' => LIBS . 'tests' . DS . 'test_app' . DS . 'config' . DS, @@ -165,7 +165,9 @@ class MediaViewTest extends CakeTestCase { $output = ob_get_clean(); $this->assertEqual("some_key = some_value\nbool_key = 1\n", $output); $this->assertTrue($result !== false); - $_SERVER['HTTP_USER_AGENT'] = $currentUserAgent; + if ($currentUserAgent !== null) { + $_SERVER['HTTP_USER_AGENT'] = $currentUserAgent; + } } /** @@ -175,7 +177,7 @@ class MediaViewTest extends CakeTestCase { * @return void */ function testRenderWithUnknownFileTypeOpera() { - $currentUserAgent = $_SERVER['HTTP_USER_AGENT']; + $currentUserAgent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : null; $_SERVER['HTTP_USER_AGENT'] = 'Opera/9.80 (Windows NT 6.0; U; en) Presto/2.8.99 Version/11.10'; $this->MediaView->viewVars = array( 'path' => LIBS . 'tests' . DS . 'test_app' . DS . 'config' . DS, @@ -228,7 +230,9 @@ class MediaViewTest extends CakeTestCase { $output = ob_get_clean(); $this->assertEqual("some_key = some_value\nbool_key = 1\n", $output); $this->assertTrue($result !== false); - $_SERVER['HTTP_USER_AGENT'] = $currentUserAgent; + if ($currentUserAgent !== null) { + $_SERVER['HTTP_USER_AGENT'] = $currentUserAgent; + } } /** @@ -238,7 +242,7 @@ class MediaViewTest extends CakeTestCase { * @return void */ function testRenderWithUnknownFileTypeIE() { - $currentUserAgent = $_SERVER['HTTP_USER_AGENT']; + $currentUserAgent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : null; $_SERVER['HTTP_USER_AGENT'] = 'Mozilla/5.0 (compatible; MSIE 8.0; Windows NT 5.2; Trident/4.0; Media Center PC 4.0; SLCC1; .NET CLR 3.0.04320)'; $this->MediaView->viewVars = array( 'path' => LIBS . 'tests' . DS . 'test_app' . DS . 'config' . DS, @@ -291,7 +295,9 @@ class MediaViewTest extends CakeTestCase { $output = ob_get_clean(); $this->assertEqual("some_key = some_value\nbool_key = 1\n", $output); $this->assertTrue($result !== false); - $_SERVER['HTTP_USER_AGENT'] = $currentUserAgent; + if ($currentUserAgent !== null) { + $_SERVER['HTTP_USER_AGENT'] = $currentUserAgent; + } } /**