aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/sabre/dav/tests/Sabre/DAV/Browser
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2013-10-21 15:46:31 -0700
committerfriendica <info@friendica.com>2013-10-21 15:46:31 -0700
commitb35122f7a6ad42756c35bb60ba1f06c3dcd45c77 (patch)
treeccdf373ce6475d264778523259cc32899b732fe7 /vendor/sabre/dav/tests/Sabre/DAV/Browser
parente3504df514d306cfe6b83e44a11f550664564af4 (diff)
downloadvolse-hubzilla-b35122f7a6ad42756c35bb60ba1f06c3dcd45c77.tar.gz
volse-hubzilla-b35122f7a6ad42756c35bb60ba1f06c3dcd45c77.tar.bz2
volse-hubzilla-b35122f7a6ad42756c35bb60ba1f06c3dcd45c77.zip
add sabre (1.8.x) via composer in the !@#$ place it wants to be
Diffstat (limited to 'vendor/sabre/dav/tests/Sabre/DAV/Browser')
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAV/Browser/GuessContentTypeTest.php68
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAV/Browser/MapGetToPropFindTest.php44
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAV/Browser/PluginTest.php114
3 files changed, 226 insertions, 0 deletions
diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Browser/GuessContentTypeTest.php b/vendor/sabre/dav/tests/Sabre/DAV/Browser/GuessContentTypeTest.php
new file mode 100644
index 000000000..6fc65f9e8
--- /dev/null
+++ b/vendor/sabre/dav/tests/Sabre/DAV/Browser/GuessContentTypeTest.php
@@ -0,0 +1,68 @@
+<?php
+
+namespace Sabre\DAV\Browser;
+
+use Sabre\DAV;
+
+require_once 'Sabre/DAV/AbstractServer.php';
+class GuessContentTypeTest extends DAV\AbstractServer {
+
+ function setUp() {
+
+ parent::setUp();
+ file_put_contents(SABRE_TEMPDIR . '/somefile.jpg','blabla');
+ file_put_contents(SABRE_TEMPDIR . '/somefile.hoi','blabla');
+
+ }
+
+ function tearDown() {
+
+ unlink(SABRE_TEMPDIR . '/somefile.jpg');
+ parent::tearDown();
+ }
+
+ function testGetProperties() {
+
+ $properties = array(
+ '{DAV:}getcontenttype',
+ );
+ $result = $this->server->getPropertiesForPath('/somefile.jpg',$properties);
+ $this->assertArrayHasKey(0,$result);
+ $this->assertArrayHasKey(404,$result[0]);
+ $this->assertArrayHasKey('{DAV:}getcontenttype',$result[0][404]);
+
+ }
+
+ /**
+ * @depends testGetProperties
+ */
+ function testGetPropertiesPluginEnabled() {
+
+ $this->server->addPlugin(new GuessContentType());
+ $properties = array(
+ '{DAV:}getcontenttype',
+ );
+ $result = $this->server->getPropertiesForPath('/somefile.jpg',$properties);
+ $this->assertArrayHasKey(0,$result);
+ $this->assertArrayHasKey(200,$result[0]);
+ $this->assertArrayHasKey('{DAV:}getcontenttype',$result[0][200]);
+ $this->assertEquals('image/jpeg',$result[0][200]['{DAV:}getcontenttype']);
+
+ }
+
+ /**
+ * @depends testGetPropertiesPluginEnabled
+ */
+ function testGetPropertiesUnknown() {
+
+ $this->server->addPlugin(new GuessContentType());
+ $properties = array(
+ '{DAV:}getcontenttype',
+ );
+ $result = $this->server->getPropertiesForPath('/somefile.hoi',$properties);
+ $this->assertArrayHasKey(0,$result);
+ $this->assertArrayHasKey(404,$result[0]);
+ $this->assertArrayHasKey('{DAV:}getcontenttype',$result[0][404]);
+
+ }
+}
diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Browser/MapGetToPropFindTest.php b/vendor/sabre/dav/tests/Sabre/DAV/Browser/MapGetToPropFindTest.php
new file mode 100644
index 000000000..169675e7e
--- /dev/null
+++ b/vendor/sabre/dav/tests/Sabre/DAV/Browser/MapGetToPropFindTest.php
@@ -0,0 +1,44 @@
+<?php
+
+namespace Sabre\DAV\Browser;
+
+use Sabre\DAV;
+use Sabre\HTTP;
+
+require_once 'Sabre/DAV/AbstractServer.php';
+
+class MapGetToPropFindTest extends DAV\AbstractServer {
+
+ function setUp() {
+
+ parent::setUp();
+ $this->server->addPlugin(new MapGetToPropFind());
+
+ }
+
+ function testCollectionGet() {
+
+ $serverVars = array(
+ 'REQUEST_URI' => '/',
+ 'REQUEST_METHOD' => 'GET',
+ );
+
+ $request = new HTTP\Request($serverVars);
+ $request->setBody('');
+ $this->server->httpRequest = ($request);
+ $this->server->exec();
+
+ $this->assertEquals(array(
+ 'Content-Type' => 'application/xml; charset=utf-8',
+ 'DAV' => '1, 3, extended-mkcol',
+ 'Vary' => 'Brief,Prefer',
+ ),
+ $this->response->headers
+ );
+
+ $this->assertEquals('HTTP/1.1 207 Multi-Status',$this->response->status,'Incorrect status response received. Full response body: ' . $this->response->body);
+
+ }
+
+
+}
diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Browser/PluginTest.php b/vendor/sabre/dav/tests/Sabre/DAV/Browser/PluginTest.php
new file mode 100644
index 000000000..c3c4bdebb
--- /dev/null
+++ b/vendor/sabre/dav/tests/Sabre/DAV/Browser/PluginTest.php
@@ -0,0 +1,114 @@
+<?php
+
+namespace Sabre\DAV\Browser;
+
+use Sabre\DAV;
+use Sabre\HTTP;
+
+require_once 'Sabre/DAV/AbstractServer.php';
+
+class PluginTest extends DAV\AbstractServer{
+
+ function setUp() {
+
+ parent::setUp();
+ $this->server->addPlugin(new Plugin());
+
+ }
+
+ function testCollectionGet() {
+
+ $serverVars = array(
+ 'REQUEST_URI' => '/dir',
+ 'REQUEST_METHOD' => 'GET',
+ );
+
+ $request = new HTTP\Request($serverVars);
+ $this->server->httpRequest = ($request);
+ $this->server->exec();
+
+ $this->assertEquals('HTTP/1.1 200 OK',$this->response->status);
+ $this->assertEquals(array(
+ 'Content-Type' => 'text/html; charset=utf-8',
+ ),
+ $this->response->headers
+ );
+
+ $this->assertTrue(strpos($this->response->body, 'Index for dir/') !== false);
+ $this->assertTrue(strpos($this->response->body, '<a href="/dir/child.txt"><img src="/?sabreAction=asset&assetName=icons%2Ffile.png" alt="" width="24" />')!==false);
+
+ }
+
+ function testNotFound() {
+
+ $serverVars = array(
+ 'REQUEST_URI' => '/random',
+ 'REQUEST_METHOD' => 'GET',
+ );
+
+ $request = new HTTP\Request($serverVars);
+ $this->server->httpRequest = ($request);
+ $this->server->exec();
+
+ $this->assertEquals('HTTP/1.1 404 Not Found',$this->response->status);
+
+ }
+
+ function testPostOtherContentType() {
+
+ $serverVars = array(
+ 'REQUEST_URI' => '/',
+ 'REQUEST_METHOD' => 'POST',
+ 'CONTENT_TYPE' => 'text/xml',
+ );
+ $request = new HTTP\Request($serverVars);
+ $this->server->httpRequest = $request;
+ $this->server->exec();
+
+ $this->assertEquals('HTTP/1.1 501 Not Implemented', $this->response->status);
+
+ }
+
+ function testPostNoSabreAction() {
+
+ $serverVars = array(
+ 'REQUEST_URI' => '/',
+ 'REQUEST_METHOD' => 'POST',
+ 'CONTENT_TYPE' => 'application/x-www-form-urlencoded',
+ );
+ $postVars = array();
+
+ $request = new HTTP\Request($serverVars,$postVars);
+ $this->server->httpRequest = $request;
+ $this->server->exec();
+
+ $this->assertEquals('HTTP/1.1 501 Not Implemented', $this->response->status);
+
+ }
+
+ function testPostMkCol() {
+
+ $serverVars = array(
+ 'REQUEST_URI' => '/',
+ 'REQUEST_METHOD' => 'POST',
+ 'CONTENT_TYPE' => 'application/x-www-form-urlencoded',
+ );
+ $postVars = array(
+ 'sabreAction' => 'mkcol',
+ 'name' => 'new_collection',
+ );
+
+ $request = new HTTP\Request($serverVars,$postVars);
+ $this->server->httpRequest = $request;
+ $this->server->exec();
+
+ $this->assertEquals('HTTP/1.1 302 Found', $this->response->status);
+ $this->assertEquals(array(
+ 'Location' => '/',
+ ), $this->response->headers);
+
+ $this->assertTrue(is_dir(SABRE_TEMPDIR . '/new_collection'));
+
+ }
+
+}