From 580c3f4ffe9608d2beb56d418c68b3b112420e76 Mon Sep 17 00:00:00 2001 From: Mario Date: Sun, 10 Nov 2019 12:49:51 +0000 Subject: another bulk of composer updates (cherry picked from commit 6685381fd8db507493c3d7c1793f8c05c681bbce) --- .../tests/Sabre/DAV/TemporaryFileFilterTest.php | 85 +++++++++++----------- 1 file changed, 44 insertions(+), 41 deletions(-) (limited to 'vendor/sabre/dav/tests/Sabre/DAV/TemporaryFileFilterTest.php') 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 @@ 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('/^$/', $this->response->getHeader('Lock-Token')) === 1, 'We did not get a valid Locktoken back (' . $this->response->getHeader('Lock-Token') . ')'); + $this->assertTrue(1 === preg_match('/^$/', $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)); - } - } -- cgit v1.2.3