|
|
@@ -111,12 +111,14 @@ class MediaViewTest extends CakeTestCase {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * testRenderWithUnknownFileType method
|
|
|
+ * testRenderWithUnknownFileTypeGeneric method
|
|
|
*
|
|
|
* @access public
|
|
|
* @return void
|
|
|
*/
|
|
|
- function testRenderWithUnknownFileType() {
|
|
|
+ function testRenderWithUnknownFileTypeGeneric() {
|
|
|
+ $currentUserAgent = $_SERVER['HTTP_USER_AGENT'];
|
|
|
+ $_SERVER['HTTP_USER_AGENT'] = 'Some generic browser';
|
|
|
$this->MediaView->viewVars = array(
|
|
|
'path' => LIBS . 'tests' . DS . 'test_app' . DS . 'config' . DS,
|
|
|
'id' => 'no_section.ini',
|
|
|
@@ -163,6 +165,133 @@ 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;
|
|
|
+ }
|
|
|
+
|
|
|
+/**
|
|
|
+ * testRenderWithUnknownFileTypeOpera method
|
|
|
+ *
|
|
|
+ * @access public
|
|
|
+ * @return void
|
|
|
+ */
|
|
|
+ function testRenderWithUnknownFileTypeOpera() {
|
|
|
+ $currentUserAgent = $_SERVER['HTTP_USER_AGENT'];
|
|
|
+ $_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,
|
|
|
+ 'id' => 'no_section.ini',
|
|
|
+ 'extension' => 'ini',
|
|
|
+ );
|
|
|
+ $this->MediaView->expects($this->exactly(2))
|
|
|
+ ->method('_isActive')
|
|
|
+ ->will($this->returnValue(true));
|
|
|
+
|
|
|
+ $this->MediaView->response->expects($this->at(0))
|
|
|
+ ->method('type')
|
|
|
+ ->with('ini')
|
|
|
+ ->will($this->returnValue(false));
|
|
|
+
|
|
|
+ $this->MediaView->response->expects($this->at(1))
|
|
|
+ ->method('header')
|
|
|
+ ->with(array(
|
|
|
+ 'Date' => gmdate('D, d M Y H:i:s', time()) . ' GMT',
|
|
|
+ 'Expires' => '0',
|
|
|
+ 'Cache-Control' => 'private, must-revalidate, post-check=0, pre-check=0',
|
|
|
+ 'Pragma' => 'no-cache'
|
|
|
+ ));
|
|
|
+
|
|
|
+ $this->MediaView->response->expects($this->at(2))
|
|
|
+ ->method('type')
|
|
|
+ ->with('application/octetstream')
|
|
|
+ ->will($this->returnValue(false));
|
|
|
+
|
|
|
+ $this->MediaView->response->expects($this->once())
|
|
|
+ ->method('download')
|
|
|
+ ->with('no_section.ini');
|
|
|
+
|
|
|
+ $this->MediaView->response->expects($this->at(4))
|
|
|
+ ->method('header')
|
|
|
+ ->with(array(
|
|
|
+ 'Accept-Ranges' => 'bytes'
|
|
|
+ ));
|
|
|
+
|
|
|
+ $this->MediaView->response->expects($this->at(5))
|
|
|
+ ->method('header')
|
|
|
+ ->with('Content-Length', 35);
|
|
|
+
|
|
|
+ $this->MediaView->response->expects($this->once())->method('send');
|
|
|
+ $this->MediaView->expects($this->once())->method('_clearBuffer');
|
|
|
+ $this->MediaView->expects($this->once())->method('_flushBuffer');
|
|
|
+
|
|
|
+ ob_start();
|
|
|
+ $result = $this->MediaView->render();
|
|
|
+ $output = ob_get_clean();
|
|
|
+ $this->assertEqual("some_key = some_value\nbool_key = 1\n", $output);
|
|
|
+ $this->assertTrue($result !== false);
|
|
|
+ $_SERVER['HTTP_USER_AGENT'] = $currentUserAgent;
|
|
|
+ }
|
|
|
+
|
|
|
+/**
|
|
|
+ * testRenderWithUnknownFileTypeIE method
|
|
|
+ *
|
|
|
+ * @access public
|
|
|
+ * @return void
|
|
|
+ */
|
|
|
+ function testRenderWithUnknownFileTypeIE() {
|
|
|
+ $currentUserAgent = $_SERVER['HTTP_USER_AGENT'];
|
|
|
+ $_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,
|
|
|
+ 'id' => 'no_section.ini',
|
|
|
+ 'extension' => 'ini',
|
|
|
+ );
|
|
|
+ $this->MediaView->expects($this->exactly(2))
|
|
|
+ ->method('_isActive')
|
|
|
+ ->will($this->returnValue(true));
|
|
|
+
|
|
|
+ $this->MediaView->response->expects($this->at(0))
|
|
|
+ ->method('type')
|
|
|
+ ->with('ini')
|
|
|
+ ->will($this->returnValue(false));
|
|
|
+
|
|
|
+ $this->MediaView->response->expects($this->at(1))
|
|
|
+ ->method('header')
|
|
|
+ ->with(array(
|
|
|
+ 'Date' => gmdate('D, d M Y H:i:s', time()) . ' GMT',
|
|
|
+ 'Expires' => '0',
|
|
|
+ 'Cache-Control' => 'private, must-revalidate, post-check=0, pre-check=0',
|
|
|
+ 'Pragma' => 'no-cache'
|
|
|
+ ));
|
|
|
+
|
|
|
+ $this->MediaView->response->expects($this->at(2))
|
|
|
+ ->method('type')
|
|
|
+ ->with('application/force-download')
|
|
|
+ ->will($this->returnValue(false));
|
|
|
+
|
|
|
+ $this->MediaView->response->expects($this->once())
|
|
|
+ ->method('download')
|
|
|
+ ->with('no_section.ini');
|
|
|
+
|
|
|
+ $this->MediaView->response->expects($this->at(4))
|
|
|
+ ->method('header')
|
|
|
+ ->with(array(
|
|
|
+ 'Accept-Ranges' => 'bytes'
|
|
|
+ ));
|
|
|
+
|
|
|
+ $this->MediaView->response->expects($this->at(5))
|
|
|
+ ->method('header')
|
|
|
+ ->with('Content-Length', 35);
|
|
|
+
|
|
|
+ $this->MediaView->response->expects($this->once())->method('send');
|
|
|
+ $this->MediaView->expects($this->once())->method('_clearBuffer');
|
|
|
+ $this->MediaView->expects($this->once())->method('_flushBuffer');
|
|
|
+
|
|
|
+ ob_start();
|
|
|
+ $result = $this->MediaView->render();
|
|
|
+ $output = ob_get_clean();
|
|
|
+ $this->assertEqual("some_key = some_value\nbool_key = 1\n", $output);
|
|
|
+ $this->assertTrue($result !== false);
|
|
|
+ $_SERVER['HTTP_USER_AGENT'] = $currentUserAgent;
|
|
|
}
|
|
|
|
|
|
/**
|