Skip to content

Commit

Permalink
Fixed the tests of MediaView in console/web.
Browse files Browse the repository at this point in the history
  • Loading branch information
jrbasso committed Apr 27, 2011
1 parent ab9b7f4 commit 84538ac
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions lib/Cake/tests/Case/View/MediaViewTest.php
Expand Up @@ -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,
Expand Down Expand Up @@ -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;
}
}

/**
Expand All @@ -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,
Expand Down Expand Up @@ -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;
}
}

/**
Expand All @@ -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,
Expand Down Expand Up @@ -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;
}
}

/**
Expand Down

0 comments on commit 84538ac

Please sign in to comment.