diff options
Diffstat (limited to 'vendor/sabre/dav/tests/Sabre/DAV/Browser')
3 files changed, 88 insertions, 100 deletions
diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Browser/GuessContentTypeTest.php b/vendor/sabre/dav/tests/Sabre/DAV/Browser/GuessContentTypeTest.php index 54a3053ec..1f48256e0 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/Browser/GuessContentTypeTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/Browser/GuessContentTypeTest.php @@ -1,29 +1,30 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Browser; use Sabre\DAV; require_once 'Sabre/DAV/AbstractServer.php'; -class GuessContentTypeTest extends DAV\AbstractServer { - - function setUp() { - +class GuessContentTypeTest extends DAV\AbstractServer +{ + public function setUp() + { parent::setUp(); \Sabre\TestUtil::clearTempDir(); - file_put_contents(SABRE_TEMPDIR . '/somefile.jpg', 'blabla'); - file_put_contents(SABRE_TEMPDIR . '/somefile.hoi', 'blabla'); - + file_put_contents(SABRE_TEMPDIR.'/somefile.jpg', 'blabla'); + file_put_contents(SABRE_TEMPDIR.'/somefile.hoi', 'blabla'); } - function tearDown() { - + public function tearDown() + { \Sabre\TestUtil::clearTempDir(); parent::tearDown(); } - function testGetProperties() { - + public function testGetProperties() + { $properties = [ '{DAV:}getcontenttype', ]; @@ -31,31 +32,29 @@ class GuessContentTypeTest extends DAV\AbstractServer { $this->assertArrayHasKey(0, $result); $this->assertArrayHasKey(404, $result[0]); $this->assertArrayHasKey('{DAV:}getcontenttype', $result[0][404]); - } /** * @depends testGetProperties */ - function testGetPropertiesPluginEnabled() { - + public function testGetPropertiesPluginEnabled() + { $this->server->addPlugin(new GuessContentType()); $properties = [ '{DAV:}getcontenttype', ]; $result = $this->server->getPropertiesForPath('/somefile.jpg', $properties); $this->assertArrayHasKey(0, $result); - $this->assertArrayHasKey(200, $result[0], 'We received: ' . print_r($result, true)); + $this->assertArrayHasKey(200, $result[0], 'We received: '.print_r($result, true)); $this->assertArrayHasKey('{DAV:}getcontenttype', $result[0][200]); $this->assertEquals('image/jpeg', $result[0][200]['{DAV:}getcontenttype']); - } /** * @depends testGetPropertiesPluginEnabled */ - function testGetPropertiesUnknown() { - + public function testGetPropertiesUnknown() + { $this->server->addPlugin(new GuessContentType()); $properties = [ '{DAV:}getcontenttype', @@ -65,6 +64,5 @@ class GuessContentTypeTest extends DAV\AbstractServer { $this->assertArrayHasKey(200, $result[0]); $this->assertArrayHasKey('{DAV:}getcontenttype', $result[0][200]); $this->assertEquals('application/octet-stream', $result[0][200]['{DAV:}getcontenttype']); - } } diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Browser/MapGetToPropFindTest.php b/vendor/sabre/dav/tests/Sabre/DAV/Browser/MapGetToPropFindTest.php index 33c4ede96..de7b85f32 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/Browser/MapGetToPropFindTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/Browser/MapGetToPropFindTest.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Browser; use Sabre\DAV; @@ -7,19 +9,18 @@ use Sabre\HTTP; require_once 'Sabre/DAV/AbstractServer.php'; -class MapGetToPropFindTest extends DAV\AbstractServer { - - function setUp() { - +class MapGetToPropFindTest extends DAV\AbstractServer +{ + public function setUp() + { parent::setUp(); $this->server->addPlugin(new MapGetToPropFind()); - } - function testCollectionGet() { - + public function testCollectionGet() + { $serverVars = [ - 'REQUEST_URI' => '/', + 'REQUEST_URI' => '/', 'REQUEST_METHOD' => 'GET', ]; @@ -28,17 +29,14 @@ class MapGetToPropFindTest extends DAV\AbstractServer { $this->server->httpRequest = ($request); $this->server->exec(); - $this->assertEquals(207, $this->response->status, 'Incorrect status response received. Full response body: ' . $this->response->body); + $this->assertEquals(207, $this->response->status, 'Incorrect status response received. Full response body: '.$this->response->body); $this->assertEquals([ 'X-Sabre-Version' => [DAV\Version::VERSION], - 'Content-Type' => ['application/xml; charset=utf-8'], - 'DAV' => ['1, 3, extended-mkcol'], - 'Vary' => ['Brief,Prefer'], + 'Content-Type' => ['application/xml; charset=utf-8'], + 'DAV' => ['1, 3, extended-mkcol'], + 'Vary' => ['Brief,Prefer'], ], $this->response->getHeaders() ); - } - - } diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Browser/PluginTest.php b/vendor/sabre/dav/tests/Sabre/DAV/Browser/PluginTest.php index f20c50f86..fb7c63d46 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/Browser/PluginTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/Browser/PluginTest.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Browser; use Sabre\DAV; @@ -7,129 +9,123 @@ use Sabre\HTTP; require_once 'Sabre/DAV/AbstractServer.php'; -class PluginTest extends DAV\AbstractServer{ - +class PluginTest extends DAV\AbstractServer +{ protected $plugin; - function setUp() { - + public function setUp() + { parent::setUp(); $this->server->addPlugin($this->plugin = new Plugin()); $this->server->tree->getNodeForPath('')->createDirectory('dir2'); - } - function testCollectionGet() { - + public function testCollectionGet() + { $request = new HTTP\Request('GET', '/dir'); $this->server->httpRequest = $request; $this->server->exec(); - $this->assertEquals(200, $this->response->getStatus(), "Incorrect status received. Full response body: " . $this->response->getBodyAsString()); + $this->assertEquals(200, $this->response->getStatus(), 'Incorrect status received. Full response body: '.$this->response->getBodyAsString()); $this->assertEquals( [ - 'X-Sabre-Version' => [DAV\Version::VERSION], - 'Content-Type' => ['text/html; charset=utf-8'], - 'Content-Security-Policy' => ["default-src 'none'; img-src 'self'; style-src 'self'; font-src 'self';"] + 'X-Sabre-Version' => [DAV\Version::VERSION], + 'Content-Type' => ['text/html; charset=utf-8'], + 'Content-Security-Policy' => ["default-src 'none'; img-src 'self'; style-src 'self'; font-src 'self';"], ], $this->response->getHeaders() ); $body = $this->response->getBodyAsString(); - $this->assertTrue(strpos($body, '<title>dir') !== false, $body); - $this->assertTrue(strpos($body, '<a href="/dir/child.txt">') !== false); - + $this->assertTrue(false !== strpos($body, '<title>dir'), $body); + $this->assertTrue(false !== strpos($body, '<a href="/dir/child.txt">')); } /** * Adding the If-None-Match should have 0 effect, but it threw an error. */ - function testCollectionGetIfNoneMatch() { - + public function testCollectionGetIfNoneMatch() + { $request = new HTTP\Request('GET', '/dir'); $request->setHeader('If-None-Match', '"foo-bar"'); $this->server->httpRequest = $request; $this->server->exec(); - $this->assertEquals(200, $this->response->getStatus(), "Incorrect status received. Full response body: " . $this->response->getBodyAsString()); + $this->assertEquals(200, $this->response->getStatus(), 'Incorrect status received. Full response body: '.$this->response->getBodyAsString()); $this->assertEquals( [ - 'X-Sabre-Version' => [DAV\Version::VERSION], - 'Content-Type' => ['text/html; charset=utf-8'], - 'Content-Security-Policy' => ["default-src 'none'; img-src 'self'; style-src 'self'; font-src 'self';"] + 'X-Sabre-Version' => [DAV\Version::VERSION], + 'Content-Type' => ['text/html; charset=utf-8'], + 'Content-Security-Policy' => ["default-src 'none'; img-src 'self'; style-src 'self'; font-src 'self';"], ], $this->response->getHeaders() ); $body = $this->response->getBodyAsString(); - $this->assertTrue(strpos($body, '<title>dir') !== false, $body); - $this->assertTrue(strpos($body, '<a href="/dir/child.txt">') !== false); - + $this->assertTrue(false !== strpos($body, '<title>dir'), $body); + $this->assertTrue(false !== strpos($body, '<a href="/dir/child.txt">')); } - function testCollectionGetRoot() { + public function testCollectionGetRoot() + { $request = new HTTP\Request('GET', '/'); $this->server->httpRequest = ($request); $this->server->exec(); - $this->assertEquals(200, $this->response->status, "Incorrect status received. Full response body: " . $this->response->getBodyAsString()); + $this->assertEquals(200, $this->response->status, 'Incorrect status received. Full response body: '.$this->response->getBodyAsString()); $this->assertEquals( [ - 'X-Sabre-Version' => [DAV\Version::VERSION], - 'Content-Type' => ['text/html; charset=utf-8'], - 'Content-Security-Policy' => ["default-src 'none'; img-src 'self'; style-src 'self'; font-src 'self';"] + 'X-Sabre-Version' => [DAV\Version::VERSION], + 'Content-Type' => ['text/html; charset=utf-8'], + 'Content-Security-Policy' => ["default-src 'none'; img-src 'self'; style-src 'self'; font-src 'self';"], ], $this->response->getHeaders() ); $body = $this->response->getBodyAsString(); - $this->assertTrue(strpos($body, '<title>/') !== false, $body); - $this->assertTrue(strpos($body, '<a href="/dir/">') !== false); - $this->assertTrue(strpos($body, '<span class="btn disabled">') !== false); - + $this->assertTrue(false !== strpos($body, '<title>/'), $body); + $this->assertTrue(false !== strpos($body, '<a href="/dir/">')); + $this->assertTrue(false !== strpos($body, '<span class="btn disabled">')); } - function testGETPassthru() { - + public function testGETPassthru() + { $request = new HTTP\Request('GET', '/random'); $response = new HTTP\Response(); $this->assertNull( $this->plugin->httpGet($request, $response) ); - } - function testPostOtherContentType() { - + public function testPostOtherContentType() + { $request = new HTTP\Request('POST', '/', ['Content-Type' => 'text/xml']); $this->server->httpRequest = $request; $this->server->exec(); $this->assertEquals(501, $this->response->status); - } - function testPostNoSabreAction() { - + public function testPostNoSabreAction() + { $request = new HTTP\Request('POST', '/', ['Content-Type' => 'application/x-www-form-urlencoded']); $request->setPostData([]); $this->server->httpRequest = $request; $this->server->exec(); $this->assertEquals(501, $this->response->status); - } - function testPostMkCol() { - + public function testPostMkCol() + { $serverVars = [ - 'REQUEST_URI' => '/', + 'REQUEST_URI' => '/', 'REQUEST_METHOD' => 'POST', - 'CONTENT_TYPE' => 'application/x-www-form-urlencoded', + 'CONTENT_TYPE' => 'application/x-www-form-urlencoded', ]; $postVars = [ 'sabreAction' => 'mkcol', - 'name' => 'new_collection', + 'name' => 'new_collection', ]; $request = HTTP\Sapi::createFromServerArray($serverVars); @@ -140,47 +136,43 @@ class PluginTest extends DAV\AbstractServer{ $this->assertEquals(302, $this->response->status); $this->assertEquals([ 'X-Sabre-Version' => [DAV\Version::VERSION], - 'Location' => ['/'], + 'Location' => ['/'], ], $this->response->getHeaders()); - $this->assertTrue(is_dir(SABRE_TEMPDIR . '/new_collection')); - + $this->assertTrue(is_dir(SABRE_TEMPDIR.'/new_collection')); } - function testGetAsset() { - + public function testGetAsset() + { $request = new HTTP\Request('GET', '/?sabreAction=asset&assetName=favicon.ico'); $this->server->httpRequest = $request; $this->server->exec(); - $this->assertEquals(200, $this->response->getStatus(), 'Error: ' . $this->response->body); + $this->assertEquals(200, $this->response->getStatus(), 'Error: '.$this->response->body); $this->assertEquals([ - 'X-Sabre-Version' => [DAV\Version::VERSION], - 'Content-Type' => ['image/vnd.microsoft.icon'], - 'Content-Length' => ['4286'], - 'Cache-Control' => ['public, max-age=1209600'], - 'Content-Security-Policy' => ["default-src 'none'; img-src 'self'; style-src 'self'; font-src 'self';"] + 'X-Sabre-Version' => [DAV\Version::VERSION], + 'Content-Type' => ['image/vnd.microsoft.icon'], + 'Content-Length' => ['4286'], + 'Cache-Control' => ['public, max-age=1209600'], + 'Content-Security-Policy' => ["default-src 'none'; img-src 'self'; style-src 'self'; font-src 'self';"], ], $this->response->getHeaders()); - } - function testGetAsset404() { - + public function testGetAsset404() + { $request = new HTTP\Request('GET', '/?sabreAction=asset&assetName=flavicon.ico'); $this->server->httpRequest = $request; $this->server->exec(); - $this->assertEquals(404, $this->response->getStatus(), 'Error: ' . $this->response->body); - + $this->assertEquals(404, $this->response->getStatus(), 'Error: '.$this->response->body); } - function testGetAssetEscapeBasePath() { - + public function testGetAssetEscapeBasePath() + { $request = new HTTP\Request('GET', '/?sabreAction=asset&assetName=./../assets/favicon.ico'); $this->server->httpRequest = $request; $this->server->exec(); - $this->assertEquals(404, $this->response->getStatus(), 'Error: ' . $this->response->body); - + $this->assertEquals(404, $this->response->getStatus(), 'Error: '.$this->response->body); } } |