aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/sabre/dav/tests/Sabre/DAV/TemporaryFileFilterTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/sabre/dav/tests/Sabre/DAV/TemporaryFileFilterTest.php')
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAV/TemporaryFileFilterTest.php85
1 files changed, 44 insertions, 41 deletions
diff --git a/vendor/sabre/dav/tests/Sabre/DAV/TemporaryFileFilterTest.php b/vendor/sabre/dav/tests/Sabre/DAV/TemporaryFileFilterTest.php
index 6acd6b077..352c8a3e7 100644
--- a/vendor/sabre/dav/tests/Sabre/DAV/TemporaryFileFilterTest.php
+++ b/vendor/sabre/dav/tests/Sabre/DAV/TemporaryFileFilterTest.php
@@ -1,21 +1,22 @@
<?php
+declare(strict_types=1);
+
namespace Sabre\DAV;
use Sabre\HTTP;
-class TemporaryFileFilterTest extends AbstractServer {
-
- function setUp() {
-
+class TemporaryFileFilterTest extends AbstractServer
+{
+ public function setUp()
+ {
parent::setUp();
- $plugin = new TemporaryFileFilterPlugin(SABRE_TEMPDIR . '/tff');
+ $plugin = new TemporaryFileFilterPlugin(SABRE_TEMPDIR.'/tff');
$this->server->addPlugin($plugin);
-
}
- function testPutNormal() {
-
+ public function testPutNormal()
+ {
$request = new HTTP\Request('PUT', '/testput.txt', [], 'Testing new file');
$this->server->httpRequest = ($request);
@@ -25,12 +26,11 @@ class TemporaryFileFilterTest extends AbstractServer {
$this->assertEquals(201, $this->response->status);
$this->assertEquals('0', $this->response->getHeader('Content-Length'));
- $this->assertEquals('Testing new file', file_get_contents(SABRE_TEMPDIR . '/testput.txt'));
-
+ $this->assertEquals('Testing new file', file_get_contents(SABRE_TEMPDIR.'/testput.txt'));
}
- function testPutTemp() {
-
+ public function testPutTemp()
+ {
// mimicking an OS/X resource fork
$request = new HTTP\Request('PUT', '/._testput.txt', [], 'Testing new file');
@@ -43,12 +43,11 @@ class TemporaryFileFilterTest extends AbstractServer {
'X-Sabre-Temp' => ['true'],
], $this->response->getHeaders());
- $this->assertFalse(file_exists(SABRE_TEMPDIR . '/._testput.txt'), '._testput.txt should not exist in the regular file structure.');
-
+ $this->assertFalse(file_exists(SABRE_TEMPDIR.'/._testput.txt'), '._testput.txt should not exist in the regular file structure.');
}
- function testPutTempIfNoneMatch() {
-
+ public function testPutTempIfNoneMatch()
+ {
// mimicking an OS/X resource fork
$request = new HTTP\Request('PUT', '/._testput.txt', ['If-None-Match' => '*'], 'Testing new file');
@@ -61,8 +60,7 @@ class TemporaryFileFilterTest extends AbstractServer {
'X-Sabre-Temp' => ['true'],
], $this->response->getHeaders());
- $this->assertFalse(file_exists(SABRE_TEMPDIR . '/._testput.txt'), '._testput.txt should not exist in the regular file structure.');
-
+ $this->assertFalse(file_exists(SABRE_TEMPDIR.'/._testput.txt'), '._testput.txt should not exist in the regular file structure.');
$this->server->exec();
@@ -71,11 +69,10 @@ class TemporaryFileFilterTest extends AbstractServer {
'X-Sabre-Temp' => ['true'],
'Content-Type' => ['application/xml; charset=utf-8'],
], $this->response->getHeaders());
-
}
- function testPutGet() {
-
+ public function testPutGet()
+ {
// mimicking an OS/X resource fork
$request = new HTTP\Request('PUT', '/._testput.txt', [], 'Testing new file');
$this->server->httpRequest = ($request);
@@ -94,19 +91,29 @@ class TemporaryFileFilterTest extends AbstractServer {
$this->assertEquals(200, $this->response->status);
$this->assertEquals([
- 'X-Sabre-Temp' => ['true'],
+ 'X-Sabre-Temp' => ['true'],
'Content-Length' => [16],
- 'Content-Type' => ['application/octet-stream'],
+ 'Content-Type' => ['application/octet-stream'],
], $this->response->getHeaders());
$this->assertEquals('Testing new file', stream_get_contents($this->response->body));
-
}
- function testLockNonExistant() {
+ public function testGetWithBrowserPlugin()
+ {
+ $this->server->addPlugin(new Browser\Plugin());
+ $request = new HTTP\Request('GET', '/');
+
+ $this->server->httpRequest = $request;
+ $this->server->exec();
+
+ $this->assertEquals(200, $this->response->status);
+ }
- mkdir(SABRE_TEMPDIR . '/locksdir');
- $locksBackend = new Locks\Backend\File(SABRE_TEMPDIR . '/locks');
+ public function testLockNonExistant()
+ {
+ mkdir(SABRE_TEMPDIR.'/locksdir');
+ $locksBackend = new Locks\Backend\File(SABRE_TEMPDIR.'/locks');
$locksPlugin = new Locks\Plugin($locksBackend);
$this->server->addPlugin($locksPlugin);
@@ -126,15 +133,14 @@ class TemporaryFileFilterTest extends AbstractServer {
$this->assertEquals(201, $this->response->status);
$this->assertEquals('application/xml; charset=utf-8', $this->response->getHeader('Content-Type'));
- $this->assertTrue(preg_match('/^<opaquelocktoken:(.*)>$/', $this->response->getHeader('Lock-Token')) === 1, 'We did not get a valid Locktoken back (' . $this->response->getHeader('Lock-Token') . ')');
+ $this->assertTrue(1 === preg_match('/^<opaquelocktoken:(.*)>$/', $this->response->getHeader('Lock-Token')), 'We did not get a valid Locktoken back ('.$this->response->getHeader('Lock-Token').')');
$this->assertEquals('true', $this->response->getHeader('X-Sabre-Temp'));
- $this->assertFalse(file_exists(SABRE_TEMPDIR . '/._testlock.txt'), '._testlock.txt should not exist in the regular file structure.');
-
+ $this->assertFalse(file_exists(SABRE_TEMPDIR.'/._testlock.txt'), '._testlock.txt should not exist in the regular file structure.');
}
- function testPutDelete() {
-
+ public function testPutDelete()
+ {
// mimicking an OS/X resource fork
$request = new HTTP\Request('PUT', '/._testput.txt', [], 'Testing new file');
@@ -151,17 +157,16 @@ class TemporaryFileFilterTest extends AbstractServer {
$this->server->httpRequest = $request;
$this->server->exec();
- $this->assertEquals(204, $this->response->status, "Incorrect status code received. Full body:\n" . $this->response->body);
+ $this->assertEquals(204, $this->response->status, "Incorrect status code received. Full body:\n".$this->response->body);
$this->assertEquals([
'X-Sabre-Temp' => ['true'],
], $this->response->getHeaders());
$this->assertEquals('', $this->response->body);
-
}
- function testPutPropfind() {
-
+ public function testPutPropfind()
+ {
// mimicking an OS/X resource fork
$request = new HTTP\Request('PUT', '/._testput.txt', [], 'Testing new file');
$this->server->httpRequest = $request;
@@ -178,22 +183,20 @@ class TemporaryFileFilterTest extends AbstractServer {
$this->server->httpRequest = ($request);
$this->server->exec();
- $this->assertEquals(207, $this->response->status, 'Incorrect status code returned. Body: ' . $this->response->body);
+ $this->assertEquals(207, $this->response->status, 'Incorrect status code returned. Body: '.$this->response->body);
$this->assertEquals([
'X-Sabre-Temp' => ['true'],
'Content-Type' => ['application/xml; charset=utf-8'],
], $this->response->getHeaders());
- $body = preg_replace("/xmlns(:[A-Za-z0-9_])?=(\"|\')DAV:(\"|\')/", "xmlns\\1=\"urn:DAV\"", $this->response->body);
+ $body = preg_replace("/xmlns(:[A-Za-z0-9_])?=(\"|\')DAV:(\"|\')/", 'xmlns\\1="urn:DAV"', $this->response->body);
$xml = simplexml_load_string($body);
$xml->registerXPathNamespace('d', 'urn:DAV');
list($data) = $xml->xpath('/d:multistatus/d:response/d:href');
- $this->assertEquals('/._testput.txt', (string)$data, 'href element should have been /._testput.txt');
+ $this->assertEquals('/._testput.txt', (string) $data, 'href element should have been /._testput.txt');
$data = $xml->xpath('/d:multistatus/d:response/d:propstat/d:prop/d:resourcetype');
$this->assertEquals(1, count($data));
-
}
-
}