aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/sabre/dav/tests/Sabre/DAV/ServerRangeTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/sabre/dav/tests/Sabre/DAV/ServerRangeTest.php')
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAV/ServerRangeTest.php150
1 files changed, 70 insertions, 80 deletions
diff --git a/vendor/sabre/dav/tests/Sabre/DAV/ServerRangeTest.php b/vendor/sabre/dav/tests/Sabre/DAV/ServerRangeTest.php
index 81224d687..93ea083d8 100644
--- a/vendor/sabre/dav/tests/Sabre/DAV/ServerRangeTest.php
+++ b/vendor/sabre/dav/tests/Sabre/DAV/ServerRangeTest.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
namespace Sabre\DAV;
use DateTime;
@@ -12,22 +14,22 @@ use Sabre\HTTP;
* @author Evert Pot (http://evertpot.com/)
* @license http://sabre.io/license/ Modified BSD License
*/
-class ServerRangeTest extends \Sabre\DAVServerTest {
-
+class ServerRangeTest extends \Sabre\DAVServerTest
+{
protected $setupFiles = true;
/**
- * We need this string a lot
+ * We need this string a lot.
*/
protected $lastModified;
- function setUp() {
-
+ public function setUp()
+ {
parent::setUp();
$this->server->createFile('files/test.txt', 'Test contents');
- $this->lastModified = HTTP\Util::toHTTPDate(
- new DateTime('@' . $this->server->tree->getNodeForPath('files/test.txt')->getLastModified())
+ $this->lastModified = HTTP\toDate(
+ new DateTime('@'.$this->server->tree->getNodeForPath('files/test.txt')->getLastModified())
);
$stream = popen('echo "Test contents"', 'r');
@@ -37,112 +39,106 @@ class ServerRangeTest extends \Sabre\DAVServerTest {
);
$streamingFile->setSize(12);
$this->server->tree->getNodeForPath('files')->addNode($streamingFile);
-
}
- function testRange() {
-
+ public function testRange()
+ {
$request = new HTTP\Request('GET', '/files/test.txt', ['Range' => 'bytes=2-5']);
$response = $this->request($request);
$this->assertEquals([
'X-Sabre-Version' => [Version::VERSION],
- 'Content-Type' => ['application/octet-stream'],
- 'Content-Length' => [4],
- 'Content-Range' => ['bytes 2-5/13'],
- 'ETag' => ['"' . md5('Test contents') . '"'],
- 'Last-Modified' => [$this->lastModified],
+ 'Content-Type' => ['application/octet-stream'],
+ 'Content-Length' => [4],
+ 'Content-Range' => ['bytes 2-5/13'],
+ 'ETag' => ['"'.md5('Test contents').'"'],
+ 'Last-Modified' => [$this->lastModified],
],
$response->getHeaders()
);
$this->assertEquals(206, $response->getStatus());
$this->assertEquals('st c', $response->getBodyAsString());
-
}
/**
* @depends testRange
*/
- function testStartRange() {
-
+ public function testStartRange()
+ {
$request = new HTTP\Request('GET', '/files/test.txt', ['Range' => 'bytes=2-']);
$response = $this->request($request);
$this->assertEquals([
'X-Sabre-Version' => [Version::VERSION],
- 'Content-Type' => ['application/octet-stream'],
- 'Content-Length' => [11],
- 'Content-Range' => ['bytes 2-12/13'],
- 'ETag' => ['"' . md5('Test contents') . '"'],
- 'Last-Modified' => [$this->lastModified],
+ 'Content-Type' => ['application/octet-stream'],
+ 'Content-Length' => [11],
+ 'Content-Range' => ['bytes 2-12/13'],
+ 'ETag' => ['"'.md5('Test contents').'"'],
+ 'Last-Modified' => [$this->lastModified],
],
$response->getHeaders()
);
$this->assertEquals(206, $response->getStatus());
$this->assertEquals('st contents', $response->getBodyAsString());
-
}
/**
* @depends testRange
*/
- function testEndRange() {
-
+ public function testEndRange()
+ {
$request = new HTTP\Request('GET', '/files/test.txt', ['Range' => 'bytes=-8']);
$response = $this->request($request);
$this->assertEquals([
'X-Sabre-Version' => [Version::VERSION],
- 'Content-Type' => ['application/octet-stream'],
- 'Content-Length' => [8],
- 'Content-Range' => ['bytes 5-12/13'],
- 'ETag' => ['"' . md5('Test contents') . '"'],
- 'Last-Modified' => [$this->lastModified],
+ 'Content-Type' => ['application/octet-stream'],
+ 'Content-Length' => [8],
+ 'Content-Range' => ['bytes 5-12/13'],
+ 'ETag' => ['"'.md5('Test contents').'"'],
+ 'Last-Modified' => [$this->lastModified],
],
$response->getHeaders()
);
$this->assertEquals(206, $response->getStatus());
$this->assertEquals('contents', $response->getBodyAsString());
-
}
/**
* @depends testRange
*/
- function testTooHighRange() {
-
+ public function testTooHighRange()
+ {
$request = new HTTP\Request('GET', '/files/test.txt', ['Range' => 'bytes=100-200']);
$response = $this->request($request);
$this->assertEquals(416, $response->getStatus());
-
}
/**
* @depends testRange
*/
- function testCrazyRange() {
-
+ public function testCrazyRange()
+ {
$request = new HTTP\Request('GET', '/files/test.txt', ['Range' => 'bytes=8-4']);
$response = $this->request($request);
$this->assertEquals(416, $response->getStatus());
-
}
- function testNonSeekableStream() {
-
+ public function testNonSeekableStream()
+ {
$request = new HTTP\Request('GET', '/files/no-seeking.txt', ['Range' => 'bytes=2-5']);
$response = $this->request($request);
$this->assertEquals(206, $response->getStatus(), $response);
$this->assertEquals([
'X-Sabre-Version' => [Version::VERSION],
- 'Content-Type' => ['application/octet-stream'],
- 'Content-Length' => [4],
- 'Content-Range' => ['bytes 2-5/12'],
+ 'Content-Type' => ['application/octet-stream'],
+ 'Content-Length' => [4],
+ 'Content-Range' => ['bytes 2-5/12'],
// 'ETag' => ['"' . md5('Test contents') . '"'],
'Last-Modified' => [$this->lastModified],
],
@@ -150,113 +146,107 @@ class ServerRangeTest extends \Sabre\DAVServerTest {
);
$this->assertEquals('st c', $response->getBodyAsString());
-
}
/**
* @depends testRange
*/
- function testIfRangeEtag() {
-
+ public function testIfRangeEtag()
+ {
$request = new HTTP\Request('GET', '/files/test.txt', [
- 'Range' => 'bytes=2-5',
- 'If-Range' => '"' . md5('Test contents') . '"',
+ 'Range' => 'bytes=2-5',
+ 'If-Range' => '"'.md5('Test contents').'"',
]);
$response = $this->request($request);
$this->assertEquals([
'X-Sabre-Version' => [Version::VERSION],
- 'Content-Type' => ['application/octet-stream'],
- 'Content-Length' => [4],
- 'Content-Range' => ['bytes 2-5/13'],
- 'ETag' => ['"' . md5('Test contents') . '"'],
- 'Last-Modified' => [$this->lastModified],
+ 'Content-Type' => ['application/octet-stream'],
+ 'Content-Length' => [4],
+ 'Content-Range' => ['bytes 2-5/13'],
+ 'ETag' => ['"'.md5('Test contents').'"'],
+ 'Last-Modified' => [$this->lastModified],
],
$response->getHeaders()
);
$this->assertEquals(206, $response->getStatus());
$this->assertEquals('st c', $response->getBodyAsString());
-
}
/**
* @depends testIfRangeEtag
*/
- function testIfRangeEtagIncorrect() {
-
+ public function testIfRangeEtagIncorrect()
+ {
$request = new HTTP\Request('GET', '/files/test.txt', [
- 'Range' => 'bytes=2-5',
+ 'Range' => 'bytes=2-5',
'If-Range' => '"foobar"',
]);
$response = $this->request($request);
$this->assertEquals([
'X-Sabre-Version' => [Version::VERSION],
- 'Content-Type' => ['application/octet-stream'],
- 'Content-Length' => [13],
- 'ETag' => ['"' . md5('Test contents') . '"'],
- 'Last-Modified' => [$this->lastModified],
+ 'Content-Type' => ['application/octet-stream'],
+ 'Content-Length' => [13],
+ 'ETag' => ['"'.md5('Test contents').'"'],
+ 'Last-Modified' => [$this->lastModified],
],
$response->getHeaders()
);
$this->assertEquals(200, $response->getStatus());
$this->assertEquals('Test contents', $response->getBodyAsString());
-
}
/**
* @depends testIfRangeEtag
*/
- function testIfRangeModificationDate() {
-
+ public function testIfRangeModificationDate()
+ {
$request = new HTTP\Request('GET', '/files/test.txt', [
- 'Range' => 'bytes=2-5',
+ 'Range' => 'bytes=2-5',
'If-Range' => 'tomorrow',
]);
$response = $this->request($request);
$this->assertEquals([
'X-Sabre-Version' => [Version::VERSION],
- 'Content-Type' => ['application/octet-stream'],
- 'Content-Length' => [4],
- 'Content-Range' => ['bytes 2-5/13'],
- 'ETag' => ['"' . md5('Test contents') . '"'],
- 'Last-Modified' => [$this->lastModified],
+ 'Content-Type' => ['application/octet-stream'],
+ 'Content-Length' => [4],
+ 'Content-Range' => ['bytes 2-5/13'],
+ 'ETag' => ['"'.md5('Test contents').'"'],
+ 'Last-Modified' => [$this->lastModified],
],
$response->getHeaders()
);
$this->assertEquals(206, $response->getStatus());
$this->assertEquals('st c', $response->getBodyAsString());
-
}
/**
* @depends testIfRangeModificationDate
*/
- function testIfRangeModificationDateModified() {
-
+ public function testIfRangeModificationDateModified()
+ {
$request = new HTTP\Request('GET', '/files/test.txt', [
- 'Range' => 'bytes=2-5',
+ 'Range' => 'bytes=2-5',
'If-Range' => '-2 years',
]);
$response = $this->request($request);
$this->assertEquals([
'X-Sabre-Version' => [Version::VERSION],
- 'Content-Type' => ['application/octet-stream'],
- 'Content-Length' => [13],
- 'ETag' => ['"' . md5('Test contents') . '"'],
- 'Last-Modified' => [$this->lastModified],
+ 'Content-Type' => ['application/octet-stream'],
+ 'Content-Length' => [13],
+ 'ETag' => ['"'.md5('Test contents').'"'],
+ 'Last-Modified' => [$this->lastModified],
],
$response->getHeaders()
);
$this->assertEquals(200, $response->getStatus());
$this->assertEquals('Test contents', $response->getBodyAsString());
-
}
-
}