|
|
@@ -1199,6 +1199,10 @@ class ResponseTest extends TestCase {
|
|
|
|
|
|
$response->expects($this->at(1))
|
|
|
->method('header')
|
|
|
+ ->with('Accept-Ranges', 'bytes');
|
|
|
+
|
|
|
+ $response->expects($this->at(2))
|
|
|
+ ->method('header')
|
|
|
->with('Content-Length', 38);
|
|
|
|
|
|
$response->expects($this->once())->method('_clearBuffer');
|
|
|
@@ -1245,11 +1249,11 @@ class ResponseTest extends TestCase {
|
|
|
|
|
|
$response->expects($this->at(2))
|
|
|
->method('header')
|
|
|
- ->with('Accept-Ranges', 'bytes');
|
|
|
+ ->with('Content-Transfer-Encoding', 'binary');
|
|
|
|
|
|
$response->expects($this->at(3))
|
|
|
->method('header')
|
|
|
- ->with('Content-Transfer-Encoding', 'binary');
|
|
|
+ ->with('Accept-Ranges', 'bytes');
|
|
|
|
|
|
$response->expects($this->at(4))
|
|
|
->method('header')
|
|
|
@@ -1274,7 +1278,7 @@ class ResponseTest extends TestCase {
|
|
|
$result = $response->send();
|
|
|
$output = ob_get_clean();
|
|
|
$this->assertEquals("/* this is the test asset css file */\n", $output);
|
|
|
- $this->assertTrue($result !== false);
|
|
|
+ $this->assertNotSame(false, $result);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -1308,11 +1312,11 @@ class ResponseTest extends TestCase {
|
|
|
|
|
|
$response->expects($this->at(2))
|
|
|
->method('header')
|
|
|
- ->with('Accept-Ranges', 'bytes');
|
|
|
+ ->with('Content-Transfer-Encoding', 'binary');
|
|
|
|
|
|
$response->expects($this->at(3))
|
|
|
->method('header')
|
|
|
- ->with('Content-Transfer-Encoding', 'binary');
|
|
|
+ ->with('Accept-Ranges', 'bytes');
|
|
|
|
|
|
$response->expects($this->at(4))
|
|
|
->method('header')
|
|
|
@@ -1331,7 +1335,7 @@ class ResponseTest extends TestCase {
|
|
|
$result = $response->send();
|
|
|
$output = ob_get_clean();
|
|
|
$this->assertEquals("some_key = some_value\nbool_key = 1\n", $output);
|
|
|
- $this->assertTrue($result !== false);
|
|
|
+ $this->assertNotSame(false, $result);
|
|
|
if ($currentUserAgent !== null) {
|
|
|
$_SERVER['HTTP_USER_AGENT'] = $currentUserAgent;
|
|
|
}
|
|
|
@@ -1373,11 +1377,11 @@ class ResponseTest extends TestCase {
|
|
|
|
|
|
$response->expects($this->at(3))
|
|
|
->method('header')
|
|
|
- ->with('Accept-Ranges', 'bytes');
|
|
|
+ ->with('Content-Transfer-Encoding', 'binary');
|
|
|
|
|
|
$response->expects($this->at(4))
|
|
|
->method('header')
|
|
|
- ->with('Content-Transfer-Encoding', 'binary');
|
|
|
+ ->with('Accept-Ranges', 'bytes');
|
|
|
|
|
|
$response->expects($this->at(5))
|
|
|
->method('header')
|
|
|
@@ -1395,7 +1399,7 @@ class ResponseTest extends TestCase {
|
|
|
$result = $response->send();
|
|
|
$output = ob_get_clean();
|
|
|
$this->assertEquals("some_key = some_value\nbool_key = 1\n", $output);
|
|
|
- $this->assertTrue($result !== false);
|
|
|
+ $this->assertNotSame(false, $result);
|
|
|
if ($currentUserAgent !== null) {
|
|
|
$_SERVER['HTTP_USER_AGENT'] = $currentUserAgent;
|
|
|
}
|
|
|
@@ -1437,11 +1441,11 @@ class ResponseTest extends TestCase {
|
|
|
|
|
|
$response->expects($this->at(3))
|
|
|
->method('header')
|
|
|
- ->with('Accept-Ranges', 'bytes');
|
|
|
+ ->with('Content-Transfer-Encoding', 'binary');
|
|
|
|
|
|
$response->expects($this->at(4))
|
|
|
->method('header')
|
|
|
- ->with('Content-Transfer-Encoding', 'binary');
|
|
|
+ ->with('Accept-Ranges', 'bytes');
|
|
|
|
|
|
$response->expects($this->at(5))
|
|
|
->method('header')
|
|
|
@@ -1461,7 +1465,7 @@ class ResponseTest extends TestCase {
|
|
|
$result = $response->send();
|
|
|
$output = ob_get_clean();
|
|
|
$this->assertEquals("some_key = some_value\nbool_key = 1\n", $output);
|
|
|
- $this->assertTrue($result !== false);
|
|
|
+ $this->assertNotSame(false, $result);
|
|
|
if ($currentUserAgent !== null) {
|
|
|
$_SERVER['HTTP_USER_AGENT'] = $currentUserAgent;
|
|
|
}
|
|
|
@@ -1491,6 +1495,10 @@ class ResponseTest extends TestCase {
|
|
|
->with('ini')
|
|
|
->will($this->returnValue(false));
|
|
|
|
|
|
+ $response->expects($this->at(1))
|
|
|
+ ->method('header')
|
|
|
+ ->with('Accept-Ranges', 'bytes');
|
|
|
+
|
|
|
$response->expects($this->never())
|
|
|
->method('download');
|
|
|
|
|
|
@@ -1643,11 +1651,11 @@ class ResponseTest extends TestCase {
|
|
|
|
|
|
$response->expects($this->at(2))
|
|
|
->method('header')
|
|
|
- ->with('Accept-Ranges', 'bytes');
|
|
|
+ ->with('Content-Transfer-Encoding', 'binary');
|
|
|
|
|
|
$response->expects($this->at(3))
|
|
|
->method('header')
|
|
|
- ->with('Content-Transfer-Encoding', 'binary');
|
|
|
+ ->with('Accept-Ranges', 'bytes');
|
|
|
|
|
|
$response->expects($this->at(4))
|
|
|
->method('header')
|
|
|
@@ -1698,11 +1706,11 @@ class ResponseTest extends TestCase {
|
|
|
|
|
|
$response->expects($this->at(2))
|
|
|
->method('header')
|
|
|
- ->with('Accept-Ranges', 'bytes');
|
|
|
+ ->with('Content-Transfer-Encoding', 'binary');
|
|
|
|
|
|
$response->expects($this->at(3))
|
|
|
->method('header')
|
|
|
- ->with('Content-Transfer-Encoding', 'binary');
|
|
|
+ ->with('Accept-Ranges', 'bytes');
|
|
|
|
|
|
$response->expects($this->at(4))
|
|
|
->method('header')
|
|
|
@@ -1727,7 +1735,7 @@ class ResponseTest extends TestCase {
|
|
|
$output = ob_get_clean();
|
|
|
$this->assertEquals(206, $response->statusCode());
|
|
|
$this->assertEquals("is the test asset ", $output);
|
|
|
- $this->assertTrue($result !== false);
|
|
|
+ $this->assertNotSame(false, $result);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -1753,11 +1761,11 @@ class ResponseTest extends TestCase {
|
|
|
|
|
|
$response->expects($this->at(2))
|
|
|
->method('header')
|
|
|
- ->with('Accept-Ranges', 'bytes');
|
|
|
+ ->with('Content-Transfer-Encoding', 'binary');
|
|
|
|
|
|
$response->expects($this->at(3))
|
|
|
->method('header')
|
|
|
- ->with('Content-Transfer-Encoding', 'binary');
|
|
|
+ ->with('Accept-Ranges', 'bytes');
|
|
|
|
|
|
$response->expects($this->at(4))
|
|
|
->method('header')
|
|
|
@@ -1775,6 +1783,136 @@ class ResponseTest extends TestCase {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * testFileRangeOffsetsNoDownload method
|
|
|
+ *
|
|
|
+ * @dataProvider rangeProvider
|
|
|
+ * @return void
|
|
|
+ */
|
|
|
+ public function testFileRangeOffsetsNoDownload($range, $length, $offsetResponse) {
|
|
|
+ $_SERVER['HTTP_RANGE'] = $range;
|
|
|
+ $response = $this->getMock('Cake\Network\Response', array(
|
|
|
+ 'header',
|
|
|
+ 'type',
|
|
|
+ '_sendHeader',
|
|
|
+ '_isActive',
|
|
|
+ '_clearBuffer',
|
|
|
+ '_flushBuffer'
|
|
|
+ ));
|
|
|
+
|
|
|
+ $response->expects($this->at(1))
|
|
|
+ ->method('header')
|
|
|
+ ->with('Accept-Ranges', 'bytes');
|
|
|
+
|
|
|
+ $response->expects($this->at(2))
|
|
|
+ ->method('header')
|
|
|
+ ->with(array(
|
|
|
+ 'Content-Length' => $length,
|
|
|
+ 'Content-Range' => $offsetResponse,
|
|
|
+ ));
|
|
|
+
|
|
|
+ $response->expects($this->any())
|
|
|
+ ->method('_isActive')
|
|
|
+ ->will($this->returnValue(true));
|
|
|
+
|
|
|
+ $response->file(
|
|
|
+ TEST_APP . 'vendor' . DS . 'css' . DS . 'test_asset.css',
|
|
|
+ array('download' => false)
|
|
|
+ );
|
|
|
+
|
|
|
+ ob_start();
|
|
|
+ $result = $response->send();
|
|
|
+ ob_get_clean();
|
|
|
+ }
|
|
|
+
|
|
|
+/**
|
|
|
+ * testFileRangeNoDownload method
|
|
|
+ *
|
|
|
+ * @return void
|
|
|
+ */
|
|
|
+ public function testFileRangeNoDownload() {
|
|
|
+ $_SERVER['HTTP_RANGE'] = 'bytes=8-25';
|
|
|
+ $response = $this->getMock('Cake\Network\Response', array(
|
|
|
+ 'header',
|
|
|
+ 'type',
|
|
|
+ '_sendHeader',
|
|
|
+ '_setContentType',
|
|
|
+ '_isActive',
|
|
|
+ '_clearBuffer',
|
|
|
+ '_flushBuffer'
|
|
|
+ ));
|
|
|
+
|
|
|
+ $response->expects($this->exactly(1))
|
|
|
+ ->method('type')
|
|
|
+ ->with('css')
|
|
|
+ ->will($this->returnArgument(0));
|
|
|
+
|
|
|
+ $response->expects($this->at(1))
|
|
|
+ ->method('header')
|
|
|
+ ->with('Accept-Ranges', 'bytes');
|
|
|
+
|
|
|
+ $response->expects($this->at(2))
|
|
|
+ ->method('header')
|
|
|
+ ->with(array(
|
|
|
+ 'Content-Length' => 18,
|
|
|
+ 'Content-Range' => 'bytes 8-25/38',
|
|
|
+ ));
|
|
|
+
|
|
|
+ $response->expects($this->once())->method('_clearBuffer');
|
|
|
+
|
|
|
+ $response->expects($this->any())
|
|
|
+ ->method('_isActive')
|
|
|
+ ->will($this->returnValue(true));
|
|
|
+
|
|
|
+ $response->file(
|
|
|
+ TEST_APP . 'vendor' . DS . 'css' . DS . 'test_asset.css',
|
|
|
+ array('download' => false)
|
|
|
+ );
|
|
|
+
|
|
|
+ ob_start();
|
|
|
+ $result = $response->send();
|
|
|
+ $output = ob_get_clean();
|
|
|
+ $this->assertEquals(206, $response->statusCode());
|
|
|
+ $this->assertEquals("is the test asset ", $output);
|
|
|
+ $this->assertNotSame(false, $result);
|
|
|
+ }
|
|
|
+
|
|
|
+/**
|
|
|
+ * testFileRangeInvalidNoDownload method
|
|
|
+ *
|
|
|
+ * @return void
|
|
|
+ */
|
|
|
+ public function testFileRangeInvalidNoDownload() {
|
|
|
+ $_SERVER['HTTP_RANGE'] = 'bytes=30-2';
|
|
|
+ $response = $this->getMock('Cake\Network\Response', array(
|
|
|
+ 'header',
|
|
|
+ 'type',
|
|
|
+ '_sendHeader',
|
|
|
+ '_setContentType',
|
|
|
+ '_isActive',
|
|
|
+ '_clearBuffer',
|
|
|
+ '_flushBuffer'
|
|
|
+ ));
|
|
|
+
|
|
|
+ $response->expects($this->at(1))
|
|
|
+ ->method('header')
|
|
|
+ ->with('Accept-Ranges', 'bytes');
|
|
|
+
|
|
|
+ $response->expects($this->at(2))
|
|
|
+ ->method('header')
|
|
|
+ ->with(array(
|
|
|
+ 'Content-Range' => 'bytes 0-37/38',
|
|
|
+ ));
|
|
|
+
|
|
|
+ $response->file(
|
|
|
+ TEST_APP . 'vendor' . DS . 'css' . DS . 'test_asset.css',
|
|
|
+ array('download' => false)
|
|
|
+ );
|
|
|
+
|
|
|
+ $this->assertEquals(416, $response->statusCode());
|
|
|
+ $result = $response->send();
|
|
|
+ }
|
|
|
+
|
|
|
+/**
|
|
|
* Test the location method.
|
|
|
*
|
|
|
* @return void
|