diff --git a/lib/Cake/tests/Case/View/MediaViewTest.php b/lib/Cake/tests/Case/View/MediaViewTest.php index 47f6b9b9b39..d0f4be9607f 100644 --- a/lib/Cake/tests/Case/View/MediaViewTest.php +++ b/lib/Cake/tests/Case/View/MediaViewTest.php @@ -117,7 +117,7 @@ function testRender() { * @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 @@ function testRenderWithUnknownFileTypeGeneric() { $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 @@ function testRenderWithUnknownFileTypeGeneric() { * @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 @@ function testRenderWithUnknownFileTypeOpera() { $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 @@ function testRenderWithUnknownFileTypeOpera() { * @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 @@ function testRenderWithUnknownFileTypeIE() { $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; + } } /**