aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/sabre/dav/tests/Sabre/DAV/PartialUpdate
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/sabre/dav/tests/Sabre/DAV/PartialUpdate')
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAV/PartialUpdate/FileMock.php79
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAV/PartialUpdate/PluginTest.php73
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAV/PartialUpdate/SpecificationTest.php40
3 files changed, 83 insertions, 109 deletions
diff --git a/vendor/sabre/dav/tests/Sabre/DAV/PartialUpdate/FileMock.php b/vendor/sabre/dav/tests/Sabre/DAV/PartialUpdate/FileMock.php
index eff1e7d67..72fdb5ec8 100644
--- a/vendor/sabre/dav/tests/Sabre/DAV/PartialUpdate/FileMock.php
+++ b/vendor/sabre/dav/tests/Sabre/DAV/PartialUpdate/FileMock.php
@@ -1,20 +1,21 @@
<?php
+declare(strict_types=1);
+
namespace Sabre\DAV\PartialUpdate;
use Sabre\DAV;
-class FileMock implements IPatchSupport {
-
+class FileMock implements IPatchSupport
+{
protected $data = '';
- function put($str) {
-
+ public function put($str)
+ {
if (is_resource($str)) {
$str = stream_get_contents($str);
}
$this->data = $str;
-
}
/**
@@ -40,83 +41,71 @@ class FileMock implements IPatchSupport {
* time.
*
* @param resource|string $data
- * @param int $rangeType
- * @param int $offset
+ * @param int $rangeType
+ * @param int $offset
+ *
* @return string|null
*/
- function patch($data, $rangeType, $offset = null) {
-
+ public function patch($data, $rangeType, $offset = null)
+ {
if (is_resource($data)) {
$data = stream_get_contents($data);
}
switch ($rangeType) {
-
- case 1 :
+ case 1:
$this->data .= $data;
break;
- case 3 :
+ case 3:
// Turn the offset into an offset-offset.
$offset = strlen($this->data) - $offset;
- // No break is intentional
- case 2 :
+ // no break is intentional
+ case 2:
$this->data =
- substr($this->data, 0, $offset) .
- $data .
+ substr($this->data, 0, $offset).
+ $data.
substr($this->data, $offset + strlen($data));
break;
-
}
-
}
- function get() {
-
+ public function get()
+ {
return $this->data;
-
}
- function getContentType() {
-
+ public function getContentType()
+ {
return 'text/plain';
-
}
- function getSize() {
-
+ public function getSize()
+ {
return strlen($this->data);
-
}
- function getETag() {
-
- return '"' . $this->data . '"';
-
+ public function getETag()
+ {
+ return '"'.$this->data.'"';
}
- function delete() {
-
+ public function delete()
+ {
throw new DAV\Exception\MethodNotAllowed();
-
}
- function setName($name) {
-
+ public function setName($name)
+ {
throw new DAV\Exception\MethodNotAllowed();
-
}
- function getName() {
-
+ public function getName()
+ {
return 'partial';
-
}
- function getLastModified() {
-
+ public function getLastModified()
+ {
return null;
-
}
-
-
}
diff --git a/vendor/sabre/dav/tests/Sabre/DAV/PartialUpdate/PluginTest.php b/vendor/sabre/dav/tests/Sabre/DAV/PartialUpdate/PluginTest.php
index 5bd696416..63d692ec9 100644
--- a/vendor/sabre/dav/tests/Sabre/DAV/PartialUpdate/PluginTest.php
+++ b/vendor/sabre/dav/tests/Sabre/DAV/PartialUpdate/PluginTest.php
@@ -1,19 +1,20 @@
<?php
+declare(strict_types=1);
+
namespace Sabre\DAV\PartialUpdate;
-use Sabre\DAV;
use Sabre\HTTP;
require_once 'Sabre/DAV/PartialUpdate/FileMock.php';
-class PluginTest extends \Sabre\DAVServerTest {
-
+class PluginTest extends \Sabre\DAVServerTest
+{
protected $node;
protected $plugin;
- function setUp() {
-
+ public function setUp()
+ {
$this->node = new FileMock();
$this->tree[] = $this->node;
@@ -21,38 +22,33 @@ class PluginTest extends \Sabre\DAVServerTest {
$this->plugin = new Plugin();
$this->server->addPlugin($this->plugin);
-
-
-
}
- function testInit() {
-
+ public function testInit()
+ {
$this->assertEquals('partialupdate', $this->plugin->getPluginName());
$this->assertEquals(['sabredav-partialupdate'], $this->plugin->getFeatures());
$this->assertEquals([
- 'PATCH'
+ 'PATCH',
], $this->plugin->getHTTPMethods('partial'));
$this->assertEquals([
], $this->plugin->getHTTPMethods(''));
-
}
- function testPatchNoRange() {
-
+ public function testPatchNoRange()
+ {
$this->node->put('aaaaaaaa');
$request = HTTP\Sapi::createFromServerArray([
'REQUEST_METHOD' => 'PATCH',
- 'REQUEST_URI' => '/partial',
+ 'REQUEST_URI' => '/partial',
]);
$response = $this->request($request);
- $this->assertEquals(400, $response->status, 'Full response body:' . $response->body);
-
+ $this->assertEquals(400, $response->status, 'Full response body:'.$response->body);
}
- function testPatchNotSupported() {
-
+ public function testPatchNotSupported()
+ {
$this->node->put('aaaaaaaa');
$request = new HTTP\Request('PATCH', '/', ['X-Update-Range' => '3-4']);
$request->setBody(
@@ -60,12 +56,11 @@ class PluginTest extends \Sabre\DAVServerTest {
);
$response = $this->request($request);
- $this->assertEquals(405, $response->status, 'Full response body:' . $response->body);
-
+ $this->assertEquals(405, $response->status, 'Full response body:'.$response->body);
}
- function testPatchNoContentType() {
-
+ public function testPatchNoContentType()
+ {
$this->node->put('aaaaaaaa');
$request = new HTTP\Request('PATCH', '/partial', ['X-Update-Range' => 'bytes=3-4']);
$request->setBody(
@@ -73,12 +68,11 @@ class PluginTest extends \Sabre\DAVServerTest {
);
$response = $this->request($request);
- $this->assertEquals(415, $response->status, 'Full response body:' . $response->body);
-
+ $this->assertEquals(415, $response->status, 'Full response body:'.$response->body);
}
- function testPatchBadRange() {
-
+ public function testPatchBadRange()
+ {
$this->node->put('aaaaaaaa');
$request = new HTTP\Request('PATCH', '/partial', ['X-Update-Range' => 'bytes=3-4', 'Content-Type' => 'application/x-sabredav-partialupdate', 'Content-Length' => '3']);
$request->setBody(
@@ -86,12 +80,11 @@ class PluginTest extends \Sabre\DAVServerTest {
);
$response = $this->request($request);
- $this->assertEquals(416, $response->status, 'Full response body:' . $response->body);
-
+ $this->assertEquals(416, $response->status, 'Full response body:'.$response->body);
}
- function testPatchNoLength() {
-
+ public function testPatchNoLength()
+ {
$this->node->put('aaaaaaaa');
$request = new HTTP\Request('PATCH', '/partial', ['X-Update-Range' => 'bytes=3-5', 'Content-Type' => 'application/x-sabredav-partialupdate']);
$request->setBody(
@@ -99,12 +92,11 @@ class PluginTest extends \Sabre\DAVServerTest {
);
$response = $this->request($request);
- $this->assertEquals(411, $response->status, 'Full response body:' . $response->body);
-
+ $this->assertEquals(411, $response->status, 'Full response body:'.$response->body);
}
- function testPatchSuccess() {
-
+ public function testPatchSuccess()
+ {
$this->node->put('aaaaaaaa');
$request = new HTTP\Request('PATCH', '/partial', ['X-Update-Range' => 'bytes=3-5', 'Content-Type' => 'application/x-sabredav-partialupdate', 'Content-Length' => 3]);
$request->setBody(
@@ -112,13 +104,12 @@ class PluginTest extends \Sabre\DAVServerTest {
);
$response = $this->request($request);
- $this->assertEquals(204, $response->status, 'Full response body:' . $response->body);
+ $this->assertEquals(204, $response->status, 'Full response body:'.$response->body);
$this->assertEquals('aaabbbaa', $this->node->get());
-
}
- function testPatchNoEndRange() {
-
+ public function testPatchNoEndRange()
+ {
$this->node->put('aaaaa');
$request = new HTTP\Request('PATCH', '/partial', ['X-Update-Range' => 'bytes=3-', 'Content-Type' => 'application/x-sabredav-partialupdate', 'Content-Length' => '3']);
$request->setBody(
@@ -127,9 +118,7 @@ class PluginTest extends \Sabre\DAVServerTest {
$response = $this->request($request);
- $this->assertEquals(204, $response->getStatus(), 'Full response body:' . $response->getBodyAsString());
+ $this->assertEquals(204, $response->getStatus(), 'Full response body:'.$response->getBodyAsString());
$this->assertEquals('aaabbb', $this->node->get());
-
}
-
}
diff --git a/vendor/sabre/dav/tests/Sabre/DAV/PartialUpdate/SpecificationTest.php b/vendor/sabre/dav/tests/Sabre/DAV/PartialUpdate/SpecificationTest.php
index 2c6274173..56b2d576f 100644
--- a/vendor/sabre/dav/tests/Sabre/DAV/PartialUpdate/SpecificationTest.php
+++ b/vendor/sabre/dav/tests/Sabre/DAV/PartialUpdate/SpecificationTest.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
namespace Sabre\DAV\PartialUpdate;
use Sabre\DAV\FSExt\File;
@@ -12,14 +14,14 @@ use Sabre\HTTP;
*
* See: http://sabre.io/dav/http-patch/
*/
-class SpecificationTest extends \PHPUnit_Framework_TestCase {
-
+class SpecificationTest extends \PHPUnit\Framework\TestCase
+{
protected $server;
- function setUp() {
-
+ public function setUp()
+ {
$tree = [
- new File(SABRE_TEMPDIR . '/foobar.txt')
+ new File(SABRE_TEMPDIR.'/foobar.txt'),
];
$server = new Server($tree);
$server->debugExceptions = true;
@@ -28,32 +30,30 @@ class SpecificationTest extends \PHPUnit_Framework_TestCase {
$tree[0]->put('1234567890');
$this->server = $server;
-
}
- function tearDown() {
-
+ public function tearDown()
+ {
\Sabre\TestUtil::clearTempDir();
-
}
/**
* @param string $headerValue
* @param string $httpStatus
* @param string $endResult
- * @param int $contentLength
+ * @param int $contentLength
*
* @dataProvider data
*/
- function testUpdateRange($headerValue, $httpStatus, $endResult, $contentLength = 4) {
-
+ public function testUpdateRange($headerValue, $httpStatus, $endResult, $contentLength = 4)
+ {
$headers = [
- 'Content-Type' => 'application/x-sabredav-partialupdate',
+ 'Content-Type' => 'application/x-sabredav-partialupdate',
'X-Update-Range' => $headerValue,
];
if ($contentLength) {
- $headers['Content-Length'] = (string)$contentLength;
+ $headers['Content-Length'] = (string) $contentLength;
}
$request = new HTTP\Request('PATCH', '/foobar.txt', $headers, '----');
@@ -64,15 +64,14 @@ class SpecificationTest extends \PHPUnit_Framework_TestCase {
$this->server->sapi = new HTTP\SapiMock();
$this->server->exec();
- $this->assertEquals($httpStatus, $this->server->httpResponse->status, 'Incorrect http status received: ' . $this->server->httpResponse->body);
+ $this->assertEquals($httpStatus, $this->server->httpResponse->status, 'Incorrect http status received: '.$this->server->httpResponse->body);
if (!is_null($endResult)) {
- $this->assertEquals($endResult, file_get_contents(SABRE_TEMPDIR . '/foobar.txt'));
+ $this->assertEquals($endResult, file_get_contents(SABRE_TEMPDIR.'/foobar.txt'));
}
-
}
- function data() {
-
+ public function data()
+ {
return [
// Problems
['foo', 400, null],
@@ -86,9 +85,6 @@ class SpecificationTest extends \PHPUnit_Framework_TestCase {
['bytes=-2', 204, '12345678----'],
['bytes=2-', 204, '12----7890'],
['append', 204, '1234567890----'],
-
];
-
}
-
}