Fixed the tests of MediaView in console/web.

This commit is contained in:
Juan Basso 2011-04-27 00:26:42 -04:00
parent ab9b7f44dc
commit 84538ac10a

View file

@ -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;
}
}
/**