aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/sabre/dav/tests/Sabre/DAV
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
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')
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAV/AbstractServer.php64
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/AbstractBasicTest.php91
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/AbstractDigestTest.php149
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/AbstractPDOTest.php35
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/ApacheTest.php45
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/FileTest.php42
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/Mock.php37
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/PDOMySQLTest.php31
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/PDOSqliteTest.php28
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAV/Auth/PluginTest.php84
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAV/BasicNodeTest.php234
-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
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAV/ClientMock.php32
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAV/ClientTest.php949
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAV/Exception/LockedTest.php68
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAV/Exception/PaymentRequiredTest.php14
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAV/ExceptionTest.php30
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAV/FSExt/FileTest.php95
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAV/FSExt/NodeTest.php178
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAV/FSExt/ServerTest.php224
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAV/HTTPPreferParsingTest.php200
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAV/Issue33Test.php105
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAV/Locks/Backend/AbstractTest.php196
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAV/Locks/Backend/FSTest.php31
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAV/Locks/Backend/FileTest.php24
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAV/Locks/Backend/PDOMySQLTest.php32
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAV/Locks/Backend/PDOTest.php29
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAV/Locks/GetIfConditionsTest.php375
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAV/Locks/MSWordTest.php123
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAV/Locks/PluginTest.php966
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAV/Mount/PluginTest.php58
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAV/ObjectTreeTest.php100
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAV/PartialUpdate/FileMock.php79
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAV/PartialUpdate/PluginTest.php130
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAV/Property/GetLastModifiedTest.php75
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAV/Property/HrefListTest.php91
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAV/Property/HrefTest.php119
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAV/Property/ResourceTypeTest.php111
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAV/Property/ResponseListTest.php19
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAV/Property/ResponseTest.php230
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAV/Property/SupportedReportSetTest.php128
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAV/ServerCopyMoveTest.php268
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAV/ServerEventsTest.php76
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAV/ServerFinderBlockTest.php53
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAV/ServerMKCOLTest.php371
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAV/ServerPluginTest.php98
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAV/ServerPreconditionTest.php395
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAV/ServerPropsTest.php413
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAV/ServerRangeTest.php274
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAV/ServerSimpleTest.php767
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAV/ServerUpdatePropertiesTest.php130
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAV/SimpleFileTest.php19
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAV/StringUtilTest.php122
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAV/TemporaryFileFilterTest.php252
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAV/TestPlugin.php34
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAV/Tree/FilesystemTest.php88
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAV/TreeTest.php175
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAV/URLUtilTest.php131
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAV/UUIDUtilTest.php25
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAV/XMLUtilTest.php284
62 files changed, 9852 insertions, 0 deletions
diff --git a/vendor/sabre/dav/tests/Sabre/DAV/AbstractServer.php b/vendor/sabre/dav/tests/Sabre/DAV/AbstractServer.php
new file mode 100644
index 000000000..357675686
--- /dev/null
+++ b/vendor/sabre/dav/tests/Sabre/DAV/AbstractServer.php
@@ -0,0 +1,64 @@
+<?php
+
+namespace Sabre\DAV;
+
+use Sabre\HTTP;
+
+require_once 'Sabre/HTTP/ResponseMock.php';
+
+abstract class AbstractServer extends \PHPUnit_Framework_TestCase {
+
+ /**
+ * @var Sabre\HTTP\ResponseMock
+ */
+ protected $response;
+ protected $request;
+ /**
+ * @var Sabre\DAV\Server
+ */
+ protected $server;
+ protected $tempDir = SABRE_TEMPDIR;
+
+ function setUp() {
+
+ $this->response = new HTTP\ResponseMock();
+ $this->server = new Server($this->getRootNode());
+ $this->server->httpResponse = $this->response;
+ $this->server->debugExceptions = true;
+ file_put_contents(SABRE_TEMPDIR . '/test.txt', 'Test contents');
+ mkdir(SABRE_TEMPDIR . '/dir');
+ file_put_contents(SABRE_TEMPDIR . '/dir/child.txt', 'Child contents');
+
+
+ }
+
+ function tearDown() {
+
+ $this->deleteTree(SABRE_TEMPDIR,false);
+
+ }
+
+ protected function getRootNode() {
+
+ return new FS\Directory(SABRE_TEMPDIR);
+
+ }
+
+ private function deleteTree($path,$deleteRoot = true) {
+
+ foreach(scandir($path) as $node) {
+
+ if ($node=='.' || $node=='.svn' || $node=='..') continue;
+ $myPath = $path.'/'. $node;
+ if (is_file($myPath)) {
+ unlink($myPath);
+ } else {
+ $this->deleteTree($myPath);
+ }
+
+ }
+ if ($deleteRoot) rmdir($path);
+
+ }
+
+}
diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/AbstractBasicTest.php b/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/AbstractBasicTest.php
new file mode 100644
index 000000000..36d23c5c0
--- /dev/null
+++ b/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/AbstractBasicTest.php
@@ -0,0 +1,91 @@
+<?php
+
+namespace Sabre\DAV\Auth\Backend;
+
+use Sabre\DAV;
+use Sabre\HTTP;
+
+require_once 'Sabre/HTTP/ResponseMock.php';
+
+class AbstractBasicTest extends \PHPUnit_Framework_TestCase {
+
+ /**
+ * @expectedException Sabre\DAV\Exception\NotAuthenticated
+ */
+ public function testAuthenticateNoHeaders() {
+
+ $response = new HTTP\ResponseMock();
+ $server = new DAV\Server();
+ $server->httpResponse = $response;
+
+ $backend = new AbstractBasicMock();
+ $backend->authenticate($server,'myRealm');
+
+ }
+
+ /**
+ * @expectedException Sabre\DAV\Exception\NotAuthenticated
+ */
+ public function testAuthenticateUnknownUser() {
+
+ $response = new HTTP\ResponseMock();
+ $tree = new DAV\ObjectTree(new DAV\SimpleCollection('bla'));
+ $server = new DAV\Server($tree);
+ $server->httpResponse = $response;
+
+ $request = new HTTP\Request(array(
+ 'PHP_AUTH_USER' => 'username',
+ 'PHP_AUTH_PW' => 'wrongpassword',
+ ));
+ $server->httpRequest = $request;
+
+ $backend = new AbstractBasicMock();
+ $backend->authenticate($server,'myRealm');
+
+ }
+
+ public function testAuthenticate() {
+
+ $response = new HTTP\ResponseMock();
+ $tree = new DAV\ObjectTree(new DAV\SimpleCollection('bla'));
+ $server = new DAV\Server($tree);
+ $server->httpResponse = $response;
+
+ $request = new HTTP\Request(array(
+ 'PHP_AUTH_USER' => 'username',
+ 'PHP_AUTH_PW' => 'password',
+ ));
+ $server->httpRequest = $request;
+
+ $backend = new AbstractBasicMock();
+ $this->assertTrue($backend->authenticate($server,'myRealm'));
+
+ $result = $backend->getCurrentUser();
+
+ $this->assertEquals('username', $result);
+
+ }
+
+
+}
+
+
+class AbstractBasicMock extends AbstractBasic {
+
+ /**
+ * Validates a username and password
+ *
+ * This method should return true or false depending on if login
+ * succeeded.
+ *
+ * @param string $username
+ * @param string $password
+ * @return bool
+ */
+ function validateUserPass($username, $password) {
+
+ return ($username == 'username' && $password == 'password');
+
+ }
+
+}
diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/AbstractDigestTest.php b/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/AbstractDigestTest.php
new file mode 100644
index 000000000..495690c4e
--- /dev/null
+++ b/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/AbstractDigestTest.php
@@ -0,0 +1,149 @@
+<?php
+
+namespace Sabre\DAV\Auth\Backend;
+
+use Sabre\DAV;
+use Sabre\HTTP;
+
+require_once 'Sabre/HTTP/ResponseMock.php';
+
+class AbstractDigestTest extends \PHPUnit_Framework_TestCase {
+
+ /**
+ * @expectedException Sabre\DAV\Exception\NotAuthenticated
+ */
+ public function testAuthenticateNoHeaders() {
+
+ $response = new HTTP\ResponseMock();
+ $server = new DAV\Server();
+ $server->httpResponse = $response;
+
+ $backend = new AbstractDigestMock();
+ $backend->authenticate($server,'myRealm');
+
+ }
+
+ /**
+ * @expectedException Sabre\DAV\Exception
+ */
+ public function testAuthenticateBadGetUserInfoResponse() {
+
+ $response = new HTTP\ResponseMock();
+ $server = new DAV\Server();
+ $server->httpResponse = $response;
+
+ $header = 'username=null, realm=myRealm, nonce=12345, uri=/, response=HASH, opaque=1, qop=auth, nc=1, cnonce=1';
+ $request = new HTTP\Request(array(
+ 'PHP_AUTH_DIGEST' => $header,
+ ));
+ $server->httpRequest = $request;
+
+ $backend = new AbstractDigestMock();
+ $backend->authenticate($server,'myRealm');
+
+ }
+
+ /**
+ * @expectedException Sabre\DAV\Exception
+ */
+ public function testAuthenticateBadGetUserInfoResponse2() {
+
+ $response = new HTTP\ResponseMock();
+ $server = new DAV\Server();
+ $server->httpResponse = $response;
+
+ $header = 'username=array, realm=myRealm, nonce=12345, uri=/, response=HASH, opaque=1, qop=auth, nc=1, cnonce=1';
+ $request = new HTTP\Request(array(
+ 'PHP_AUTH_DIGEST' => $header,
+ ));
+ $server->httpRequest = $request;
+
+ $backend = new AbstractDigestMock();
+ $backend->authenticate($server,'myRealm');
+
+ }
+
+ /**
+ * @expectedException Sabre\DAV\Exception\NotAuthenticated
+ */
+ public function testAuthenticateUnknownUser() {
+
+ $response = new HTTP\ResponseMock();
+ $server = new DAV\Server();
+ $server->httpResponse = $response;
+
+ $header = 'username=false, realm=myRealm, nonce=12345, uri=/, response=HASH, opaque=1, qop=auth, nc=1, cnonce=1';
+ $request = new HTTP\Request(array(
+ 'PHP_AUTH_DIGEST' => $header,
+ ));
+ $server->httpRequest = $request;
+
+ $backend = new AbstractDigestMock();
+ $backend->authenticate($server,'myRealm');
+
+ }
+
+ /**
+ * @expectedException Sabre\DAV\Exception\NotAuthenticated
+ */
+ public function testAuthenticateBadPassword() {
+
+ $response = new HTTP\ResponseMock();
+ $server = new DAV\Server();
+ $server->httpResponse = $response;
+
+ $header = 'username=user, realm=myRealm, nonce=12345, uri=/, response=HASH, opaque=1, qop=auth, nc=1, cnonce=1';
+ $request = new HTTP\Request(array(
+ 'PHP_AUTH_DIGEST' => $header,
+ 'REQUEST_METHOD' => 'PUT',
+ ));
+ $server->httpRequest = $request;
+
+ $backend = new AbstractDigestMock();
+ $backend->authenticate($server,'myRealm');
+
+ }
+
+ public function testAuthenticate() {
+
+ $response = new HTTP\ResponseMock();
+ $server = new DAV\Server();
+ $server->httpResponse = $response;
+
+ $digestHash = md5('HELLO:12345:1:1:auth:' . md5('GET:/'));
+ $header = 'username=user, realm=myRealm, nonce=12345, uri=/, response='.$digestHash.', opaque=1, qop=auth, nc=1, cnonce=1';
+ $request = new HTTP\Request(array(
+ 'REQUEST_METHOD' => 'GET',
+ 'PHP_AUTH_DIGEST' => $header,
+ 'REQUEST_URI' => '/',
+ ));
+ $server->httpRequest = $request;
+
+ $backend = new AbstractDigestMock();
+ $this->assertTrue($backend->authenticate($server,'myRealm'));
+
+ $result = $backend->getCurrentUser();
+
+ $this->assertEquals('user', $result);
+ $this->assertEquals('HELLO', $backend->getDigestHash('myRealm', $result));
+
+ }
+
+
+}
+
+
+class AbstractDigestMock extends AbstractDigest {
+
+ function getDigestHash($realm, $userName) {
+
+ switch($userName) {
+ case 'null' : return null;
+ case 'false' : return false;
+ case 'array' : return array();
+ case 'user' : return 'HELLO';
+ }
+
+ }
+
+}
diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/AbstractPDOTest.php b/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/AbstractPDOTest.php
new file mode 100644
index 000000000..d22923d51
--- /dev/null
+++ b/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/AbstractPDOTest.php
@@ -0,0 +1,35 @@
+<?php
+
+namespace Sabre\DAV\Auth\Backend;
+
+use Sabre\DAV;
+
+abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase {
+
+ abstract function getPDO();
+
+ function testConstruct() {
+
+ $pdo = $this->getPDO();
+ $backend = new PDO($pdo);
+ $this->assertTrue($backend instanceof PDO);
+
+ }
+
+ /**
+ * @depends testConstruct
+ */
+ function testUserInfo() {
+
+ $pdo = $this->getPDO();
+ $backend = new PDO($pdo);
+
+ $this->assertNull($backend->getDigestHash('realm','blabla'));
+
+ $expected = 'hash';
+
+ $this->assertEquals($expected, $backend->getDigestHash('realm','user'));
+
+ }
+
+}
diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/ApacheTest.php b/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/ApacheTest.php
new file mode 100644
index 000000000..b1ed555d4
--- /dev/null
+++ b/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/ApacheTest.php
@@ -0,0 +1,45 @@
+<?php
+
+namespace Sabre\DAV\Auth\Backend;
+
+use Sabre\DAV;
+use Sabre\HTTP;
+
+class ApacheTest extends \PHPUnit_Framework_TestCase {
+
+ function testConstruct() {
+
+ $backend = new Apache();
+
+ }
+
+ /**
+ * @expectedException Sabre\DAV\Exception
+ */
+ function testNoHeader() {
+
+ $server = new DAV\Server();
+ $backend = new Apache();
+ $backend->authenticate($server,'Realm');
+
+ }
+
+ function testRemoteUser() {
+
+ $backend = new Apache();
+
+ $server = new DAV\Server();
+ $request = new HTTP\Request(array(
+ 'REMOTE_USER' => 'username',
+ ));
+ $server->httpRequest = $request;
+
+ $this->assertTrue($backend->authenticate($server, 'Realm'));
+
+ $userInfo = 'username';
+
+ $this->assertEquals($userInfo, $backend->getCurrentUser());
+
+ }
+
+}
diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/FileTest.php b/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/FileTest.php
new file mode 100644
index 000000000..72f150ab6
--- /dev/null
+++ b/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/FileTest.php
@@ -0,0 +1,42 @@
+<?php
+
+namespace Sabre\DAV\Auth\Backend;
+
+class FileTest extends \PHPUnit_Framework_TestCase {
+
+ function tearDown() {
+
+ if (file_exists(SABRE_TEMPDIR . '/filebackend')) unlink(SABRE_TEMPDIR .'/filebackend');
+
+ }
+
+ function testConstruct() {
+
+ $file = new File();
+ $this->assertTrue($file instanceof File);
+
+ }
+
+ /**
+ * @expectedException Sabre\DAV\Exception
+ */
+ function testLoadFileBroken() {
+
+ file_put_contents(SABRE_TEMPDIR . '/backend','user:realm:hash');
+ $file = new File();
+ $file->loadFile(SABRE_TEMPDIR .'/backend');
+
+ }
+
+ function testLoadFile() {
+
+ file_put_contents(SABRE_TEMPDIR . '/backend','user:realm:' . md5('user:realm:password'));
+ $file = new File();
+ $file->loadFile(SABRE_TEMPDIR . '/backend');
+
+ $this->assertFalse($file->getDigestHash('realm','blabla'));
+ $this->assertEquals(md5('user:realm:password'), $file->getDigesthash('realm','user'));
+
+ }
+
+}
diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/Mock.php b/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/Mock.php
new file mode 100644
index 000000000..fdad8a605
--- /dev/null
+++ b/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/Mock.php
@@ -0,0 +1,37 @@
+<?php
+
+namespace Sabre\DAV\Auth\Backend;
+
+use Sabre\DAV;
+
+class Mock implements BackendInterface {
+
+ protected $currentUser;
+
+ public $defaultUser = 'admin';
+
+ /**
+ * @param Sabre\DAV\Server $server
+ * @param string $realm
+ * @throws Sabre\DAV\Exception\NotAuthenticated
+ */
+ function authenticate(DAV\Server $server, $realm) {
+
+ if ($realm=='failme') throw new DAV\Exception\NotAuthenticated('deliberate fail');
+ $this->currentUser = $this->defaultUser;
+
+ }
+
+ function setCurrentUser($user) {
+
+ $this->currentUser = $user;
+
+ }
+
+ function getCurrentUser() {
+
+ return $this->currentUser;
+
+ }
+
+}
diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/PDOMySQLTest.php b/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/PDOMySQLTest.php
new file mode 100644
index 000000000..ede432de2
--- /dev/null
+++ b/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/PDOMySQLTest.php
@@ -0,0 +1,31 @@
+<?php
+
+namespace Sabre\DAV\Auth\Backend;
+
+require_once 'Sabre/TestUtil.php';
+
+class PDOMySQLTest extends AbstractPDOTest {
+
+ function getPDO() {
+
+ if (!SABRE_HASMYSQL) $this->markTestSkipped('MySQL driver is not available, or not properly configured');
+ $pdo = \Sabre\TestUtil::getMySQLDB();
+ if (!$pdo) $this->markTestSkipped('Could not connect to MySQL database');
+ $pdo->query("DROP TABLE IF EXISTS users");
+ $pdo->query("
+create table users (
+ id integer unsigned not null primary key auto_increment,
+ username varchar(50),
+ digesta1 varchar(32),
+ email varchar(80),
+ displayname varchar(80),
+ unique(username)
+);");
+
+ $pdo->query("INSERT INTO users (username,digesta1,email,displayname) VALUES ('user','hash','user@example.org','User')");
+
+ return $pdo;
+
+ }
+
+}
diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/PDOSqliteTest.php b/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/PDOSqliteTest.php
new file mode 100644
index 000000000..abfb031bb
--- /dev/null
+++ b/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/PDOSqliteTest.php
@@ -0,0 +1,28 @@
+<?php
+
+namespace Sabre\DAV\Auth\Backend;
+
+require_once 'Sabre/DAV/Auth/Backend/AbstractPDOTest.php';
+
+class PDOSQLiteTest extends AbstractPDOTest {
+
+ function tearDown() {
+
+ if (file_exists(SABRE_TEMPDIR . '/pdobackend')) unlink(SABRE_TEMPDIR . '/pdobackend');
+ if (file_exists(SABRE_TEMPDIR . '/pdobackend2')) unlink(SABRE_TEMPDIR . '/pdobackend2');
+
+ }
+
+ function getPDO() {
+
+ if (!SABRE_HASSQLITE) $this->markTestSkipped('SQLite driver is not available');
+ $pdo = new \PDO('sqlite:'.SABRE_TEMPDIR.'/pdobackend');
+ $pdo->setAttribute(\PDO::ATTR_ERRMODE,\PDO::ERRMODE_EXCEPTION);
+ $pdo->query('CREATE TABLE users (username TEXT, digesta1 TEXT, email VARCHAR(80), displayname VARCHAR(80))');
+ $pdo->query('INSERT INTO users VALUES ("user","hash","user@example.org","User")');
+
+ return $pdo;
+
+ }
+
+}
diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Auth/PluginTest.php b/vendor/sabre/dav/tests/Sabre/DAV/Auth/PluginTest.php
new file mode 100644
index 000000000..2096a04d7
--- /dev/null
+++ b/vendor/sabre/dav/tests/Sabre/DAV/Auth/PluginTest.php
@@ -0,0 +1,84 @@
+<?php
+
+namespace Sabre\DAV\Auth;
+
+use Sabre\HTTP;
+use Sabre\DAV;
+
+require_once 'Sabre/HTTP/ResponseMock.php';
+
+class PluginTest extends \PHPUnit_Framework_TestCase {
+
+ function testInit() {
+
+ $fakeServer = new DAV\Server( new DAV\SimpleCollection('bla'));
+ $plugin = new Plugin(new Backend\Mock(),'realm');
+ $this->assertTrue($plugin instanceof Plugin);
+ $fakeServer->addPlugin($plugin);
+ $this->assertEquals($plugin, $fakeServer->getPlugin('auth'));
+
+ }
+
+ /**
+ * @depends testInit
+ */
+ function testAuthenticate() {
+
+ $fakeServer = new DAV\Server( new DAV\SimpleCollection('bla'));
+ $plugin = new Plugin(new Backend\Mock(),'realm');
+ $fakeServer->addPlugin($plugin);
+ $fakeServer->broadCastEvent('beforeMethod',array('GET','/'));
+
+ }
+
+
+
+ /**
+ * @depends testInit
+ * @expectedException Sabre\DAV\Exception\NotAuthenticated
+ */
+ function testAuthenticateFail() {
+
+ $fakeServer = new DAV\Server( new DAV\SimpleCollection('bla'));
+ $plugin = new Plugin(new Backend\Mock(),'failme');
+ $fakeServer->addPlugin($plugin);
+ $fakeServer->broadCastEvent('beforeMethod',array('GET','/'));
+
+ }
+
+ function testReportPassThrough() {
+
+ $fakeServer = new DAV\Server(new DAV\SimpleCollection('bla'));
+ $plugin = new Plugin(new Backend\Mock(),'realm');
+ $fakeServer->addPlugin($plugin);
+
+ $request = new HTTP\Request(array(
+ 'REQUEST_METHOD' => 'REPORT',
+ 'HTTP_CONTENT_TYPE' => 'application/xml',
+ 'REQUEST_URI' => '/',
+ ));
+ $request->setBody('<?xml version="1.0"?><s:somereport xmlns:s="http://www.rooftopsolutions.nl/NS/example" />');
+
+ $fakeServer->httpRequest = $request;
+ $fakeServer->httpResponse = new HTTP\ResponseMock();
+ $fakeServer->exec();
+
+ $this->assertEquals('HTTP/1.1 403 Forbidden', $fakeServer->httpResponse->status);
+
+ }
+
+ /**
+ * @depends testInit
+ */
+ function testGetCurrentUserPrincipal() {
+
+ $fakeServer = new DAV\Server( new DAV\SimpleCollection('bla'));
+ $plugin = new Plugin(new Backend\Mock(),'realm');
+ $fakeServer->addPlugin($plugin);
+ $fakeServer->broadCastEvent('beforeMethod',array('GET','/'));
+ $this->assertEquals('admin', $plugin->getCurrentUser());
+
+ }
+
+}
+
diff --git a/vendor/sabre/dav/tests/Sabre/DAV/BasicNodeTest.php b/vendor/sabre/dav/tests/Sabre/DAV/BasicNodeTest.php
new file mode 100644
index 000000000..fdc2403db
--- /dev/null
+++ b/vendor/sabre/dav/tests/Sabre/DAV/BasicNodeTest.php
@@ -0,0 +1,234 @@
+<?php
+
+namespace Sabre\DAV;
+
+class BasicNodeTest extends \PHPUnit_Framework_TestCase {
+
+ /**
+ * @expectedException Sabre\DAV\Exception\Forbidden
+ */
+ public function testPut() {
+
+ $file = new FileMock();
+ $file->put('hi');
+
+ }
+
+ /**
+ * @expectedException Sabre\DAV\Exception\Forbidden
+ */
+ public function testGet() {
+
+ $file = new FileMock();
+ $file->get();
+
+ }
+
+ public function testGetSize() {
+
+ $file = new FileMock();
+ $this->assertEquals(0,$file->getSize());
+
+ }
+
+
+ public function testGetETag() {
+
+ $file = new FileMock();
+ $this->assertNull($file->getETag());
+
+ }
+
+ public function testGetContentType() {
+
+ $file = new FileMock();
+ $this->assertNull($file->getContentType());
+
+ }
+
+ /**
+ * @expectedException Sabre\DAV\Exception\Forbidden
+ */
+ public function testDelete() {
+
+ $file = new FileMock();
+ $file->delete();
+
+ }
+
+ /**
+ * @expectedException Sabre\DAV\Exception\Forbidden
+ */
+ public function testSetName() {
+
+ $file = new FileMock();
+ $file->setName('hi');
+
+ }
+
+ public function testGetLastModified() {
+
+ $file = new FileMock();
+ // checking if lastmod is within the range of a few seconds
+ $lastMod = $file->getLastModified();
+ $compareTime = ($lastMod + 1)-time();
+ $this->assertTrue($compareTime < 3);
+
+ }
+
+ public function testGetChild() {
+
+ $dir = new DirectoryMock();
+ $file = $dir->getChild('mockfile');
+ $this->assertTrue($file instanceof FileMock);
+
+ }
+
+ public function testChildExists() {
+
+ $dir = new DirectoryMock();
+ $this->assertTrue($dir->childExists('mockfile'));
+
+ }
+
+ public function testChildExistsFalse() {
+
+ $dir = new DirectoryMock();
+ $this->assertFalse($dir->childExists('mockfile2'));
+
+ }
+
+ /**
+ * @expectedException Sabre\DAV\Exception\NotFound
+ */
+ public function testGetChild404() {
+
+ $dir = new DirectoryMock();
+ $file = $dir->getChild('blabla');
+
+ }
+
+ /**
+ * @expectedException Sabre\DAV\Exception\Forbidden
+ */
+ public function testCreateFile() {
+
+ $dir = new DirectoryMock();
+ $dir->createFile('hello','data');
+
+ }
+
+ /**
+ * @expectedException Sabre\DAV\Exception\Forbidden
+ */
+ public function testCreateDirectory() {
+
+ $dir = new DirectoryMock();
+ $dir->createDirectory('hello');
+
+ }
+
+ public function testSimpleDirectoryConstruct() {
+
+ $dir = new SimpleCollection('simpledir',array());
+
+ }
+
+ /**
+ * @depends testSimpleDirectoryConstruct
+ */
+ public function testSimpleDirectoryConstructChild() {
+
+ $file = new FileMock();
+ $dir = new SimpleCollection('simpledir',array($file));
+ $file2 = $dir->getChild('mockfile');
+
+ $this->assertEquals($file,$file2);
+
+ }
+
+ /**
+ * @expectedException Sabre\DAV\Exception
+ * @depends testSimpleDirectoryConstruct
+ */
+ public function testSimpleDirectoryBadParam() {
+
+ $dir = new SimpleCollection('simpledir',array('string shouldn\'t be here'));
+
+ }
+
+ /**
+ * @depends testSimpleDirectoryConstruct
+ */
+ public function testSimpleDirectoryAddChild() {
+
+ $file = new FileMock();
+ $dir = new SimpleCollection('simpledir');
+ $dir->addChild($file);
+ $file2 = $dir->getChild('mockfile');
+
+ $this->assertEquals($file,$file2);
+
+ }
+
+ /**
+ * @depends testSimpleDirectoryConstruct
+ * @depends testSimpleDirectoryAddChild
+ */
+ public function testSimpleDirectoryGetChildren() {
+
+ $file = new FileMock();
+ $dir = new SimpleCollection('simpledir');
+ $dir->addChild($file);
+
+ $this->assertEquals(array($file),$dir->getChildren());
+
+ }
+
+ /*
+ * @depends testSimpleDirectoryConstruct
+ */
+ public function testSimpleDirectoryGetName() {
+
+ $dir = new SimpleCollection('simpledir');
+ $this->assertEquals('simpledir',$dir->getName());
+
+ }
+
+ /**
+ * @depends testSimpleDirectoryConstruct
+ * @expectedException Sabre\DAV\Exception\NotFound
+ */
+ public function testSimpleDirectoryGetChild404() {
+
+ $dir = new SimpleCollection('simpledir');
+ $dir->getChild('blabla');
+
+ }
+}
+
+class DirectoryMock extends Collection {
+
+ function getName() {
+
+ return 'mockdir';
+
+ }
+
+ function getChildren() {
+
+ return array(new FileMock());
+
+ }
+
+}
+
+class FileMock extends File {
+
+ function getName() {
+
+ return 'mockfile';
+
+ }
+
+}
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'));
+
+ }
+
+}
diff --git a/vendor/sabre/dav/tests/Sabre/DAV/ClientMock.php b/vendor/sabre/dav/tests/Sabre/DAV/ClientMock.php
new file mode 100644
index 000000000..6e74e6ec0
--- /dev/null
+++ b/vendor/sabre/dav/tests/Sabre/DAV/ClientMock.php
@@ -0,0 +1,32 @@
+<?php
+
+namespace Sabre\DAV;
+
+class ClientMock extends Client {
+
+ public $response;
+
+ public $url;
+ public $curlSettings;
+
+ protected function curlRequest($url, $curlSettings) {
+
+ $this->url = $url;
+ $this->curlSettings = $curlSettings;
+ return $this->response;
+
+ }
+
+ /**
+ * Just making this method public
+ *
+ * @param string $url
+ * @return string
+ */
+ public function getAbsoluteUrl($url) {
+
+ return parent::getAbsoluteUrl($url);
+
+ }
+
+}
diff --git a/vendor/sabre/dav/tests/Sabre/DAV/ClientTest.php b/vendor/sabre/dav/tests/Sabre/DAV/ClientTest.php
new file mode 100644
index 000000000..9c3532a47
--- /dev/null
+++ b/vendor/sabre/dav/tests/Sabre/DAV/ClientTest.php
@@ -0,0 +1,949 @@
+<?php
+
+namespace Sabre\DAV;
+
+require_once 'Sabre/DAV/ClientMock.php';
+
+class ClientTest extends \PHPUnit_Framework_TestCase {
+
+ function testConstruct() {
+
+ $client = new ClientMock(array(
+ 'baseUri' => '/',
+ ));
+
+ }
+
+ /**
+ * @expectedException InvalidArgumentException
+ */
+ function testConstructNoBaseUri() {
+
+ $client = new ClientMock(array());
+
+ }
+
+ function testRequest() {
+
+ $client = new ClientMock(array(
+ 'baseUri' => 'http://example.org/foo/bar/',
+ ));
+
+ $responseBlob = array(
+ "HTTP/1.1 200 OK",
+ "Content-Type: text/plain",
+ "",
+ "Hello there!"
+ );
+
+ $client->response = array(
+ implode("\r\n", $responseBlob),
+ array(
+ 'header_size' => 45,
+ 'http_code' => 200,
+ ),
+ 0,
+ ""
+ );
+
+ $result = $client->request('POST', 'baz', 'sillybody', array('Content-Type' => 'text/plain'));
+
+ $this->assertEquals('http://example.org/foo/bar/baz', $client->url);
+ $this->assertEquals(array(
+ CURLOPT_RETURNTRANSFER => true,
+ CURLOPT_FOLLOWLOCATION => true,
+ CURLOPT_MAXREDIRS => 5,
+ CURLOPT_CUSTOMREQUEST => 'POST',
+ CURLOPT_POSTFIELDS => 'sillybody',
+ CURLOPT_HEADER => true,
+ CURLOPT_HTTPHEADER => array('Content-Type: text/plain'),
+ ), $client->curlSettings);
+
+ $this->assertEquals(array(
+ 'statusCode' => 200,
+ 'headers' => array(
+ 'content-type' => 'text/plain',
+ ),
+ 'body' => 'Hello there!'
+ ), $result);
+
+
+ }
+
+
+ function testRequestProxy() {
+
+ $client = new ClientMock(array(
+ 'baseUri' => 'http://example.org/foo/bar/',
+ 'proxy' => 'http://localhost:8000/',
+ ));
+
+ $responseBlob = array(
+ "HTTP/1.1 200 OK",
+ "Content-Type: text/plain",
+ "",
+ "Hello there!"
+ );
+
+ $client->response = array(
+ implode("\r\n", $responseBlob),
+ array(
+ 'header_size' => 45,
+ 'http_code' => 200,
+ ),
+ 0,
+ ""
+ );
+
+ $result = $client->request('POST', 'baz', 'sillybody', array('Content-Type' => 'text/plain'));
+
+ $this->assertEquals('http://example.org/foo/bar/baz', $client->url);
+ $this->assertEquals(array(
+ CURLOPT_RETURNTRANSFER => true,
+ CURLOPT_FOLLOWLOCATION => true,
+ CURLOPT_MAXREDIRS => 5,
+ CURLOPT_CUSTOMREQUEST => 'POST',
+ CURLOPT_POSTFIELDS => 'sillybody',
+ CURLOPT_HEADER => true,
+ CURLOPT_HTTPHEADER => array('Content-Type: text/plain'),
+ CURLOPT_PROXY => 'http://localhost:8000/',
+ ), $client->curlSettings);
+
+ $this->assertEquals(array(
+ 'statusCode' => 200,
+ 'headers' => array(
+ 'content-type' => 'text/plain',
+ ),
+ 'body' => 'Hello there!'
+ ), $result);
+
+ }
+
+ function testRequestCAInfo() {
+
+ $client = new ClientMock(array(
+ 'baseUri' => 'http://example.org/foo/bar/',
+ ));
+
+ $responseBlob = array(
+ "HTTP/1.1 200 OK",
+ "Content-Type: text/plain",
+ "",
+ "Hello there!"
+ );
+
+ $client->response = array(
+ implode("\r\n", $responseBlob),
+ array(
+ 'header_size' => 45,
+ 'http_code' => 200,
+ ),
+ 0,
+ ""
+ );
+
+ $client->addTrustedCertificates('bla');
+
+ $result = $client->request('POST', 'baz', 'sillybody', array('Content-Type' => 'text/plain'));
+
+ $this->assertEquals('http://example.org/foo/bar/baz', $client->url);
+ $this->assertEquals(array(
+ CURLOPT_RETURNTRANSFER => true,
+ CURLOPT_FOLLOWLOCATION => true,
+ CURLOPT_MAXREDIRS => 5,
+ CURLOPT_CUSTOMREQUEST => 'POST',
+ CURLOPT_POSTFIELDS => 'sillybody',
+ CURLOPT_HEADER => true,
+ CURLOPT_CAINFO => 'bla',
+ CURLOPT_HTTPHEADER => array('Content-Type: text/plain'),
+ ), $client->curlSettings);
+
+ }
+
+ function testRequestSslPeer() {
+
+ $client = new ClientMock(array(
+ 'baseUri' => 'http://example.org/foo/bar/',
+ ));
+
+ $responseBlob = array(
+ "HTTP/1.1 200 OK",
+ "Content-Type: text/plain",
+ "",
+ "Hello there!"
+ );
+
+ $client->response = array(
+ implode("\r\n", $responseBlob),
+ array(
+ 'header_size' => 45,
+ 'http_code' => 200,
+ ),
+ 0,
+ ""
+ );
+
+ $client->setVerifyPeer(true);
+
+ $result = $client->request('POST', 'baz', 'sillybody', array('Content-Type' => 'text/plain'));
+
+ $this->assertEquals('http://example.org/foo/bar/baz', $client->url);
+ $this->assertEquals(array(
+ CURLOPT_RETURNTRANSFER => true,
+ CURLOPT_FOLLOWLOCATION => true,
+ CURLOPT_MAXREDIRS => 5,
+ CURLOPT_CUSTOMREQUEST => 'POST',
+ CURLOPT_POSTFIELDS => 'sillybody',
+ CURLOPT_HEADER => true,
+ CURLOPT_HTTPHEADER => array('Content-Type: text/plain'),
+ CURLOPT_SSL_VERIFYPEER => true
+ ), $client->curlSettings);
+
+ }
+
+ function testRequestAuth() {
+
+ $client = new ClientMock(array(
+ 'baseUri' => 'http://example.org/foo/bar/',
+ 'userName' => 'user',
+ 'password' => 'password',
+ ));
+
+ $responseBlob = array(
+ "HTTP/1.1 200 OK",
+ "Content-Type: text/plain",
+ "",
+ "Hello there!"
+ );
+
+ $client->response = array(
+ implode("\r\n", $responseBlob),
+ array(
+ 'header_size' => 45,
+ 'http_code' => 200,
+ ),
+ 0,
+ ""
+ );
+
+ $result = $client->request('POST', 'baz', 'sillybody', array('Content-Type' => 'text/plain'));
+
+ $this->assertEquals('http://example.org/foo/bar/baz', $client->url);
+ $this->assertEquals(array(
+ CURLOPT_RETURNTRANSFER => true,
+ CURLOPT_FOLLOWLOCATION => true,
+ CURLOPT_MAXREDIRS => 5,
+ CURLOPT_CUSTOMREQUEST => 'POST',
+ CURLOPT_POSTFIELDS => 'sillybody',
+ CURLOPT_HEADER => true,
+ CURLOPT_HTTPHEADER => array('Content-Type: text/plain'),
+ CURLOPT_HTTPAUTH => CURLAUTH_BASIC | CURLAUTH_DIGEST,
+ CURLOPT_USERPWD => 'user:password'
+ ), $client->curlSettings);
+
+ $this->assertEquals(array(
+ 'statusCode' => 200,
+ 'headers' => array(
+ 'content-type' => 'text/plain',
+ ),
+ 'body' => 'Hello there!'
+ ), $result);
+
+ }
+
+ function testRequestAuthBasic() {
+
+ $client = new ClientMock(array(
+ 'baseUri' => 'http://example.org/foo/bar/',
+ 'userName' => 'user',
+ 'password' => 'password',
+ 'authType' => Client::AUTH_BASIC,
+ ));
+
+ $responseBlob = array(
+ "HTTP/1.1 200 OK",
+ "Content-Type: text/plain",
+ "",
+ "Hello there!"
+ );
+
+ $client->response = array(
+ implode("\r\n", $responseBlob),
+ array(
+ 'header_size' => 45,
+ 'http_code' => 200,
+ ),
+ 0,
+ ""
+ );
+
+ $result = $client->request('POST', 'baz', 'sillybody', array('Content-Type' => 'text/plain'));
+
+ $this->assertEquals('http://example.org/foo/bar/baz', $client->url);
+ $this->assertEquals(array(
+ CURLOPT_RETURNTRANSFER => true,
+ CURLOPT_FOLLOWLOCATION => true,
+ CURLOPT_MAXREDIRS => 5,
+ CURLOPT_CUSTOMREQUEST => 'POST',
+ CURLOPT_POSTFIELDS => 'sillybody',
+ CURLOPT_HEADER => true,
+ CURLOPT_HTTPHEADER => array('Content-Type: text/plain'),
+ CURLOPT_HTTPAUTH => CURLAUTH_BASIC,
+ CURLOPT_USERPWD => 'user:password'
+ ), $client->curlSettings);
+
+ $this->assertEquals(array(
+ 'statusCode' => 200,
+ 'headers' => array(
+ 'content-type' => 'text/plain',
+ ),
+ 'body' => 'Hello there!'
+ ), $result);
+
+ }
+
+ function testRequestAuthDigest() {
+
+ $client = new ClientMock(array(
+ 'baseUri' => 'http://example.org/foo/bar/',
+ 'userName' => 'user',
+ 'password' => 'password',
+ 'authType' => Client::AUTH_DIGEST,
+ ));
+
+ $responseBlob = array(
+ "HTTP/1.1 200 OK",
+ "Content-Type: text/plain",
+ "",
+ "Hello there!"
+ );
+
+ $client->response = array(
+ implode("\r\n", $responseBlob),
+ array(
+ 'header_size' => 45,
+ 'http_code' => 200,
+ ),
+ 0,
+ ""
+ );
+
+ $result = $client->request('POST', 'baz', 'sillybody', array('Content-Type' => 'text/plain'));
+
+ $this->assertEquals('http://example.org/foo/bar/baz', $client->url);
+ $this->assertEquals(array(
+ CURLOPT_RETURNTRANSFER => true,
+ CURLOPT_FOLLOWLOCATION => true,
+ CURLOPT_MAXREDIRS => 5,
+ CURLOPT_CUSTOMREQUEST => 'POST',
+ CURLOPT_POSTFIELDS => 'sillybody',
+ CURLOPT_HEADER => true,
+ CURLOPT_HTTPHEADER => array('Content-Type: text/plain'),
+ CURLOPT_HTTPAUTH => CURLAUTH_DIGEST,
+ CURLOPT_USERPWD => 'user:password'
+ ), $client->curlSettings);
+
+ $this->assertEquals(array(
+ 'statusCode' => 200,
+ 'headers' => array(
+ 'content-type' => 'text/plain',
+ ),
+ 'body' => 'Hello there!'
+ ), $result);
+
+ }
+ function testRequestError() {
+
+ $client = new ClientMock(array(
+ 'baseUri' => 'http://example.org/foo/bar/',
+ ));
+
+ $responseBlob = array(
+ "HTTP/1.1 200 OK",
+ "Content-Type: text/plain",
+ "",
+ "Hello there!"
+ );
+
+ $client->response = array(
+ implode("\r\n", $responseBlob),
+ array(
+ 'header_size' => 45,
+ 'http_code' => 200,
+ ),
+ CURLE_COULDNT_CONNECT,
+ "Could not connect, or something"
+ );
+
+ $caught = false;
+ try {
+ $client->request('POST', 'baz', 'sillybody', array('Content-Type' => 'text/plain'));
+ } catch (Exception $e) {
+ $caught = true;
+ }
+ if (!$caught) {
+ $this->markTestFailed('Exception was not thrown');
+ }
+
+ }
+
+ function testRequestHTTPError() {
+
+ $client = new ClientMock(array(
+ 'baseUri' => 'http://example.org/foo/bar/',
+ ));
+
+ $responseBlob = array(
+ "HTTP/1.1 400 Bad Request",
+ "Content-Type: text/plain",
+ "",
+ "Hello there!"
+ );
+
+ $client->response = array(
+ implode("\r\n", $responseBlob),
+ array(
+ 'header_size' => 45,
+ 'http_code' => 400,
+ ),
+ 0,
+ ""
+ );
+
+ $caught = false;
+ try {
+ $client->request('POST', 'baz', 'sillybody', array('Content-Type' => 'text/plain'));
+ } catch (Exception $e) {
+ $caught = true;
+ }
+ if (!$caught) {
+ $this->fail('Exception was not thrown');
+ }
+
+ }
+
+ function testRequestHTTP404() {
+
+ $client = new ClientMock(array(
+ 'baseUri' => 'http://example.org/foo/bar/',
+ ));
+
+ $responseBlob = array(
+ "HTTP/1.1 404 Not Found",
+ "Content-Type: text/plain",
+ "",
+ "Hello there!"
+ );
+
+ $client->response = array(
+ implode("\r\n", $responseBlob),
+ array(
+ 'header_size' => 45,
+ 'http_code' => 404,
+ ),
+ 0,
+ ""
+ );
+
+ $caught = false;
+ try {
+ $client->request('POST', 'baz', 'sillybody', array('Content-Type' => 'text/plain'));
+ } catch (Exception\NotFound $e) {
+ $caught = true;
+ }
+ if (!$caught) {
+ $this->fail('Exception was not thrown');
+ }
+
+ }
+
+ /**
+ * @dataProvider supportedHTTPCodes
+ */
+ function testSpecificHTTPErrors($error) {
+
+ $client = new ClientMock(array(
+ 'baseUri' => 'http://example.org/foo/bar/',
+ ));
+
+ $responseBlob = array(
+ "HTTP/1.1 $error blabla",
+ "Content-Type: text/plain",
+ "",
+ "Hello there!"
+ );
+
+ $client->response = array(
+ implode("\r\n", $responseBlob),
+ array(
+ 'header_size' => 42,
+ 'http_code' => $error,
+ ),
+ 0,
+ ""
+ );
+
+ try {
+ $client->request('POST', 'baz', 'sillybody', array('Content-Type' => 'text/plain'));
+ $this->fail('Exception was not thrown');
+ } catch (Exception $e) {
+ $this->assertEquals($e->getHTTPCode(), $error);
+ }
+
+
+ }
+
+ public function supportedHTTPCodes() {
+
+ return array(
+ array(400),
+ array(401),
+ array(402),
+ array(403),
+ array(404),
+ array(405),
+ array(409),
+ array(412),
+ array(416),
+ array(500),
+ array(501),
+ array(507),
+ );
+
+ }
+
+ function testUnsupportedHTTPError() {
+
+ $client = new ClientMock(array(
+ 'baseUri' => 'http://example.org/foo/bar/',
+ ));
+
+ $responseBlob = array(
+ "HTTP/1.1 580 blabla",
+ "Content-Type: text/plain",
+ "",
+ "Hello there!"
+ );
+
+ $client->response = array(
+ implode("\r\n", $responseBlob),
+ array(
+ 'header_size' => 42,
+ 'http_code' => "580"
+ ),
+ 0,
+ ""
+ );
+
+ try {
+ $client->request('POST', 'baz', 'sillybody', array('Content-Type' => 'text/plain'));
+ $this->fail('Exception was not thrown');
+ } catch (Exception $e) {
+ $this->assertEquals(500, $e->getHTTPCode());
+ }
+
+
+ }
+
+ function testGetAbsoluteUrl() {
+
+ $client = new ClientMock(array(
+ 'baseUri' => 'http://example.org/foo/',
+ ));
+
+ $this->assertEquals(
+ 'http://example.org/foo/bar',
+ $client->getAbsoluteUrl('bar')
+ );
+
+ $this->assertEquals(
+ 'http://example.org/bar',
+ $client->getAbsoluteUrl('/bar')
+ );
+
+ $this->assertEquals(
+ 'http://example.com/bar',
+ $client->getAbsoluteUrl('http://example.com/bar')
+ );
+
+ }
+
+ function testOptions() {
+
+ $client = new ClientMock(array(
+ 'baseUri' => 'http://example.org/foo/bar/',
+ ));
+
+ $responseBlob = array(
+ "HTTP/1.1 200 OK",
+ "DAV: feature1, feature2",
+ "",
+ );
+
+ $client->response = array(
+ implode("\r\n", $responseBlob),
+ array(
+ 'header_size' => 40,
+ 'http_code' => 200,
+ ),
+ 0,
+ ""
+ );
+
+ $result = $client->options();
+ $this->assertEquals(
+ array('feature1', 'feature2'),
+ $result
+ );
+
+ }
+
+ function testOptionsNoDav() {
+
+ $client = new ClientMock(array(
+ 'baseUri' => 'http://example.org/foo/bar/',
+ ));
+
+ $responseBlob = array(
+ "HTTP/1.1 200 OK",
+ "",
+ );
+
+ $client->response = array(
+ implode("\r\n", $responseBlob),
+ array(
+ 'header_size' => 20,
+ 'http_code' => 200,
+ ),
+ 0,
+ ""
+ );
+
+ $result = $client->options();
+ $this->assertEquals(
+ array(),
+ $result
+ );
+
+ }
+
+ /**
+ * @expectedException InvalidArgumentException
+ */
+ function testPropFindNoXML() {
+
+ $client = new ClientMock(array(
+ 'baseUri' => 'http://example.org/foo/bar/',
+ ));
+
+ $responseBlob = array(
+ "HTTP/1.1 200 OK",
+ "",
+ );
+
+ $client->response = array(
+ implode("\r\n", $responseBlob),
+ array(
+ 'header_size' => 20,
+ 'http_code' => 200,
+ ),
+ 0,
+ ""
+ );
+
+ $client->propfind('', array('{DAV:}foo','{DAV:}bar'));
+
+ }
+
+ function testPropFind() {
+
+ $client = new ClientMock(array(
+ 'baseUri' => 'http://example.org/foo/bar/',
+ ));
+
+ $responseBlob = array(
+ "HTTP/1.1 200 OK",
+ "",
+ "<?xml version=\"1.0\"?>",
+ "<d:multistatus xmlns:d=\"DAV:\">",
+ " <d:response>",
+ " <d:href>/foo/bar/</d:href>",
+ " <d:propstat>",
+ " <d:prop>",
+ " <d:foo>hello</d:foo>",
+ " </d:prop>",
+ " <d:status>HTTP/1.1 200 OK</d:status>",
+ " </d:propstat>",
+ " <d:propstat>",
+ " <d:prop>",
+ " <d:bar />",
+ " </d:prop>",
+ " <d:status>HTTP/1.1 404 Not Found</d:status>",
+ " </d:propstat>",
+ " </d:response>",
+ "</d:multistatus>",
+ );
+
+ $client->response = array(
+ implode("\r\n", $responseBlob),
+ array(
+ 'header_size' => 19,
+ 'http_code' => 200,
+ ),
+ 0,
+ ""
+ );
+
+ $result = $client->propfind('', array('{DAV:}foo','{DAV:}bar'));
+
+ $this->assertEquals(array(
+ '{DAV:}foo' => 'hello',
+ ), $result);
+
+ $requestBody = array(
+ '<?xml version="1.0"?>',
+ '<d:propfind xmlns:d="DAV:">',
+ ' <d:prop>',
+ ' <d:foo />',
+ ' <d:bar />',
+ ' </d:prop>',
+ '</d:propfind>'
+ );
+ $requestBody = implode("\n", $requestBody);
+
+ $this->assertEquals($requestBody, $client->curlSettings[CURLOPT_POSTFIELDS]);
+
+ }
+
+ /**
+ * This was reported in Issue 235.
+ *
+ * If no '200 Ok' properties are returned, the client will throw an
+ * E_NOTICE.
+ */
+ function testPropFindNo200s() {
+
+ $client = new ClientMock(array(
+ 'baseUri' => 'http://example.org/foo/bar/',
+ ));
+
+ $responseBlob = array(
+ "HTTP/1.1 200 OK",
+ "",
+ "<?xml version=\"1.0\"?>",
+ "<d:multistatus xmlns:d=\"DAV:\">",
+ " <d:response>",
+ " <d:href>/foo/bar/</d:href>",
+ " <d:propstat>",
+ " <d:prop>",
+ " <d:bar />",
+ " </d:prop>",
+ " <d:status>HTTP/1.1 404 Not Found</d:status>",
+ " </d:propstat>",
+ " </d:response>",
+ "</d:multistatus>",
+ );
+
+ $client->response = array(
+ implode("\r\n", $responseBlob),
+ array(
+ 'header_size' => 19,
+ 'http_code' => 200,
+ ),
+ 0,
+ ""
+ );
+
+ $result = $client->propfind('', array('{DAV:}foo','{DAV:}bar'));
+
+ $this->assertEquals(array(
+ ), $result);
+
+ }
+
+ function testPropFindDepth1CustomProp() {
+
+ $client = new ClientMock(array(
+ 'baseUri' => 'http://example.org/foo/bar/',
+ ));
+
+ $responseBlob = array(
+ "HTTP/1.1 200 OK",
+ "",
+ "<?xml version=\"1.0\"?>",
+ "<d:multistatus xmlns:d=\"DAV:\" xmlns:x=\"urn:custom\">",
+ " <d:response>",
+ " <d:href>/foo/bar/</d:href>",
+ " <d:propstat>",
+ " <d:prop>",
+ " <d:foo>hello</d:foo>",
+ " <x:bar>world</x:bar>",
+ " </d:prop>",
+ " <d:status>HTTP/1.1 200 OK</d:status>",
+ " </d:propstat>",
+ " </d:response>",
+ "</d:multistatus>",
+ );
+
+ $client->response = array(
+ implode("\r\n", $responseBlob),
+ array(
+ 'header_size' => 19,
+ 'http_code' => 200,
+ ),
+ 0,
+ ""
+ );
+
+ $result = $client->propfind('', array('{DAV:}foo','{urn:custom}bar'),1);
+
+ $this->assertEquals(array(
+ "/foo/bar/" => array(
+ '{DAV:}foo' => 'hello',
+ '{urn:custom}bar' => 'world',
+ ),
+ ), $result);
+
+ $requestBody = array(
+ '<?xml version="1.0"?>',
+ '<d:propfind xmlns:d="DAV:">',
+ ' <d:prop>',
+ ' <d:foo />',
+ ' <x:bar xmlns:x="urn:custom"/>',
+ ' </d:prop>',
+ '</d:propfind>'
+ );
+ $requestBody = implode("\n", $requestBody);
+
+ $this->assertEquals($requestBody, $client->curlSettings[CURLOPT_POSTFIELDS]);
+
+ }
+
+ function testPropPatch() {
+
+ $client = new ClientMock(array(
+ 'baseUri' => 'http://example.org/foo/bar/',
+ ));
+
+ $responseBlob = array(
+ "HTTP/1.1 200 OK",
+ "",
+ );
+
+ $client->response = array(
+ implode("\r\n", $responseBlob),
+ array(
+ 'header_size' => 20,
+ 'http_code' => 200,
+ ),
+ 0,
+ ""
+ );
+
+ $client->proppatch('', array(
+ '{DAV:}foo' => 'newvalue',
+ '{urn:custom}foo' => 'newvalue2',
+ '{DAV:}bar' => null,
+ '{urn:custom}bar' => null,
+ ));
+
+ $requestBody = array(
+ '<?xml version="1.0"?>',
+ '<d:propertyupdate xmlns:d="DAV:">',
+ '<d:set><d:prop>',
+ ' <d:foo>newvalue</d:foo>',
+ '</d:prop></d:set>',
+ '<d:set><d:prop>',
+ ' <x:foo xmlns:x="urn:custom">newvalue2</x:foo>',
+ '</d:prop></d:set>',
+ '<d:remove><d:prop>',
+ ' <d:bar />',
+ '</d:prop></d:remove>',
+ '<d:remove><d:prop>',
+ ' <x:bar xmlns:x="urn:custom"/>',
+ '</d:prop></d:remove>',
+ '</d:propertyupdate>'
+ );
+ $requestBody = implode("\n", $requestBody);
+
+ $this->assertEquals($requestBody, $client->curlSettings[CURLOPT_POSTFIELDS]);
+
+ }
+
+ function testHEADRequest() {
+
+ $client = new ClientMock(array(
+ 'baseUri' => 'http://example.org/foo/bar/',
+ ));
+
+ $responseBlob = array(
+ "HTTP/1.1 200 OK",
+ "Content-Type: text/plain",
+ "",
+ "Hello there!"
+ );
+
+ $client->response = array(
+ implode("\r\n", $responseBlob),
+ array(
+ 'header_size' => 45,
+ 'http_code' => 200,
+ ),
+ 0,
+ ""
+ );
+
+ $result = $client->request('HEAD', 'baz');
+
+ $this->assertEquals('http://example.org/foo/bar/baz', $client->url);
+ $this->assertEquals(array(
+ CURLOPT_RETURNTRANSFER => true,
+ CURLOPT_FOLLOWLOCATION => true,
+ CURLOPT_MAXREDIRS => 5,
+ CURLOPT_CUSTOMREQUEST => 'HEAD',
+ CURLOPT_NOBODY => true,
+ CURLOPT_HEADER => true,
+ CURLOPT_HTTPHEADER => array(),
+ CURLOPT_POSTFIELDS => null,
+ ), $client->curlSettings);
+
+ }
+
+ function testPUTRequest() {
+
+ $client = new ClientMock(array(
+ 'baseUri' => 'http://example.org/foo/bar/',
+ ));
+
+ $responseBlob = array(
+ "HTTP/1.1 200 OK",
+ "Content-Type: text/plain",
+ "",
+ "Hello there!"
+ );
+
+ $client->response = array(
+ implode("\r\n", $responseBlob),
+ array(
+ 'header_size' => 45,
+ 'http_code' => 200,
+ ),
+ 0,
+ ""
+ );
+
+ $result = $client->request('PUT', 'bar','newcontent');
+
+ $this->assertEquals('http://example.org/foo/bar/bar', $client->url);
+ $this->assertEquals(array(
+ CURLOPT_RETURNTRANSFER => true,
+ CURLOPT_FOLLOWLOCATION => true,
+ CURLOPT_MAXREDIRS => 5,
+ CURLOPT_CUSTOMREQUEST => "PUT",
+ CURLOPT_POSTFIELDS => 'newcontent',
+ CURLOPT_HEADER => true,
+ CURLOPT_HTTPHEADER => array(),
+ ), $client->curlSettings);
+
+ }
+}
diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Exception/LockedTest.php b/vendor/sabre/dav/tests/Sabre/DAV/Exception/LockedTest.php
new file mode 100644
index 000000000..c06d6aa1f
--- /dev/null
+++ b/vendor/sabre/dav/tests/Sabre/DAV/Exception/LockedTest.php
@@ -0,0 +1,68 @@
+<?php
+
+namespace Sabre\DAV\Exception;
+
+use
+ Sabre\DAV,
+ DOMDocument;
+
+class LockedTest extends \PHPUnit_Framework_TestCase {
+
+ function testSerialize() {
+
+ $dom = new DOMDocument('1.0');
+ $dom->formatOutput = true;
+ $root = $dom->createElement('d:root');
+
+ $dom->appendChild($root);
+ $root->setAttribute('xmlns:d','DAV:');
+
+ $lockInfo = new DAV\Locks\LockInfo();
+ $lockInfo->uri = '/foo';
+ $locked = new Locked($lockInfo);
+
+ $locked->serialize(new DAV\Server(), $root);
+
+ $output = $dom->saveXML();
+
+ $expected = '<?xml version="1.0"?>
+<d:root xmlns:d="DAV:">
+ <d:lock-token-submitted xmlns:d="DAV:">
+ <d:href>/foo</d:href>
+ </d:lock-token-submitted>
+</d:root>
+';
+
+ $this->assertEquals($expected, $output);
+
+ }
+
+ function testSerializeAmpersand() {
+
+ $dom = new DOMDocument('1.0');
+ $dom->formatOutput = true;
+ $root = $dom->createElement('d:root');
+
+ $dom->appendChild($root);
+ $root->setAttribute('xmlns:d','DAV:');
+
+ $lockInfo = new DAV\Locks\LockInfo();
+ $lockInfo->uri = '/foo&bar';
+ $locked = new Locked($lockInfo);
+
+ $locked->serialize(new DAV\Server(), $root);
+
+ $output = $dom->saveXML();
+
+ $expected = '<?xml version="1.0"?>
+<d:root xmlns:d="DAV:">
+ <d:lock-token-submitted xmlns:d="DAV:">
+ <d:href>/foo&amp;bar</d:href>
+ </d:lock-token-submitted>
+</d:root>
+';
+
+ $this->assertEquals($expected, $output);
+
+ }
+}
diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Exception/PaymentRequiredTest.php b/vendor/sabre/dav/tests/Sabre/DAV/Exception/PaymentRequiredTest.php
new file mode 100644
index 000000000..7142937b4
--- /dev/null
+++ b/vendor/sabre/dav/tests/Sabre/DAV/Exception/PaymentRequiredTest.php
@@ -0,0 +1,14 @@
+<?php
+
+namespace Sabre\DAV\Exception;
+
+class PaymentRequiredTest extends \PHPUnit_Framework_TestCase {
+
+ function testGetHTTPCode() {
+
+ $ex = new PaymentRequired();
+ $this->assertEquals(402, $ex->getHTTPCode());
+
+ }
+
+}
diff --git a/vendor/sabre/dav/tests/Sabre/DAV/ExceptionTest.php b/vendor/sabre/dav/tests/Sabre/DAV/ExceptionTest.php
new file mode 100644
index 000000000..6d6bf5668
--- /dev/null
+++ b/vendor/sabre/dav/tests/Sabre/DAV/ExceptionTest.php
@@ -0,0 +1,30 @@
+<?php
+
+namespace Sabre\DAV;
+
+class ExceptionTest extends \PHPUnit_Framework_TestCase {
+
+ function testStatus() {
+
+ $e = new Exception();
+ $this->assertEquals(500,$e->getHTTPCode());
+
+ }
+
+ function testExceptionStatuses() {
+
+ $c = array(
+ 'Sabre\\DAV\\Exception\\NotAuthenticated' => 401,
+ 'Sabre\\DAV\\Exception\\InsufficientStorage' => 507,
+ );
+
+ foreach($c as $class=>$status) {
+
+ $obj = new $class();
+ $this->assertEquals($status, $obj->getHTTPCode());
+
+ }
+
+ }
+
+}
diff --git a/vendor/sabre/dav/tests/Sabre/DAV/FSExt/FileTest.php b/vendor/sabre/dav/tests/Sabre/DAV/FSExt/FileTest.php
new file mode 100644
index 000000000..265f9f1c1
--- /dev/null
+++ b/vendor/sabre/dav/tests/Sabre/DAV/FSExt/FileTest.php
@@ -0,0 +1,95 @@
+<?php
+
+namespace Sabre\DAV\FSExt;
+
+use Sabre\DAV;
+
+require_once 'Sabre/TestUtil.php';
+
+class FileTest extends \PHPUnit_Framework_TestCase {
+
+ function setUp() {
+
+ file_put_contents(SABRE_TEMPDIR . '/file.txt', 'Contents');
+
+ }
+
+ function tearDown() {
+
+ \Sabre\TestUtil::clearTempDir();
+
+ }
+
+ function testPut() {
+
+ $file = new File(SABRE_TEMPDIR . '/file.txt');
+ $result = $file->put('New contents');
+
+ $this->assertEquals('New contents',file_get_contents(SABRE_TEMPDIR . '/file.txt'));
+ $this->assertEquals('"' . md5('New contents') . '"', $result);
+
+ }
+
+ function testRange() {
+
+ $file = new File(SABRE_TEMPDIR . '/file.txt');
+ $file->put('0000000');
+ $file->putRange('111',3);
+
+ $this->assertEquals('0011100',file_get_contents(SABRE_TEMPDIR . '/file.txt'));
+
+ }
+
+ function testRangeStream() {
+
+ $stream = fopen('php://memory','r+');
+ fwrite($stream, "222");
+ rewind($stream);
+
+ $file = new File(SABRE_TEMPDIR . '/file.txt');
+ $file->put('0000000');
+ $file->putRange($stream,3);
+
+ $this->assertEquals('0022200',file_get_contents(SABRE_TEMPDIR . '/file.txt'));
+
+ }
+
+
+ function testGet() {
+
+ $file = new File(SABRE_TEMPDIR . '/file.txt');
+ $this->assertEquals('Contents',stream_get_contents($file->get()));
+
+ }
+
+ function testDelete() {
+
+ $file = new File(SABRE_TEMPDIR . '/file.txt');
+ $file->delete();
+
+ $this->assertFalse(file_exists(SABRE_TEMPDIR . '/file.txt'));
+
+ }
+
+ function testGetETag() {
+
+ $file = new File(SABRE_TEMPDIR . '/file.txt');
+ $this->assertEquals('"' . md5('Contents') . '"',$file->getETag());
+
+ }
+
+ function testGetContentType() {
+
+ $file = new File(SABRE_TEMPDIR . '/file.txt');
+ $this->assertNull($file->getContentType());
+
+ }
+
+ function testGetSize() {
+
+ $file = new File(SABRE_TEMPDIR . '/file.txt');
+ $this->assertEquals(8,$file->getSize());
+
+ }
+
+}
diff --git a/vendor/sabre/dav/tests/Sabre/DAV/FSExt/NodeTest.php b/vendor/sabre/dav/tests/Sabre/DAV/FSExt/NodeTest.php
new file mode 100644
index 000000000..275075b4c
--- /dev/null
+++ b/vendor/sabre/dav/tests/Sabre/DAV/FSExt/NodeTest.php
@@ -0,0 +1,178 @@
+<?php
+
+namespace Sabre\DAV\FSExt;
+use Sabre\DAV;
+
+require_once 'Sabre/TestUtil.php';
+
+class NodeTest extends \PHPUnit_Framework_TestCase {
+
+ function setUp() {
+
+ mkdir(SABRE_TEMPDIR . '/dir');
+ file_put_contents(SABRE_TEMPDIR . '/dir/file.txt', 'Contents');
+ file_put_contents(SABRE_TEMPDIR . '/dir/file2.txt', 'Contents2');
+
+ }
+
+ function tearDown() {
+
+ \Sabre\TestUtil::clearTempDir();
+
+ }
+
+ function testUpdateProperties() {
+
+ $file = new File(SABRE_TEMPDIR . '/dir/file.txt');
+ $properties = array(
+ '{http://sabredav.org/NS/2010}test1' => 'foo',
+ '{http://sabredav.org/NS/2010}test2' => 'bar',
+ );
+
+ $result = $file->updateProperties($properties);
+ $expected = true;
+
+ $this->assertEquals($expected, $result);
+
+ $getProperties = $file->getProperties(array_keys($properties));
+
+ $this->assertEquals($properties, $getProperties);
+
+ }
+
+ /**
+ * @depends testUpdateProperties
+ */
+ function testUpdatePropertiesAgain() {
+
+ $file = new File(SABRE_TEMPDIR . '/dir/file.txt');
+ $mutations = array(
+ '{http://sabredav.org/NS/2010}test1' => 'foo',
+ '{http://sabredav.org/NS/2010}test2' => 'bar',
+ );
+
+ $result = $file->updateProperties($mutations);
+
+ $this->assertEquals(true, $result);
+
+ $mutations = array(
+ '{http://sabredav.org/NS/2010}test1' => 'foo',
+ '{http://sabredav.org/NS/2010}test3' => 'baz',
+ );
+
+ $result = $file->updateProperties($mutations);
+
+ $this->assertEquals(true, $result);
+ }
+
+ /**
+ * @depends testUpdateProperties
+ */
+ function testUpdatePropertiesDelete() {
+
+ $file = new File(SABRE_TEMPDIR . '/dir/file.txt');
+
+ $mutations = array(
+ '{http://sabredav.org/NS/2010}test1' => 'foo',
+ '{http://sabredav.org/NS/2010}test2' => 'bar',
+ );
+
+ $result = $file->updateProperties($mutations);
+
+ $this->assertEquals(true, $result);
+
+ $mutations = array(
+ '{http://sabredav.org/NS/2010}test1' => null,
+ '{http://sabredav.org/NS/2010}test3' => null
+ );
+
+ $result = $file->updateProperties($mutations);
+
+ $this->assertEquals(true, $result);
+
+ $properties = $file->getProperties(array('http://sabredav.org/NS/2010}test1','{http://sabredav.org/NS/2010}test2','{http://sabredav.org/NS/2010}test3'));
+
+ $this->assertEquals(array(
+ '{http://sabredav.org/NS/2010}test2' => 'bar',
+ ), $properties);
+ }
+
+ /**
+ * @depends testUpdateProperties
+ */
+ function testUpdatePropertiesMove() {
+
+ $file = new File(SABRE_TEMPDIR . '/dir/file.txt');
+
+ $mutations = array(
+ '{http://sabredav.org/NS/2010}test1' => 'foo',
+ '{http://sabredav.org/NS/2010}test2' => 'bar',
+ );
+
+ $result = $file->updateProperties($mutations);
+
+ $this->assertEquals(true, $result);
+
+ $properties = $file->getProperties(array('{http://sabredav.org/NS/2010}test1','{http://sabredav.org/NS/2010}test2','{http://sabredav.org/NS/2010}test3'));
+
+ $this->assertEquals(array(
+ '{http://sabredav.org/NS/2010}test1' => 'foo',
+ '{http://sabredav.org/NS/2010}test2' => 'bar',
+ ), $properties);
+
+ // Renaming
+ $file->setName('file3.txt');
+
+ $this->assertFalse(file_exists(SABRE_TEMPDIR . '/dir/file.txt'));
+ $this->assertTrue(file_exists(SABRE_TEMPDIR . '/dir/file3.txt'));
+ $this->assertEquals('file3.txt',$file->getName());
+
+ $newFile = new File(SABRE_TEMPDIR . '/dir/file3.txt');
+ $this->assertEquals('file3.txt',$newFile->getName());
+
+ $properties = $newFile->getProperties(array('{http://sabredav.org/NS/2010}test1','{http://sabredav.org/NS/2010}test2','{http://sabredav.org/NS/2010}test3'));
+
+ $this->assertEquals(array(
+ '{http://sabredav.org/NS/2010}test1' => 'foo',
+ '{http://sabredav.org/NS/2010}test2' => 'bar',
+ ), $properties);
+ }
+
+ /**
+ * @depends testUpdatePropertiesMove
+ */
+ function testUpdatePropertiesDeleteBleed() {
+
+ $file = new File(SABRE_TEMPDIR . '/dir/file.txt');
+ $mutations = array(
+ '{http://sabredav.org/NS/2010}test1' => 'foo',
+ '{http://sabredav.org/NS/2010}test2' => 'bar',
+ );
+
+ $result = $file->updateProperties($mutations);
+
+ $this->assertEquals(true, $result);
+
+ $properties = $file->getProperties(array('{http://sabredav.org/NS/2010}test1','{http://sabredav.org/NS/2010}test2','{http://sabredav.org/NS/2010}test3'));
+
+ $this->assertEquals(array(
+ '{http://sabredav.org/NS/2010}test1' => 'foo',
+ '{http://sabredav.org/NS/2010}test2' => 'bar',
+ ), $properties);
+
+ // Deleting
+ $file->delete();
+
+ $this->assertFalse(file_exists(SABRE_TEMPDIR . '/dir/file.txt'));
+
+ // Creating it again
+ file_put_contents(SABRE_TEMPDIR . '/dir/file.txt','New Contents');
+ $file = new File(SABRE_TEMPDIR . '/dir/file.txt');
+
+ $properties = $file->getProperties(array('http://sabredav.org/NS/2010}test1','{http://sabredav.org/NS/2010}test2','{http://sabredav.org/NS/2010}test3'));
+
+ $this->assertEquals(array(), $properties);
+
+ }
+
+}
diff --git a/vendor/sabre/dav/tests/Sabre/DAV/FSExt/ServerTest.php b/vendor/sabre/dav/tests/Sabre/DAV/FSExt/ServerTest.php
new file mode 100644
index 000000000..907ede40b
--- /dev/null
+++ b/vendor/sabre/dav/tests/Sabre/DAV/FSExt/ServerTest.php
@@ -0,0 +1,224 @@
+<?php
+
+namespace Sabre\DAV\FSExt;
+
+use Sabre\DAV;
+use Sabre\HTTP;
+
+require_once 'Sabre/DAV/AbstractServer.php';
+
+class ServerTest extends DAV\AbstractServer{
+
+ protected function getRootNode() {
+
+ return new Directory($this->tempDir);
+
+ }
+
+ function testGet() {
+
+ $serverVars = array(
+ 'REQUEST_URI' => '/test.txt',
+ 'REQUEST_METHOD' => 'GET',
+ );
+
+ $request = new HTTP\Request($serverVars);
+ $this->server->httpRequest = ($request);
+ $this->server->exec();
+
+ $this->assertEquals(array(
+ 'Content-Type' => 'application/octet-stream',
+ 'Content-Length' => 13,
+ 'Last-Modified' => HTTP\Util::toHTTPDate(new \DateTime('@' . filemtime($this->tempDir . '/test.txt'))),
+ 'ETag' => '"' .md5_file($this->tempDir . '/test.txt') . '"',
+ ),
+ $this->response->headers
+ );
+
+ $this->assertEquals('HTTP/1.1 200 OK',$this->response->status);
+ $this->assertEquals('Test contents', stream_get_contents($this->response->body));
+
+ }
+
+ function testHEAD() {
+
+ $serverVars = array(
+ 'REQUEST_URI' => '/test.txt',
+ 'REQUEST_METHOD' => 'HEAD',
+ );
+
+ $request = new HTTP\Request($serverVars);
+ $this->server->httpRequest = ($request);
+ $this->server->exec();
+
+ $this->assertEquals(array(
+ 'Content-Type' => 'application/octet-stream',
+ 'Content-Length' => 13,
+ 'Last-Modified' => HTTP\Util::toHTTPDate(new \DateTime('@' . filemtime($this->tempDir . '/test.txt'))),
+ 'ETag' => '"' . md5_file($this->tempDir . '/test.txt') . '"',
+ ),
+ $this->response->headers
+ );
+
+ $this->assertEquals('HTTP/1.1 200 OK',$this->response->status);
+ $this->assertEquals('', $this->response->body);
+
+ }
+
+ function testPut() {
+
+ $serverVars = array(
+ 'REQUEST_URI' => '/testput.txt',
+ 'REQUEST_METHOD' => 'PUT',
+ );
+
+ $request = new HTTP\Request($serverVars);
+ $request->setBody('Testing new file');
+ $this->server->httpRequest = ($request);
+ $this->server->exec();
+
+ $this->assertEquals(array(
+ 'Content-Length' => 0,
+ 'ETag' => '"' . md5('Testing new file') . '"',
+ ), $this->response->headers);
+
+ $this->assertEquals('HTTP/1.1 201 Created',$this->response->status);
+ $this->assertEquals('', $this->response->body);
+ $this->assertEquals('Testing new file',file_get_contents($this->tempDir . '/testput.txt'));
+
+ }
+
+ function testPutAlreadyExists() {
+
+ $serverVars = array(
+ 'REQUEST_URI' => '/test.txt',
+ 'REQUEST_METHOD' => 'PUT',
+ 'HTTP_IF_NONE_MATCH' => '*',
+ );
+
+ $request = new HTTP\Request($serverVars);
+ $request->setBody('Testing new file');
+ $this->server->httpRequest = ($request);
+ $this->server->exec();
+
+ $this->assertEquals(array(
+ 'Content-Type' => 'application/xml; charset=utf-8',
+ ),$this->response->headers);
+
+ $this->assertEquals('HTTP/1.1 412 Precondition failed',$this->response->status);
+ $this->assertNotEquals('Testing new file',file_get_contents($this->tempDir . '/test.txt'));
+
+ }
+
+ function testMkcol() {
+
+ $serverVars = array(
+ 'REQUEST_URI' => '/testcol',
+ 'REQUEST_METHOD' => 'MKCOL',
+ );
+
+ $request = new HTTP\Request($serverVars);
+ $request->setBody("");
+ $this->server->httpRequest = ($request);
+ $this->server->exec();
+
+ $this->assertEquals(array(
+ 'Content-Length' => '0',
+ ),$this->response->headers);
+
+ $this->assertEquals('HTTP/1.1 201 Created',$this->response->status);
+ $this->assertEquals('', $this->response->body);
+ $this->assertTrue(is_dir($this->tempDir . '/testcol'));
+
+ }
+
+ function testPutUpdate() {
+
+ $serverVars = array(
+ 'REQUEST_URI' => '/test.txt',
+ 'REQUEST_METHOD' => 'PUT',
+ );
+
+ $request = new HTTP\Request($serverVars);
+ $request->setBody('Testing updated file');
+ $this->server->httpRequest = ($request);
+ $this->server->exec();
+
+ $this->assertEquals('0', $this->response->headers['Content-Length']);
+
+ $this->assertEquals('HTTP/1.1 204 No Content',$this->response->status);
+ $this->assertEquals('', $this->response->body);
+ $this->assertEquals('Testing updated file',file_get_contents($this->tempDir . '/test.txt'));
+
+ }
+
+ function testDelete() {
+
+ $serverVars = array(
+ 'REQUEST_URI' => '/test.txt',
+ 'REQUEST_METHOD' => 'DELETE',
+ );
+
+ $request = new HTTP\Request($serverVars);
+ $this->server->httpRequest = ($request);
+ $this->server->exec();
+
+ $this->assertEquals(array(
+ 'Content-Length' => '0',
+ ),$this->response->headers);
+
+ $this->assertEquals('HTTP/1.1 204 No Content',$this->response->status);
+ $this->assertEquals('', $this->response->body);
+ $this->assertFalse(file_exists($this->tempDir . '/test.txt'));
+
+ }
+
+ function testDeleteDirectory() {
+
+ $serverVars = array(
+ 'REQUEST_URI' => '/testcol',
+ 'REQUEST_METHOD' => 'DELETE',
+ );
+
+ mkdir($this->tempDir.'/testcol');
+ file_put_contents($this->tempDir.'/testcol/test.txt','Hi! I\'m a file with a short lifespan');
+
+ $request = new HTTP\Request($serverVars);
+ $this->server->httpRequest = ($request);
+ $this->server->exec();
+
+ $this->assertEquals(array(
+ 'Content-Length' => '0',
+ ),$this->response->headers);
+ $this->assertEquals('HTTP/1.1 204 No Content',$this->response->status);
+ $this->assertEquals('', $this->response->body);
+ $this->assertFalse(file_exists($this->tempDir . '/col'));
+
+ }
+
+ function testOptions() {
+
+ $serverVars = array(
+ 'REQUEST_URI' => '/',
+ 'REQUEST_METHOD' => 'OPTIONS',
+ );
+
+ $request = new HTTP\Request($serverVars);
+ $this->server->httpRequest = ($request);
+ $this->server->exec();
+
+ $this->assertEquals(array(
+ 'DAV' => '1, 3, extended-mkcol',
+ 'MS-Author-Via' => 'DAV',
+ 'Allow' => 'OPTIONS, GET, HEAD, DELETE, PROPFIND, PUT, PROPPATCH, COPY, MOVE, REPORT',
+ 'Accept-Ranges' => 'bytes',
+ 'Content-Length' => '0',
+ 'X-Sabre-Version'=> DAV\Version::VERSION,
+ ),$this->response->headers);
+
+ $this->assertEquals('HTTP/1.1 200 OK',$this->response->status);
+ $this->assertEquals('', $this->response->body);
+
+ }
+
+}
diff --git a/vendor/sabre/dav/tests/Sabre/DAV/HTTPPreferParsingTest.php b/vendor/sabre/dav/tests/Sabre/DAV/HTTPPreferParsingTest.php
new file mode 100644
index 000000000..45865b2a1
--- /dev/null
+++ b/vendor/sabre/dav/tests/Sabre/DAV/HTTPPreferParsingTest.php
@@ -0,0 +1,200 @@
+<?php
+
+namespace Sabre\DAV;
+
+use Sabre\HTTP;
+
+class HTTPPReferParsingTest extends \Sabre\DAVServerTest {
+
+ function testParseSimple() {
+
+ $httpRequest = new HTTP\Request(array(
+ 'HTTP_PREFER' => 'return-asynch',
+ ));
+
+ $server = new Server();
+ $server->httpRequest = $httpRequest;
+
+ $this->assertEquals(array(
+ 'return-asynch' => true,
+ 'return-minimal' => false,
+ 'return-representation' => false,
+ 'strict' => false,
+ 'lenient' => false,
+ 'wait' => null,
+ ), $server->getHTTPPrefer());
+
+ }
+
+ function testParseValue() {
+
+ $httpRequest = new HTTP\Request(array(
+ 'HTTP_PREFER' => 'wait=10',
+ ));
+
+ $server = new Server();
+ $server->httpRequest = $httpRequest;
+
+ $this->assertEquals(array(
+ 'return-asynch' => false,
+ 'return-minimal' => false,
+ 'return-representation' => false,
+ 'strict' => false,
+ 'lenient' => false,
+ 'wait' => 10,
+ ), $server->getHTTPPrefer());
+
+ }
+
+ function testParseMultiple() {
+
+ $httpRequest = new HTTP\Request(array(
+ 'HTTP_PREFER' => 'return-minimal, strict,lenient',
+ ));
+
+ $server = new Server();
+ $server->httpRequest = $httpRequest;
+
+ $this->assertEquals(array(
+ 'return-asynch' => false,
+ 'return-minimal' => true,
+ 'return-representation' => false,
+ 'strict' => true,
+ 'lenient' => true,
+ 'wait' => null,
+ ), $server->getHTTPPrefer());
+
+ }
+
+ function testParseWeirdValue() {
+
+ $httpRequest = new HTTP\Request(array(
+ 'HTTP_PREFER' => 'BOOOH',
+ ));
+
+ $server = new Server();
+ $server->httpRequest = $httpRequest;
+
+ $this->assertEquals(array(
+ 'strict' => false,
+ 'lenient' => false,
+ 'wait' => null,
+ 'return-asynch' => false,
+ 'return-minimal' => false,
+ 'return-representation' => false,
+ ), $server->getHTTPPrefer());
+
+ }
+
+ function testBrief() {
+
+ $httpRequest = new HTTP\Request(array(
+ 'HTTP_BRIEF' => 't',
+ ));
+
+ $server = new Server();
+ $server->httpRequest = $httpRequest;
+
+ $this->assertEquals(array(
+ 'strict' => false,
+ 'lenient' => false,
+ 'wait' => null,
+ 'return-asynch' => false,
+ 'return-minimal' => true,
+ 'return-representation' => false,
+ ), $server->getHTTPPrefer());
+
+ }
+
+ /**
+ * propfindMinimal
+ *
+ * @return void
+ */
+ function testpropfindMinimal() {
+
+ $request = new HTTP\Request(array(
+ 'REQUEST_METHOD' => 'PROPFIND',
+ 'REQUEST_URI' => '/',
+ 'HTTP_PREFER' => 'return-minimal',
+ ));
+ $request->setBody(<<<BLA
+<?xml version="1.0"?>
+<d:propfind xmlns:d="DAV:">
+ <d:prop>
+ <d:something />
+ <d:resourcetype />
+ </d:prop>
+</d:propfind>
+BLA
+ );
+
+ $response = $this->request($request);
+
+ $this->assertTrue(strpos($response->body, 'resourcetype')!==false);
+ $this->assertTrue(strpos($response->body, 'something')===false);
+
+ }
+
+ function testproppatchMinimal() {
+
+ $request = new HTTP\Request(array(
+ 'REQUEST_METHOD' => 'PROPPATCH',
+ 'REQUEST_URI' => '/',
+ 'HTTP_PREFER' => 'return-minimal',
+ ));
+ $request->setBody(<<<BLA
+<?xml version="1.0"?>
+<d:proppatch xmlns:d="DAV:">
+ <d:set>
+ <d:prop>
+ <d:something>nope!</d:something>
+ </d:prop>
+ </d:set>
+</d:proppatch>
+BLA
+ );
+
+ $this->server->subscribeEvent('updateProperties', function(&$props, &$result) {
+
+ if (isset($props['{DAV:}something'])) {
+ unset($props['{DAV:}something']);
+ $result[200]['{DAV:}something'] = null;
+ }
+
+ });
+
+ $response = $this->request($request);
+
+ $this->assertEquals(0, strlen($response->body), 'Expected empty body: ' . $response->body);
+ $this->assertEquals('HTTP/1.1 204 No Content', $response->status);
+
+ }
+
+ function testproppatchMinimalError() {
+
+ $request = new HTTP\Request(array(
+ 'REQUEST_METHOD' => 'PROPPATCH',
+ 'REQUEST_URI' => '/',
+ 'HTTP_PREFER' => 'return-minimal',
+ ));
+ $request->setBody(<<<BLA
+<?xml version="1.0"?>
+<d:proppatch xmlns:d="DAV:">
+ <d:set>
+ <d:prop>
+ <d:something>nope!</d:something>
+ </d:prop>
+ </d:set>
+</d:proppatch>
+BLA
+ );
+
+ $response = $this->request($request);
+
+ $this->assertEquals('HTTP/1.1 207 Multi-Status', $response->status);
+ $this->assertTrue(strpos($response->body, 'something')!==false);
+ $this->assertTrue(strpos($response->body, 'HTTP/1.1 403 Forbidden')!==false);
+
+ }
+}
diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Issue33Test.php b/vendor/sabre/dav/tests/Sabre/DAV/Issue33Test.php
new file mode 100644
index 000000000..c3fba4aae
--- /dev/null
+++ b/vendor/sabre/dav/tests/Sabre/DAV/Issue33Test.php
@@ -0,0 +1,105 @@
+<?php
+
+namespace Sabre\DAV;
+
+use Sabre\HTTP;
+
+require_once 'Sabre/TestUtil.php';
+
+class Issue33Test extends \PHPUnit_Framework_TestCase {
+
+ function setUp() {
+
+ \Sabre\TestUtil::clearTempDir();
+
+ }
+
+ function testCopyMoveInfo() {
+
+ $bar = new SimpleCollection('bar');
+ $root = new SimpleCollection('webdav',array($bar));
+
+ $server = new Server($root);
+ $server->setBaseUri('/webdav/');
+
+ $serverVars = array(
+ 'REQUEST_URI' => '/webdav/bar',
+ 'HTTP_DESTINATION' => 'http://dev2.tribalos.com/webdav/%C3%A0fo%C3%B3',
+ 'HTTP_OVERWRITE' => 'F',
+ );
+
+ $request = new HTTP\Request($serverVars);
+
+ $server->httpRequest = $request;
+
+ $info = $server->getCopyAndMoveInfo();
+
+ $this->assertEquals('%C3%A0fo%C3%B3', urlencode($info['destination']));
+ $this->assertFalse($info['destinationExists']);
+ $this->assertFalse($info['destinationNode']);
+
+ }
+
+ function testTreeMove() {
+
+ mkdir(SABRE_TEMPDIR . '/issue33');
+ $dir = new FS\Directory(SABRE_TEMPDIR . '/issue33');
+
+ $dir->createDirectory('bar');
+
+ $tree = new ObjectTree($dir);
+ $tree->move('bar',urldecode('%C3%A0fo%C3%B3'));
+
+ $node = $tree->getNodeForPath(urldecode('%C3%A0fo%C3%B3'));
+ $this->assertEquals(urldecode('%C3%A0fo%C3%B3'),$node->getName());
+
+ }
+
+ function testDirName() {
+
+ $dirname1 = 'bar';
+ $dirname2 = urlencode('%C3%A0fo%C3%B3');;
+
+ $this->assertTrue(dirname($dirname1)==dirname($dirname2));
+
+ }
+
+ /**
+ * @depends testTreeMove
+ * @depends testCopyMoveInfo
+ */
+ function testEverything() {
+
+ // Request object
+ $serverVars = array(
+ 'REQUEST_METHOD' => 'MOVE',
+ 'REQUEST_URI' => '/webdav/bar',
+ 'HTTP_DESTINATION' => 'http://dev2.tribalos.com/webdav/%C3%A0fo%C3%B3',
+ 'HTTP_OVERWRITE' => 'F',
+ );
+
+ $request = new HTTP\Request($serverVars);
+ $request->setBody('');
+
+ $response = new HTTP\ResponseMock();
+
+ // Server setup
+ mkdir(SABRE_TEMPDIR . '/issue33');
+ $dir = new FS\Directory(SABRE_TEMPDIR . '/issue33');
+
+ $dir->createDirectory('bar');
+
+ $tree = new ObjectTree($dir);
+
+ $server = new Server($tree);
+ $server->setBaseUri('/webdav/');
+
+ $server->httpRequest = $request;
+ $server->httpResponse = $response;
+ $server->exec();
+
+ $this->assertTrue(file_exists(SABRE_TEMPDIR . '/issue33/' . urldecode('%C3%A0fo%C3%B3')));
+
+ }
+
+}
diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Locks/Backend/AbstractTest.php b/vendor/sabre/dav/tests/Sabre/DAV/Locks/Backend/AbstractTest.php
new file mode 100644
index 000000000..f39e9a036
--- /dev/null
+++ b/vendor/sabre/dav/tests/Sabre/DAV/Locks/Backend/AbstractTest.php
@@ -0,0 +1,196 @@
+<?php
+
+namespace Sabre\DAV\Locks\Backend;
+
+use Sabre\DAV;
+
+abstract class AbstractTest extends \PHPUnit_Framework_TestCase {
+
+ /**
+ * @abstract
+ * @return AbstractBackend
+ */
+ abstract function getBackend();
+
+ function testSetup() {
+
+ $backend = $this->getBackend();
+ $this->assertInstanceOf('Sabre\\DAV\\Locks\\Backend\\AbstractBackend', $backend);
+
+ }
+
+ /**
+ * @depends testSetup
+ */
+ function testGetLocks() {
+
+ $backend = $this->getBackend();
+
+ $lock = new DAV\Locks\LockInfo();
+ $lock->owner = 'Sinterklaas';
+ $lock->timeout = 60;
+ $lock->created = time();
+ $lock->token = 'MY-UNIQUE-TOKEN';
+ $lock->uri ='someuri';
+
+ $this->assertTrue($backend->lock('someuri', $lock));
+
+ $locks = $backend->getLocks('someuri', false);
+
+ $this->assertEquals(1,count($locks));
+ $this->assertEquals('Sinterklaas',$locks[0]->owner);
+ $this->assertEquals('someuri',$locks[0]->uri);
+
+ }
+
+ /**
+ * @depends testGetLocks
+ */
+ function testGetLocksParent() {
+
+ $backend = $this->getBackend();
+
+ $lock = new DAV\Locks\LockInfo();
+ $lock->owner = 'Sinterklaas';
+ $lock->timeout = 60;
+ $lock->created = time();
+ $lock->depth = DAV\Server::DEPTH_INFINITY;
+ $lock->token = 'MY-UNIQUE-TOKEN';
+
+ $this->assertTrue($backend->lock('someuri', $lock));
+
+ $locks = $backend->getLocks('someuri/child', false);
+
+ $this->assertEquals(1,count($locks));
+ $this->assertEquals('Sinterklaas',$locks[0]->owner);
+ $this->assertEquals('someuri',$locks[0]->uri);
+
+ }
+
+
+ /**
+ * @depends testGetLocks
+ */
+ function testGetLocksParentDepth0() {
+
+ $backend = $this->getBackend();
+
+ $lock = new DAV\Locks\LockInfo();
+ $lock->owner = 'Sinterklaas';
+ $lock->timeout = 60;
+ $lock->created = time();
+ $lock->depth = 0;
+ $lock->token = 'MY-UNIQUE-TOKEN';
+
+ $this->assertTrue($backend->lock('someuri', $lock));
+
+ $locks = $backend->getLocks('someuri/child', false);
+
+ $this->assertEquals(0,count($locks));
+
+ }
+
+ function testGetLocksChildren() {
+
+ $backend = $this->getBackend();
+
+ $lock = new DAV\Locks\LockInfo();
+ $lock->owner = 'Sinterklaas';
+ $lock->timeout = 60;
+ $lock->created = time();
+ $lock->depth = 0;
+ $lock->token = 'MY-UNIQUE-TOKEN';
+
+ $this->assertTrue($backend->lock('someuri/child', $lock));
+
+ $locks = $backend->getLocks('someuri/child', false);
+ $this->assertEquals(1,count($locks));
+
+ $locks = $backend->getLocks('someuri', false);
+ $this->assertEquals(0,count($locks));
+
+ $locks = $backend->getLocks('someuri', true);
+ $this->assertEquals(1,count($locks));
+
+ }
+
+ /**
+ * @depends testGetLocks
+ */
+ function testLockRefresh() {
+
+ $backend = $this->getBackend();
+
+ $lock = new DAV\Locks\LockInfo();
+ $lock->owner = 'Sinterklaas';
+ $lock->timeout = 60;
+ $lock->created = time();
+ $lock->token = 'MY-UNIQUE-TOKEN';
+
+ $this->assertTrue($backend->lock('someuri', $lock));
+ /* Second time */
+
+ $lock->owner = 'Santa Clause';
+ $this->assertTrue($backend->lock('someuri', $lock));
+
+ $locks = $backend->getLocks('someuri', false);
+
+ $this->assertEquals(1,count($locks));
+
+ $this->assertEquals('Santa Clause',$locks[0]->owner);
+ $this->assertEquals('someuri',$locks[0]->uri);
+
+ }
+
+ /**
+ * @depends testGetLocks
+ */
+ function testUnlock() {
+
+ $backend = $this->getBackend();
+
+ $lock = new DAV\Locks\LockInfo();
+ $lock->owner = 'Sinterklaas';
+ $lock->timeout = 60;
+ $lock->created = time();
+ $lock->token = 'MY-UNIQUE-TOKEN';
+
+ $this->assertTrue($backend->lock('someuri', $lock));
+
+ $locks = $backend->getLocks('someuri', false);
+ $this->assertEquals(1,count($locks));
+
+ $this->assertTrue($backend->unlock('someuri',$lock));
+
+ $locks = $backend->getLocks('someuri', false);
+ $this->assertEquals(0,count($locks));
+
+ }
+
+ /**
+ * @depends testUnlock
+ */
+ function testUnlockUnknownToken() {
+
+ $backend = $this->getBackend();
+
+ $lock = new DAV\Locks\LockInfo();
+ $lock->owner = 'Sinterklaas';
+ $lock->timeout = 60;
+ $lock->created = time();
+ $lock->token = 'MY-UNIQUE-TOKEN';
+
+ $this->assertTrue($backend->lock('someuri', $lock));
+
+ $locks = $backend->getLocks('someuri', false);
+ $this->assertEquals(1,count($locks));
+
+ $lock->token = 'SOME-OTHER-TOKEN';
+ $this->assertFalse($backend->unlock('someuri',$lock));
+
+ $locks = $backend->getLocks('someuri', false);
+ $this->assertEquals(1,count($locks));
+
+ }
+
+}
diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Locks/Backend/FSTest.php b/vendor/sabre/dav/tests/Sabre/DAV/Locks/Backend/FSTest.php
new file mode 100644
index 000000000..651abf786
--- /dev/null
+++ b/vendor/sabre/dav/tests/Sabre/DAV/Locks/Backend/FSTest.php
@@ -0,0 +1,31 @@
+<?php
+
+namespace Sabre\DAV\Locks\Backend;
+
+require_once 'Sabre/TestUtil.php';
+
+class FSTest extends AbstractTest {
+
+ function getBackend() {
+
+ \Sabre\TestUtil::clearTempDir();
+ mkdir(SABRE_TEMPDIR . '/locks');
+ $backend = new FS(SABRE_TEMPDIR . '/locks/');
+ return $backend;
+
+ }
+
+ function tearDown() {
+
+ \Sabre\TestUtil::clearTempDir();
+
+ }
+
+ function testGetLocksChildren() {
+
+ // We're skipping this test. This doesn't work, and it will
+ // never. The class is deprecated anyway.
+
+ }
+
+}
diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Locks/Backend/FileTest.php b/vendor/sabre/dav/tests/Sabre/DAV/Locks/Backend/FileTest.php
new file mode 100644
index 000000000..537996f3b
--- /dev/null
+++ b/vendor/sabre/dav/tests/Sabre/DAV/Locks/Backend/FileTest.php
@@ -0,0 +1,24 @@
+<?php
+
+namespace Sabre\DAV\Locks\Backend;
+
+require_once 'Sabre/TestUtil.php';
+
+class FileTest extends AbstractTest {
+
+ function getBackend() {
+
+ \Sabre\TestUtil::clearTempDir();
+ $backend = new File(SABRE_TEMPDIR . '/lockdb');
+ return $backend;
+
+ }
+
+
+ function tearDown() {
+
+ \Sabre\TestUtil::clearTempDir();
+
+ }
+
+}
diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Locks/Backend/PDOMySQLTest.php b/vendor/sabre/dav/tests/Sabre/DAV/Locks/Backend/PDOMySQLTest.php
new file mode 100644
index 000000000..b6f06224c
--- /dev/null
+++ b/vendor/sabre/dav/tests/Sabre/DAV/Locks/Backend/PDOMySQLTest.php
@@ -0,0 +1,32 @@
+<?php
+
+namespace Sabre\DAV\Locks\Backend;
+
+require_once 'Sabre/TestUtil.php';
+
+class PDOMySQLTest extends AbstractTest {
+
+ function getBackend() {
+
+ if (!SABRE_HASMYSQL) $this->markTestSkipped('MySQL driver is not available, or it was not properly configured');
+ $pdo = \Sabre\TestUtil::getMySQLDB();
+ if (!$pdo) $this->markTestSkipped('Could not connect to MySQL database');
+ $pdo->query('DROP TABLE IF EXISTS locks;');
+ $pdo->query("
+CREATE TABLE locks (
+ id INTEGER UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,
+ owner VARCHAR(100),
+ timeout INTEGER UNSIGNED,
+ created INTEGER,
+ token VARCHAR(100),
+ scope TINYINT,
+ depth TINYINT,
+ uri text
+);");
+
+ $backend = new PDO($pdo);
+ return $backend;
+
+ }
+
+}
diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Locks/Backend/PDOTest.php b/vendor/sabre/dav/tests/Sabre/DAV/Locks/Backend/PDOTest.php
new file mode 100644
index 000000000..d6336c7b2
--- /dev/null
+++ b/vendor/sabre/dav/tests/Sabre/DAV/Locks/Backend/PDOTest.php
@@ -0,0 +1,29 @@
+<?php
+
+namespace Sabre\DAV\Locks\Backend;
+
+require_once 'Sabre/TestUtil.php';
+require_once 'Sabre/DAV/Locks/Backend/AbstractTest.php';
+
+class PDOTest extends AbstractTest {
+
+ function getBackend() {
+
+ if (!SABRE_HASSQLITE) $this->markTestSkipped('SQLite driver is not available');
+ \Sabre\TestUtil::clearTempDir();
+ mkdir(SABRE_TEMPDIR . '/pdolocks');
+ $pdo = new \PDO('sqlite:' . SABRE_TEMPDIR . '/pdolocks/db.sqlite');
+ $pdo->setAttribute(\PDO::ATTR_ERRMODE,\PDO::ERRMODE_EXCEPTION);
+ $pdo->query('CREATE TABLE locks ( id integer primary key asc, owner text, timeout text, created integer, token text, scope integer, depth integer, uri text)');
+ $backend = new PDO($pdo);
+ return $backend;
+
+ }
+
+ function tearDown() {
+
+ \Sabre\TestUtil::clearTempDir();
+
+ }
+
+}
diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Locks/GetIfConditionsTest.php b/vendor/sabre/dav/tests/Sabre/DAV/Locks/GetIfConditionsTest.php
new file mode 100644
index 000000000..7b2cd0db0
--- /dev/null
+++ b/vendor/sabre/dav/tests/Sabre/DAV/Locks/GetIfConditionsTest.php
@@ -0,0 +1,375 @@
+<?php
+
+namespace Sabre\DAV\Locks;
+
+use Sabre\DAV;
+use Sabre\HTTP;
+
+require_once 'Sabre/HTTP/ResponseMock.php';
+require_once 'Sabre/DAV/AbstractServer.php';
+
+class GetIfConditionsTest extends DAV\AbstractServer {
+
+ /**
+ * @var Sabre\DAV\Locks\Plugin
+ */
+ protected $locksPlugin;
+
+ function setUp() {
+
+ parent::setUp();
+ $locksPlugin = new Plugin();
+ $this->server->addPlugin($locksPlugin);
+ $this->locksPlugin = $locksPlugin;
+
+ }
+
+ function testNoConditions() {
+
+ $serverVars = array(
+ );
+
+ $request = new HTTP\Request($serverVars);
+ $this->server->httpRequest = ($request);
+
+ $conditions = $this->locksPlugin->getIfConditions();
+ $this->assertEquals(array(),$conditions);
+
+ }
+
+ function testLockToken() {
+
+ $serverVars = array(
+ 'HTTP_IF' => '(<opaquelocktoken:token1>)',
+ );
+
+ $request = new HTTP\Request($serverVars);
+ $this->server->httpRequest = ($request);
+
+ $conditions = $this->locksPlugin->getIfConditions();
+
+ $compare = array(
+
+ array(
+ 'uri' => '',
+ 'tokens' => array(
+ array(
+ 1,
+ 'opaquelocktoken:token1',
+ '',
+ ),
+ ),
+
+ ),
+
+ );
+
+ $this->assertEquals($compare,$conditions);
+
+ }
+
+ function testNotLockToken() {
+
+ $serverVars = array(
+ 'HTTP_IF' => '(Not <opaquelocktoken:token1>)',
+ );
+
+ $request = new HTTP\Request($serverVars);
+ $this->server->httpRequest = ($request);
+
+ $conditions = $this->locksPlugin->getIfConditions();
+
+ $compare = array(
+
+ array(
+ 'uri' => '',
+ 'tokens' => array(
+ array(
+ 0,
+ 'opaquelocktoken:token1',
+ '',
+ ),
+ ),
+
+ ),
+
+ );
+ $this->assertEquals($compare,$conditions);
+
+ }
+
+ function testLockTokenUrl() {
+
+ $serverVars = array(
+ 'HTTP_IF' => '<http://www.example.com/> (<opaquelocktoken:token1>)',
+ );
+
+ $request = new HTTP\Request($serverVars);
+ $this->server->httpRequest = ($request);
+
+ $conditions = $this->locksPlugin->getIfConditions();
+
+ $compare = array(
+
+ array(
+ 'uri' => 'http://www.example.com/',
+ 'tokens' => array(
+ array(
+ 1,
+ 'opaquelocktoken:token1',
+ '',
+ ),
+ ),
+
+ ),
+
+ );
+ $this->assertEquals($compare,$conditions);
+
+ }
+
+ function test2LockTokens() {
+
+ $serverVars = array(
+ 'HTTP_IF' => '(<opaquelocktoken:token1>) (Not <opaquelocktoken:token2>)',
+ );
+
+ $request = new HTTP\Request($serverVars);
+ $this->server->httpRequest = ($request);
+
+ $conditions = $this->locksPlugin->getIfConditions();
+
+ $compare = array(
+
+ array(
+ 'uri' => '',
+ 'tokens' => array(
+ array(
+ 1,
+ 'opaquelocktoken:token1',
+ '',
+ ),
+ array(
+ 0,
+ 'opaquelocktoken:token2',
+ '',
+ ),
+ ),
+
+ ),
+
+ );
+ $this->assertEquals($compare,$conditions);
+
+ }
+
+ function test2UriLockTokens() {
+
+ $serverVars = array(
+ 'HTTP_IF' => '<http://www.example.org/node1> (<opaquelocktoken:token1>) <http://www.example.org/node2> (Not <opaquelocktoken:token2>)',
+ );
+
+ $request = new HTTP\Request($serverVars);
+ $this->server->httpRequest = ($request);
+
+ $conditions = $this->locksPlugin->getIfConditions();
+
+ $compare = array(
+
+ array(
+ 'uri' => 'http://www.example.org/node1',
+ 'tokens' => array(
+ array(
+ 1,
+ 'opaquelocktoken:token1',
+ '',
+ ),
+ ),
+ ),
+ array(
+ 'uri' => 'http://www.example.org/node2',
+ 'tokens' => array(
+ array(
+ 0,
+ 'opaquelocktoken:token2',
+ '',
+ ),
+ ),
+
+ ),
+
+ );
+ $this->assertEquals($compare,$conditions);
+
+ }
+
+ function test2UriMultiLockTokens() {
+
+ $serverVars = array(
+ 'HTTP_IF' => '<http://www.example.org/node1> (<opaquelocktoken:token1>) (<opaquelocktoken:token2>) <http://www.example.org/node2> (Not <opaquelocktoken:token3>)',
+ );
+
+ $request = new HTTP\Request($serverVars);
+ $this->server->httpRequest = ($request);
+
+ $conditions = $this->locksPlugin->getIfConditions();
+
+ $compare = array(
+
+ array(
+ 'uri' => 'http://www.example.org/node1',
+ 'tokens' => array(
+ array(
+ 1,
+ 'opaquelocktoken:token1',
+ '',
+ ),
+ array(
+ 1,
+ 'opaquelocktoken:token2',
+ '',
+ ),
+ ),
+ ),
+ array(
+ 'uri' => 'http://www.example.org/node2',
+ 'tokens' => array(
+ array(
+ 0,
+ 'opaquelocktoken:token3',
+ '',
+ ),
+ ),
+
+ ),
+
+ );
+ $this->assertEquals($compare,$conditions);
+
+ }
+
+ function testEtag() {
+
+ $serverVars = array(
+ 'HTTP_IF' => '([etag1])',
+ );
+
+ $request = new HTTP\Request($serverVars);
+ $this->server->httpRequest = ($request);
+
+ $conditions = $this->locksPlugin->getIfConditions();
+
+ $compare = array(
+
+ array(
+ 'uri' => '',
+ 'tokens' => array(
+ array(
+ 1,
+ '',
+ 'etag1',
+ ),
+ ),
+ ),
+
+ );
+ $this->assertEquals($compare,$conditions);
+
+ }
+
+ function test2Etags() {
+
+ $serverVars = array(
+ 'HTTP_IF' => '<http://www.example.org/> ([etag1]) ([etag2])',
+ );
+
+ $request = new HTTP\Request($serverVars);
+ $this->server->httpRequest = ($request);
+
+ $conditions = $this->locksPlugin->getIfConditions();
+
+ $compare = array(
+
+ array(
+ 'uri' => 'http://www.example.org/',
+ 'tokens' => array(
+ array(
+ 1,
+ '',
+ 'etag1',
+ ),
+ array(
+ 1,
+ '',
+ 'etag2',
+ ),
+ ),
+ ),
+
+ );
+ $this->assertEquals($compare,$conditions);
+
+ }
+
+ function testComplexIf() {
+
+ $serverVars = array(
+ 'HTTP_IF' => '<http://www.example.org/node1> (<opaquelocktoken:token1> [etag1]) ' .
+ '(Not <opaquelocktoken:token2>) ([etag2]) <http://www.example.org/node2> ' .
+ '(<opaquelocktoken:token3>) (Not <opaquelocktoken:token4>) ([etag3])',
+ );
+
+ $request = new HTTP\Request($serverVars);
+ $this->server->httpRequest = ($request);
+
+ $conditions = $this->locksPlugin->getIfConditions();
+
+ $compare = array(
+
+ array(
+ 'uri' => 'http://www.example.org/node1',
+ 'tokens' => array(
+ array(
+ 1,
+ 'opaquelocktoken:token1',
+ 'etag1',
+ ),
+ array(
+ 0,
+ 'opaquelocktoken:token2',
+ '',
+ ),
+ array(
+ 1,
+ '',
+ 'etag2',
+ ),
+ ),
+ ),
+ array(
+ 'uri' => 'http://www.example.org/node2',
+ 'tokens' => array(
+ array(
+ 1,
+ 'opaquelocktoken:token3',
+ '',
+ ),
+ array(
+ 0,
+ 'opaquelocktoken:token4',
+ '',
+ ),
+ array(
+ 1,
+ '',
+ 'etag3',
+ ),
+ ),
+ ),
+
+ );
+ $this->assertEquals($compare,$conditions);
+
+ }
+
+}
diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Locks/MSWordTest.php b/vendor/sabre/dav/tests/Sabre/DAV/Locks/MSWordTest.php
new file mode 100644
index 000000000..b3d7d447b
--- /dev/null
+++ b/vendor/sabre/dav/tests/Sabre/DAV/Locks/MSWordTest.php
@@ -0,0 +1,123 @@
+<?php
+
+namespace Sabre\DAV\Locks;
+
+use Sabre\HTTP;
+use Sabre\DAV;
+
+require_once 'Sabre/HTTP/ResponseMock.php';
+require_once 'Sabre/TestUtil.php';
+
+class MSWordTest extends \PHPUnit_Framework_TestCase {
+
+ function testLockEtc() {
+
+ mkdir(SABRE_TEMPDIR . '/mstest');
+ $tree = new DAV\FS\Directory(SABRE_TEMPDIR . '/mstest');
+
+ $server = new DAV\Server($tree);
+ $server->debugExceptions = true;
+ $locksBackend = new Backend\File(SABRE_TEMPDIR . '/locksdb');
+ $locksPlugin = new Plugin($locksBackend);
+ $server->addPlugin($locksPlugin);
+
+ $response1 = new HTTP\ResponseMock();
+
+ $server->httpRequest = $this->getLockRequest();
+ $server->httpResponse = $response1;
+ $server->exec();
+
+ $this->assertEquals('HTTP/1.1 201 Created', $server->httpResponse->status);
+ $this->assertTrue(isset($server->httpResponse->headers['Lock-Token']));
+ $lockToken = $server->httpResponse->headers['Lock-Token'];
+
+ //sleep(10);
+
+ $response2 = new HTTP\ResponseMock();
+
+ $server->httpRequest = $this->getLockRequest2();
+ $server->httpResponse = $response2;
+ $server->exec();
+
+ $this->assertEquals('HTTP/1.1 201 Created', $server->httpResponse->status);
+ $this->assertTrue(isset($server->httpResponse->headers['Lock-Token']));
+
+ //sleep(10);
+
+ $response3 = new HTTP\ResponseMock();
+ $server->httpRequest = $this->getPutRequest($lockToken);
+ $server->httpResponse = $response3;
+ $server->exec();
+
+ $this->assertEquals('HTTP/1.1 204 No Content', $server->httpResponse->status);
+
+ }
+
+ function tearDown() {
+
+ \Sabre\TestUtil::clearTempDir();
+
+ }
+
+ function getLockRequest() {
+
+ $request = new HTTP\Request(array(
+ 'REQUEST_METHOD' => 'LOCK',
+ 'HTTP_CONTENT_TYPE' => 'application/xml',
+ 'HTTP_TIMEOUT' => 'Second-3600',
+ 'REQUEST_URI' => '/Nouveau%20Microsoft%20Office%20Excel%20Worksheet.xlsx',
+ ));
+
+ $request->setBody('<D:lockinfo xmlns:D="DAV:">
+ <D:lockscope>
+ <D:exclusive />
+ </D:lockscope>
+ <D:locktype>
+ <D:write />
+ </D:locktype>
+ <D:owner>
+ <D:href>PC-Vista\User</D:href>
+ </D:owner>
+</D:lockinfo>');
+
+ return $request;
+
+ }
+ function getLockRequest2() {
+
+ $request = new HTTP\Request(array(
+ 'REQUEST_METHOD' => 'LOCK',
+ 'HTTP_CONTENT_TYPE' => 'application/xml',
+ 'HTTP_TIMEOUT' => 'Second-3600',
+ 'REQUEST_URI' => '/~$Nouveau%20Microsoft%20Office%20Excel%20Worksheet.xlsx',
+ ));
+
+ $request->setBody('<D:lockinfo xmlns:D="DAV:">
+ <D:lockscope>
+ <D:exclusive />
+ </D:lockscope>
+ <D:locktype>
+ <D:write />
+ </D:locktype>
+ <D:owner>
+ <D:href>PC-Vista\User</D:href>
+ </D:owner>
+</D:lockinfo>');
+
+ return $request;
+
+ }
+
+ function getPutRequest($lockToken) {
+
+ $request = new HTTP\Request(array(
+ 'REQUEST_METHOD' => 'PUT',
+ 'REQUEST_URI' => '/Nouveau%20Microsoft%20Office%20Excel%20Worksheet.xlsx',
+ 'HTTP_IF' => 'If: ('.$lockToken.')',
+ ));
+ $request->setBody('FAKE BODY');
+ return $request;
+
+ }
+
+}
diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Locks/PluginTest.php b/vendor/sabre/dav/tests/Sabre/DAV/Locks/PluginTest.php
new file mode 100644
index 000000000..a45dafdf1
--- /dev/null
+++ b/vendor/sabre/dav/tests/Sabre/DAV/Locks/PluginTest.php
@@ -0,0 +1,966 @@
+<?php
+
+namespace Sabre\DAV\Locks;
+
+use Sabre\HTTP;
+use Sabre\DAV;
+
+require_once 'Sabre/DAV/AbstractServer.php';
+
+class PluginTest extends DAV\AbstractServer {
+
+ /**
+ * @var Sabre\DAV\Locks\Plugin
+ */
+ protected $locksPlugin;
+
+ function setUp() {
+
+ parent::setUp();
+ $locksBackend = new Backend\File(SABRE_TEMPDIR . '/locksdb');
+ $locksPlugin = new Plugin($locksBackend);
+ $this->server->addPlugin($locksPlugin);
+ $this->locksPlugin = $locksPlugin;
+
+ }
+
+ function testGetFeatures() {
+
+ $this->assertEquals(array(2),$this->locksPlugin->getFeatures());
+
+ }
+
+ function testGetHTTPMethods() {
+
+ $this->assertEquals(array('LOCK','UNLOCK'),$this->locksPlugin->getHTTPMethods(''));
+
+ }
+
+ function testGetHTTPMethodsNoBackend() {
+
+ $locksPlugin = new Plugin();
+ $this->server->addPlugin($locksPlugin);
+ $this->assertEquals(array(),$locksPlugin->getHTTPMethods(''));
+
+ }
+
+ function testUnknownMethodPassthough() {
+
+ $this->assertNull($this->locksPlugin->unknownMethod('BLA','/'));
+
+ }
+
+ function testLockNoBody() {
+
+ $serverVars = array(
+ 'REQUEST_URI' => '/test.txt',
+ 'REQUEST_METHOD' => 'LOCK',
+ );
+
+ $request = new HTTP\Request($serverVars);
+ $request->setBody('');
+ $this->server->httpRequest = ($request);
+ $this->server->exec();
+
+ $this->assertEquals(array(
+ 'Content-Type' => 'application/xml; charset=utf-8',
+ ),
+ $this->response->headers
+ );
+
+ $this->assertEquals('HTTP/1.1 400 Bad request',$this->response->status);
+
+ }
+
+ function testLock() {
+
+ $serverVars = array(
+ 'REQUEST_URI' => '/test.txt',
+ 'REQUEST_METHOD' => 'LOCK',
+ );
+
+ $request = new HTTP\Request($serverVars);
+ $request->setBody('<?xml version="1.0"?>
+<D:lockinfo xmlns:D="DAV:">
+ <D:lockscope><D:exclusive/></D:lockscope>
+ <D:locktype><D:write/></D:locktype>
+ <D:owner>
+ <D:href>http://example.org/~ejw/contact.html</D:href>
+ </D:owner>
+</D:lockinfo>');
+
+ $this->server->httpRequest = $request;
+ $this->server->exec();
+
+ $this->assertEquals('application/xml; charset=utf-8',$this->response->headers['Content-Type']);
+ $this->assertTrue(preg_match('/^<opaquelocktoken:(.*)>$/',$this->response->headers['Lock-Token'])===1,'We did not get a valid Locktoken back (' . $this->response->headers['Lock-Token'] . ')');
+
+ $this->assertEquals('HTTP/1.1 200 OK',$this->response->status,'Got an incorrect status back. Response body: ' . $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');
+
+ $elements = array(
+ '/d:prop',
+ '/d:prop/d:lockdiscovery',
+ '/d:prop/d:lockdiscovery/d:activelock',
+ '/d:prop/d:lockdiscovery/d:activelock/d:locktype',
+ '/d:prop/d:lockdiscovery/d:activelock/d:lockroot',
+ '/d:prop/d:lockdiscovery/d:activelock/d:lockroot/d:href',
+ '/d:prop/d:lockdiscovery/d:activelock/d:locktype/d:write',
+ '/d:prop/d:lockdiscovery/d:activelock/d:lockscope',
+ '/d:prop/d:lockdiscovery/d:activelock/d:lockscope/d:exclusive',
+ '/d:prop/d:lockdiscovery/d:activelock/d:depth',
+ '/d:prop/d:lockdiscovery/d:activelock/d:owner',
+ '/d:prop/d:lockdiscovery/d:activelock/d:timeout',
+ '/d:prop/d:lockdiscovery/d:activelock/d:locktoken',
+ '/d:prop/d:lockdiscovery/d:activelock/d:locktoken/d:href',
+ );
+
+ foreach($elements as $elem) {
+ $data = $xml->xpath($elem);
+ $this->assertEquals(1,count($data),'We expected 1 match for the xpath expression "' . $elem . '". ' . count($data) . ' were found. Full response body: ' . $this->response->body);
+ }
+
+ $depth = $xml->xpath('/d:prop/d:lockdiscovery/d:activelock/d:depth');
+ $this->assertEquals('infinity',(string)$depth[0]);
+
+ $token = $xml->xpath('/d:prop/d:lockdiscovery/d:activelock/d:locktoken/d:href');
+ $this->assertEquals($this->response->headers['Lock-Token'],'<' . (string)$token[0] . '>','Token in response body didn\'t match token in response header.');
+
+ }
+
+ /**
+ * @depends testLock
+ */
+ function testDoubleLock() {
+
+ $serverVars = array(
+ 'REQUEST_URI' => '/test.txt',
+ 'REQUEST_METHOD' => 'LOCK',
+ );
+
+ $request = new HTTP\Request($serverVars);
+ $request->setBody('<?xml version="1.0"?>
+<D:lockinfo xmlns:D="DAV:">
+ <D:lockscope><D:exclusive/></D:lockscope>
+ <D:locktype><D:write/></D:locktype>
+ <D:owner>
+ <D:href>http://example.org/~ejw/contact.html</D:href>
+ </D:owner>
+</D:lockinfo>');
+
+ $this->server->httpRequest = $request;
+ $this->server->exec();
+
+ $this->response = new HTTP\ResponseMock();
+ $this->server->httpResponse = $this->response;
+
+ $this->server->exec();
+
+ $this->assertEquals('application/xml; charset=utf-8',$this->response->headers['Content-Type']);
+
+ $this->assertEquals('HTTP/1.1 423 Locked',$this->response->status);
+
+ }
+
+ /**
+ * @depends testLock
+ */
+ function testLockRefresh() {
+
+ $serverVars = array(
+ 'REQUEST_URI' => '/test.txt',
+ 'REQUEST_METHOD' => 'LOCK',
+ );
+
+ $request = new HTTP\Request($serverVars);
+ $request->setBody('<?xml version="1.0"?>
+<D:lockinfo xmlns:D="DAV:">
+ <D:lockscope><D:exclusive/></D:lockscope>
+ <D:locktype><D:write/></D:locktype>
+ <D:owner>
+ <D:href>http://example.org/~ejw/contact.html</D:href>
+ </D:owner>
+</D:lockinfo>');
+
+ $this->server->httpRequest = $request;
+ $this->server->exec();
+
+ $lockToken = $this->response->headers['Lock-Token'];
+
+ $this->response = new HTTP\ResponseMock();
+ $this->server->httpResponse = $this->response;
+
+ $serverVars = array(
+ 'REQUEST_URI' => '/test.txt',
+ 'REQUEST_METHOD' => 'LOCK',
+ 'HTTP_IF' => '(' . $lockToken . ')',
+ );
+ $request = new HTTP\Request($serverVars);
+ $request->setBody('');
+ $this->server->httpRequest = $request;
+
+ $this->server->exec();
+
+ $this->assertEquals('application/xml; charset=utf-8',$this->response->headers['Content-Type']);
+
+ $this->assertEquals('HTTP/1.1 200 OK',$this->response->status,'We received an incorrect status code. Full response body: ' . $this->response->body);
+
+ }
+
+ /**
+ * @depends testLock
+ */
+ function testLockNoFile() {
+
+ $serverVars = array(
+ 'REQUEST_URI' => '/notfound.txt',
+ 'REQUEST_METHOD' => 'LOCK',
+ );
+
+ $request = new HTTP\Request($serverVars);
+ $request->setBody('<?xml version="1.0"?>
+<D:lockinfo xmlns:D="DAV:">
+ <D:lockscope><D:exclusive/></D:lockscope>
+ <D:locktype><D:write/></D:locktype>
+ <D:owner>
+ <D:href>http://example.org/~ejw/contact.html</D:href>
+ </D:owner>
+</D:lockinfo>');
+
+ $this->server->httpRequest = $request;
+ $this->server->exec();
+
+ $this->assertEquals('application/xml; charset=utf-8',$this->response->headers['Content-Type']);
+ $this->assertTrue(preg_match('/^<opaquelocktoken:(.*)>$/',$this->response->headers['Lock-Token'])===1,'We did not get a valid Locktoken back (' . $this->response->headers['Lock-Token'] . ')');
+
+ $this->assertEquals('HTTP/1.1 201 Created',$this->response->status);
+
+ }
+
+ /**
+ * @depends testLock
+ */
+ function testUnlockNoToken() {
+
+ $serverVars = array(
+ 'REQUEST_URI' => '/test.txt',
+ 'REQUEST_METHOD' => 'UNLOCK',
+ );
+
+ $request = new HTTP\Request($serverVars);
+ $this->server->httpRequest = ($request);
+ $this->server->exec();
+
+ $this->assertEquals(array(
+ 'Content-Type' => 'application/xml; charset=utf-8',
+ ),
+ $this->response->headers
+ );
+
+ $this->assertEquals('HTTP/1.1 400 Bad request',$this->response->status);
+
+ }
+
+ /**
+ * @depends testLock
+ */
+ function testUnlockBadToken() {
+
+ $serverVars = array(
+ 'REQUEST_URI' => '/test.txt',
+ 'REQUEST_METHOD' => 'UNLOCK',
+ 'HTTP_LOCK_TOKEN' => '<opaquelocktoken:blablabla>',
+ );
+
+ $request = new HTTP\Request($serverVars);
+ $this->server->httpRequest = ($request);
+ $this->server->exec();
+
+ $this->assertEquals(array(
+ 'Content-Type' => 'application/xml; charset=utf-8',
+ ),
+ $this->response->headers
+ );
+
+ $this->assertEquals('HTTP/1.1 409 Conflict',$this->response->status,'Got an incorrect status code. Full response body: ' . $this->response->body);
+
+ }
+
+ /**
+ * @depends testLock
+ */
+ function testLockPutNoToken() {
+
+ $serverVars = array(
+ 'REQUEST_URI' => '/test.txt',
+ 'REQUEST_METHOD' => 'LOCK',
+ );
+
+ $request = new HTTP\Request($serverVars);
+ $request->setBody('<?xml version="1.0"?>
+<D:lockinfo xmlns:D="DAV:">
+ <D:lockscope><D:exclusive/></D:lockscope>
+ <D:locktype><D:write/></D:locktype>
+ <D:owner>
+ <D:href>http://example.org/~ejw/contact.html</D:href>
+ </D:owner>
+</D:lockinfo>');
+
+ $this->server->httpRequest = $request;
+ $this->server->exec();
+
+ $this->assertEquals('application/xml; charset=utf-8',$this->response->headers['Content-Type']);
+ $this->assertTrue(preg_match('/^<opaquelocktoken:(.*)>$/',$this->response->headers['Lock-Token'])===1,'We did not get a valid Locktoken back (' . $this->response->headers['Lock-Token'] . ')');
+
+ $this->assertEquals('HTTP/1.1 200 OK',$this->response->status);
+
+ $serverVars = array(
+ 'REQUEST_URI' => '/test.txt',
+ 'REQUEST_METHOD' => 'PUT',
+ );
+
+ $request = new HTTP\Request($serverVars);
+ $request->setBody('newbody');
+ $this->server->httpRequest = $request;
+ $this->server->exec();
+
+ $this->assertEquals('application/xml; charset=utf-8',$this->response->headers['Content-Type']);
+ $this->assertTrue(preg_match('/^<opaquelocktoken:(.*)>$/',$this->response->headers['Lock-Token'])===1,'We did not get a valid Locktoken back (' . $this->response->headers['Lock-Token'] . ')');
+
+ $this->assertEquals('HTTP/1.1 423 Locked',$this->response->status);
+
+ }
+
+ /**
+ * @depends testLock
+ */
+ function testUnlock() {
+
+ $request = new HTTP\Request(array());
+ $this->server->httpRequest = $request;
+
+ $request->setBody('<?xml version="1.0"?>
+<D:lockinfo xmlns:D="DAV:">
+ <D:lockscope><D:exclusive/></D:lockscope>
+ <D:locktype><D:write/></D:locktype>
+ <D:owner>
+ <D:href>http://example.org/~ejw/contact.html</D:href>
+ </D:owner>
+</D:lockinfo>');
+
+ $this->server->invokeMethod('LOCK','test.txt');
+ $lockToken = $this->server->httpResponse->headers['Lock-Token'];
+
+ $serverVars = array(
+ 'HTTP_LOCK_TOKEN' => $lockToken,
+ );
+
+ $request = new HTTP\Request($serverVars);
+ $this->server->httpRequest = ($request);
+ $this->server->httpResponse = new HTTP\ResponseMock();
+ $this->server->invokeMethod('UNLOCK', 'test.txt');
+
+ $this->assertEquals('HTTP/1.1 204 No Content',$this->server->httpResponse->status,'Got an incorrect status code. Full response body: ' . $this->response->body);
+ $this->assertEquals(array(
+ 'Content-Length' => '0',
+ ),
+ $this->server->httpResponse->headers
+ );
+
+
+ }
+
+ /**
+ * @depends testLock
+ */
+ function testUnlockWindowsBug() {
+
+ $request = new HTTP\Request(array());
+ $this->server->httpRequest = $request;
+
+ $request->setBody('<?xml version="1.0"?>
+<D:lockinfo xmlns:D="DAV:">
+ <D:lockscope><D:exclusive/></D:lockscope>
+ <D:locktype><D:write/></D:locktype>
+ <D:owner>
+ <D:href>http://example.org/~ejw/contact.html</D:href>
+ </D:owner>
+</D:lockinfo>');
+
+ $this->server->invokeMethod('LOCK','test.txt');
+ $lockToken = $this->server->httpResponse->headers['Lock-Token'];
+
+ // See Issue 123
+ $lockToken = trim($lockToken,'<>');
+
+ $serverVars = array(
+ 'HTTP_LOCK_TOKEN' => $lockToken,
+ );
+
+ $request = new HTTP\Request($serverVars);
+ $this->server->httpRequest = ($request);
+ $this->server->httpResponse = new HTTP\ResponseMock();
+ $this->server->invokeMethod('UNLOCK', 'test.txt');
+
+ $this->assertEquals('HTTP/1.1 204 No Content',$this->server->httpResponse->status,'Got an incorrect status code. Full response body: ' . $this->response->body);
+ $this->assertEquals(array(
+ 'Content-Length' => '0',
+ ),
+ $this->server->httpResponse->headers
+ );
+
+
+ }
+
+ /**
+ * @depends testLock
+ */
+ function testLockRetainOwner() {
+
+ $request = new HTTP\Request(array());
+ $this->server->httpRequest = $request;
+
+ $request->setBody('<?xml version="1.0"?>
+<D:lockinfo xmlns:D="DAV:">
+ <D:lockscope><D:exclusive/></D:lockscope>
+ <D:locktype><D:write/></D:locktype>
+ <D:owner>Evert</D:owner>
+</D:lockinfo>');
+
+ $this->server->invokeMethod('LOCK','test.txt');
+ $lockToken = $this->server->httpResponse->headers['Lock-Token'];
+
+ $locks = $this->locksPlugin->getLocks('test.txt');
+ $this->assertEquals(1,count($locks));
+ $this->assertEquals('Evert',$locks[0]->owner);
+
+
+ }
+
+ /**
+ * @depends testLock
+ */
+ function testLockPutBadToken() {
+
+ $serverVars = array(
+ 'REQUEST_URI' => '/test.txt',
+ 'REQUEST_METHOD' => 'LOCK',
+ );
+
+ $request = new HTTP\Request($serverVars);
+ $request->setBody('<?xml version="1.0"?>
+<D:lockinfo xmlns:D="DAV:">
+ <D:lockscope><D:exclusive/></D:lockscope>
+ <D:locktype><D:write/></D:locktype>
+ <D:owner>
+ <D:href>http://example.org/~ejw/contact.html</D:href>
+ </D:owner>
+</D:lockinfo>');
+
+ $this->server->httpRequest = $request;
+ $this->server->exec();
+
+ $this->assertEquals('application/xml; charset=utf-8',$this->response->headers['Content-Type']);
+ $this->assertTrue(preg_match('/^<opaquelocktoken:(.*)>$/',$this->response->headers['Lock-Token'])===1,'We did not get a valid Locktoken back (' . $this->response->headers['Lock-Token'] . ')');
+
+ $this->assertEquals('HTTP/1.1 200 OK',$this->response->status);
+
+ $serverVars = array(
+ 'REQUEST_URI' => '/test.txt',
+ 'REQUEST_METHOD' => 'PUT',
+ 'HTTP_IF' => '(<opaquelocktoken:token1>)',
+ );
+
+ $request = new HTTP\Request($serverVars);
+ $request->setBody('newbody');
+ $this->server->httpRequest = $request;
+ $this->server->exec();
+
+ $this->assertEquals('application/xml; charset=utf-8',$this->response->headers['Content-Type']);
+ $this->assertTrue(preg_match('/^<opaquelocktoken:(.*)>$/',$this->response->headers['Lock-Token'])===1,'We did not get a valid Locktoken back (' . $this->response->headers['Lock-Token'] . ')');
+
+ $this->assertEquals('HTTP/1.1 412 Precondition failed',$this->response->status);
+
+ }
+
+ /**
+ * @depends testLock
+ */
+ function testLockDeleteParent() {
+
+ $serverVars = array(
+ 'REQUEST_URI' => '/dir/child.txt',
+ 'REQUEST_METHOD' => 'LOCK',
+ );
+
+ $request = new HTTP\Request($serverVars);
+ $request->setBody('<?xml version="1.0"?>
+<D:lockinfo xmlns:D="DAV:">
+ <D:lockscope><D:exclusive/></D:lockscope>
+ <D:locktype><D:write/></D:locktype>
+ <D:owner>
+ <D:href>http://example.org/~ejw/contact.html</D:href>
+ </D:owner>
+</D:lockinfo>');
+
+ $this->server->httpRequest = $request;
+ $this->server->exec();
+
+ $this->assertEquals('application/xml; charset=utf-8',$this->response->headers['Content-Type']);
+ $this->assertTrue(preg_match('/^<opaquelocktoken:(.*)>$/',$this->response->headers['Lock-Token'])===1,'We did not get a valid Locktoken back (' . $this->response->headers['Lock-Token'] . ')');
+
+ $this->assertEquals('HTTP/1.1 200 OK',$this->response->status);
+
+ $serverVars = array(
+ 'REQUEST_URI' => '/dir',
+ 'REQUEST_METHOD' => 'DELETE',
+ );
+
+ $request = new HTTP\Request($serverVars);
+ $this->server->httpRequest = $request;
+ $this->server->exec();
+
+ $this->assertEquals('HTTP/1.1 423 Locked',$this->response->status);
+ $this->assertEquals('application/xml; charset=utf-8',$this->response->headers['Content-Type']);
+
+ }
+ /**
+ * @depends testLock
+ */
+ function testLockDeleteSucceed() {
+
+ $serverVars = array(
+ 'REQUEST_URI' => '/dir/child.txt',
+ 'REQUEST_METHOD' => 'LOCK',
+ );
+
+ $request = new HTTP\Request($serverVars);
+ $request->setBody('<?xml version="1.0"?>
+<D:lockinfo xmlns:D="DAV:">
+ <D:lockscope><D:exclusive/></D:lockscope>
+ <D:locktype><D:write/></D:locktype>
+ <D:owner>
+ <D:href>http://example.org/~ejw/contact.html</D:href>
+ </D:owner>
+</D:lockinfo>');
+
+ $this->server->httpRequest = $request;
+ $this->server->exec();
+
+ $this->assertEquals('application/xml; charset=utf-8',$this->response->headers['Content-Type']);
+ $this->assertTrue(preg_match('/^<opaquelocktoken:(.*)>$/',$this->response->headers['Lock-Token'])===1,'We did not get a valid Locktoken back (' . $this->response->headers['Lock-Token'] . ')');
+
+ $this->assertEquals('HTTP/1.1 200 OK',$this->response->status);
+
+ $serverVars = array(
+ 'REQUEST_URI' => '/dir/child.txt',
+ 'REQUEST_METHOD' => 'DELETE',
+ 'HTTP_IF' => '(' . $this->response->headers['Lock-Token'] . ')',
+ );
+
+ $request = new HTTP\Request($serverVars);
+ $this->server->httpRequest = $request;
+ $this->server->exec();
+
+ $this->assertEquals('HTTP/1.1 204 No Content',$this->response->status);
+ $this->assertEquals('application/xml; charset=utf-8',$this->response->headers['Content-Type']);
+
+ }
+
+ /**
+ * @depends testLock
+ */
+ function testLockCopyLockSource() {
+
+ $serverVars = array(
+ 'REQUEST_URI' => '/dir/child.txt',
+ 'REQUEST_METHOD' => 'LOCK',
+ );
+
+ $request = new HTTP\Request($serverVars);
+ $request->setBody('<?xml version="1.0"?>
+<D:lockinfo xmlns:D="DAV:">
+ <D:lockscope><D:exclusive/></D:lockscope>
+ <D:locktype><D:write/></D:locktype>
+ <D:owner>
+ <D:href>http://example.org/~ejw/contact.html</D:href>
+ </D:owner>
+</D:lockinfo>');
+
+ $this->server->httpRequest = $request;
+ $this->server->exec();
+
+ $this->assertEquals('application/xml; charset=utf-8',$this->response->headers['Content-Type']);
+ $this->assertTrue(preg_match('/^<opaquelocktoken:(.*)>$/',$this->response->headers['Lock-Token'])===1,'We did not get a valid Locktoken back (' . $this->response->headers['Lock-Token'] . ')');
+
+ $this->assertEquals('HTTP/1.1 200 OK',$this->response->status);
+
+ $serverVars = array(
+ 'REQUEST_URI' => '/dir/child.txt',
+ 'REQUEST_METHOD' => 'COPY',
+ 'HTTP_DESTINATION' => '/dir/child2.txt',
+ );
+
+ $request = new HTTP\Request($serverVars);
+ $this->server->httpRequest = $request;
+ $this->server->exec();
+
+ $this->assertEquals('HTTP/1.1 201 Created',$this->response->status,'Copy must succeed if only the source is locked, but not the destination');
+ $this->assertEquals('application/xml; charset=utf-8',$this->response->headers['Content-Type']);
+
+ }
+ /**
+ * @depends testLock
+ */
+ function testLockCopyLockDestination() {
+
+ $serverVars = array(
+ 'REQUEST_URI' => '/dir/child2.txt',
+ 'REQUEST_METHOD' => 'LOCK',
+ );
+
+ $request = new HTTP\Request($serverVars);
+ $request->setBody('<?xml version="1.0"?>
+<D:lockinfo xmlns:D="DAV:">
+ <D:lockscope><D:exclusive/></D:lockscope>
+ <D:locktype><D:write/></D:locktype>
+ <D:owner>
+ <D:href>http://example.org/~ejw/contact.html</D:href>
+ </D:owner>
+</D:lockinfo>');
+
+ $this->server->httpRequest = $request;
+ $this->server->exec();
+
+ $this->assertEquals('application/xml; charset=utf-8',$this->response->headers['Content-Type']);
+ $this->assertTrue(preg_match('/^<opaquelocktoken:(.*)>$/',$this->response->headers['Lock-Token'])===1,'We did not get a valid Locktoken back (' . $this->response->headers['Lock-Token'] . ')');
+
+ $this->assertEquals('HTTP/1.1 201 Created',$this->response->status);
+
+ $serverVars = array(
+ 'REQUEST_URI' => '/dir/child.txt',
+ 'REQUEST_METHOD' => 'COPY',
+ 'HTTP_DESTINATION' => '/dir/child2.txt',
+ );
+
+ $request = new HTTP\Request($serverVars);
+ $this->server->httpRequest = $request;
+ $this->server->exec();
+
+ $this->assertEquals('HTTP/1.1 423 Locked',$this->response->status,'Copy must succeed if only the source is locked, but not the destination');
+ $this->assertEquals('application/xml; charset=utf-8',$this->response->headers['Content-Type']);
+
+ }
+
+ /**
+ * @depends testLock
+ */
+ function testLockMoveLockSourceLocked() {
+
+ $serverVars = array(
+ 'REQUEST_URI' => '/dir/child.txt',
+ 'REQUEST_METHOD' => 'LOCK',
+ );
+
+ $request = new HTTP\Request($serverVars);
+ $request->setBody('<?xml version="1.0"?>
+<D:lockinfo xmlns:D="DAV:">
+ <D:lockscope><D:exclusive/></D:lockscope>
+ <D:locktype><D:write/></D:locktype>
+ <D:owner>
+ <D:href>http://example.org/~ejw/contact.html</D:href>
+ </D:owner>
+</D:lockinfo>');
+
+ $this->server->httpRequest = $request;
+ $this->server->exec();
+
+ $this->assertEquals('application/xml; charset=utf-8',$this->response->headers['Content-Type']);
+ $this->assertTrue(preg_match('/^<opaquelocktoken:(.*)>$/',$this->response->headers['Lock-Token'])===1,'We did not get a valid Locktoken back (' . $this->response->headers['Lock-Token'] . ')');
+
+ $this->assertEquals('HTTP/1.1 200 OK',$this->response->status);
+
+ $serverVars = array(
+ 'REQUEST_URI' => '/dir/child.txt',
+ 'REQUEST_METHOD' => 'MOVE',
+ 'HTTP_DESTINATION' => '/dir/child2.txt',
+ );
+
+ $request = new HTTP\Request($serverVars);
+ $this->server->httpRequest = $request;
+ $this->server->exec();
+
+ $this->assertEquals('HTTP/1.1 423 Locked',$this->response->status,'Copy must succeed if only the source is locked, but not the destination');
+ $this->assertEquals('application/xml; charset=utf-8',$this->response->headers['Content-Type']);
+
+ }
+
+ /**
+ * @depends testLock
+ */
+ function testLockMoveLockSourceSucceed() {
+
+ $serverVars = array(
+ 'REQUEST_URI' => '/dir/child.txt',
+ 'REQUEST_METHOD' => 'LOCK',
+ );
+
+ $request = new HTTP\Request($serverVars);
+ $request->setBody('<?xml version="1.0"?>
+<D:lockinfo xmlns:D="DAV:">
+ <D:lockscope><D:exclusive/></D:lockscope>
+ <D:locktype><D:write/></D:locktype>
+ <D:owner>
+ <D:href>http://example.org/~ejw/contact.html</D:href>
+ </D:owner>
+</D:lockinfo>');
+
+ $this->server->httpRequest = $request;
+ $this->server->exec();
+
+ $this->assertEquals('application/xml; charset=utf-8',$this->response->headers['Content-Type']);
+ $this->assertTrue(preg_match('/^<opaquelocktoken:(.*)>$/',$this->response->headers['Lock-Token'])===1,'We did not get a valid Locktoken back (' . $this->response->headers['Lock-Token'] . ')');
+
+ $this->assertEquals('HTTP/1.1 200 OK',$this->response->status);
+
+ $serverVars = array(
+ 'REQUEST_URI' => '/dir/child.txt',
+ 'REQUEST_METHOD' => 'MOVE',
+ 'HTTP_DESTINATION' => '/dir/child2.txt',
+ 'HTTP_IF' => '(' . $this->response->headers['Lock-Token'] . ')',
+ );
+
+ $request = new HTTP\Request($serverVars);
+ $this->server->httpRequest = $request;
+ $this->server->exec();
+
+ $this->assertEquals('HTTP/1.1 201 Created',$this->response->status,'A valid lock-token was provided for the source, so this MOVE operation must succeed. Full response body: ' . $this->response->body);
+
+ }
+
+ /**
+ * @depends testLock
+ */
+ function testLockMoveLockDestination() {
+
+ $serverVars = array(
+ 'REQUEST_URI' => '/dir/child2.txt',
+ 'REQUEST_METHOD' => 'LOCK',
+ );
+
+ $request = new HTTP\Request($serverVars);
+ $request->setBody('<?xml version="1.0"?>
+<D:lockinfo xmlns:D="DAV:">
+ <D:lockscope><D:exclusive/></D:lockscope>
+ <D:locktype><D:write/></D:locktype>
+ <D:owner>
+ <D:href>http://example.org/~ejw/contact.html</D:href>
+ </D:owner>
+</D:lockinfo>');
+
+ $this->server->httpRequest = $request;
+ $this->server->exec();
+
+ $this->assertEquals('application/xml; charset=utf-8',$this->response->headers['Content-Type']);
+ $this->assertTrue(preg_match('/^<opaquelocktoken:(.*)>$/',$this->response->headers['Lock-Token'])===1,'We did not get a valid Locktoken back (' . $this->response->headers['Lock-Token'] . ')');
+
+ $this->assertEquals('HTTP/1.1 201 Created',$this->response->status);
+
+ $serverVars = array(
+ 'REQUEST_URI' => '/dir/child.txt',
+ 'REQUEST_METHOD' => 'MOVE',
+ 'HTTP_DESTINATION' => '/dir/child2.txt',
+ );
+
+ $request = new HTTP\Request($serverVars);
+ $this->server->httpRequest = $request;
+ $this->server->exec();
+
+ $this->assertEquals('HTTP/1.1 423 Locked',$this->response->status,'Copy must succeed if only the source is locked, but not the destination');
+ $this->assertEquals('application/xml; charset=utf-8',$this->response->headers['Content-Type']);
+
+ }
+ /**
+ * @depends testLock
+ */
+ function testLockMoveLockParent() {
+
+ $serverVars = array(
+ 'REQUEST_URI' => '/dir',
+ 'REQUEST_METHOD' => 'LOCK',
+ 'HTTP_DEPTH' => 'infinite',
+ );
+
+ $request = new HTTP\Request($serverVars);
+ $request->setBody('<?xml version="1.0"?>
+<D:lockinfo xmlns:D="DAV:">
+ <D:lockscope><D:exclusive/></D:lockscope>
+ <D:locktype><D:write/></D:locktype>
+ <D:owner>
+ <D:href>http://example.org/~ejw/contact.html</D:href>
+ </D:owner>
+</D:lockinfo>');
+
+ $this->server->httpRequest = $request;
+ $this->server->exec();
+
+ $this->assertEquals('application/xml; charset=utf-8',$this->response->headers['Content-Type']);
+ $this->assertTrue(preg_match('/^<opaquelocktoken:(.*)>$/',$this->response->headers['Lock-Token'])===1,'We did not get a valid Locktoken back (' . $this->response->headers['Lock-Token'] . ')');
+
+ $this->assertEquals('HTTP/1.1 200 OK',$this->response->status);
+
+ $serverVars = array(
+ 'REQUEST_URI' => '/dir/child.txt',
+ 'REQUEST_METHOD' => 'MOVE',
+ 'HTTP_DESTINATION' => '/dir/child2.txt',
+ 'HTTP_IF' => '</dir> (' . $this->response->headers['Lock-Token'] . ')',
+ );
+
+ $request = new HTTP\Request($serverVars);
+ $this->server->httpRequest = $request;
+ $this->server->exec();
+
+ $this->assertEquals('HTTP/1.1 201 Created',$this->response->status,'We locked the parent of both the source and destination, but the move didn\'t succeed.');
+ $this->assertEquals('application/xml; charset=utf-8',$this->response->headers['Content-Type']);
+
+ }
+
+ /**
+ * @depends testLock
+ */
+ function testLockPutGoodToken() {
+
+ $serverVars = array(
+ 'REQUEST_URI' => '/test.txt',
+ 'REQUEST_METHOD' => 'LOCK',
+ );
+
+ $request = new HTTP\Request($serverVars);
+ $request->setBody('<?xml version="1.0"?>
+<D:lockinfo xmlns:D="DAV:">
+ <D:lockscope><D:exclusive/></D:lockscope>
+ <D:locktype><D:write/></D:locktype>
+ <D:owner>
+ <D:href>http://example.org/~ejw/contact.html</D:href>
+ </D:owner>
+</D:lockinfo>');
+
+ $this->server->httpRequest = $request;
+ $this->server->exec();
+
+ $this->assertEquals('application/xml; charset=utf-8',$this->response->headers['Content-Type']);
+ $this->assertTrue(preg_match('/^<opaquelocktoken:(.*)>$/',$this->response->headers['Lock-Token'])===1,'We did not get a valid Locktoken back (' . $this->response->headers['Lock-Token'] . ')');
+
+ $this->assertEquals('HTTP/1.1 200 OK',$this->response->status);
+
+ $serverVars = array(
+ 'REQUEST_URI' => '/test.txt',
+ 'REQUEST_METHOD' => 'PUT',
+ 'HTTP_IF' => '('.$this->response->headers['Lock-Token'].')',
+ );
+
+ $request = new HTTP\Request($serverVars);
+ $request->setBody('newbody');
+ $this->server->httpRequest = $request;
+ $this->server->exec();
+
+ $this->assertEquals('application/xml; charset=utf-8',$this->response->headers['Content-Type']);
+ $this->assertTrue(preg_match('/^<opaquelocktoken:(.*)>$/',$this->response->headers['Lock-Token'])===1,'We did not get a valid Locktoken back (' . $this->response->headers['Lock-Token'] . ')');
+
+ $this->assertEquals('HTTP/1.1 204 No Content',$this->response->status);
+
+ }
+
+ function testPutWithIncorrectETag() {
+
+ $serverVars = array(
+ 'REQUEST_URI' => '/test.txt',
+ 'REQUEST_METHOD' => 'PUT',
+ 'HTTP_IF' => '(["etag1"])',
+ );
+
+ $request = new HTTP\Request($serverVars);
+ $request->setBody('newbody');
+ $this->server->httpRequest = $request;
+ $this->server->exec();
+ $this->assertEquals('HTTP/1.1 412 Precondition failed',$this->response->status);
+
+ }
+
+ /**
+ * @depends testPutWithIncorrectETag
+ */
+ function testPutWithCorrectETag() {
+
+ // We need an etag-enabled file node.
+ $tree = new DAV\ObjectTree(new DAV\FSExt\Directory(SABRE_TEMPDIR));
+ $this->server->tree = $tree;
+
+ $etag = md5(file_get_contents(SABRE_TEMPDIR . '/test.txt'));
+ $serverVars = array(
+ 'REQUEST_URI' => '/test.txt',
+ 'REQUEST_METHOD' => 'PUT',
+ 'HTTP_IF' => '(["'.$etag.'"])',
+ );
+
+ $request = new HTTP\Request($serverVars);
+ $request->setBody('newbody');
+ $this->server->httpRequest = $request;
+ $this->server->exec();
+ $this->assertEquals('HTTP/1.1 204 No Content',$this->response->status, 'Incorrect status received. Full response body:' . $this->response->body);
+
+ }
+
+ function testGetTimeoutHeader() {
+
+ $request = new HTTP\Request(array(
+ 'HTTP_TIMEOUT' => 'second-100',
+ ));
+
+ $this->server->httpRequest = $request;
+ $this->assertEquals(100, $this->locksPlugin->getTimeoutHeader());
+
+ }
+
+
+ function testGetTimeoutHeaderNotSet() {
+
+ $request = new HTTP\Request(array(
+ ));
+
+ $this->server->httpRequest = $request;
+ $this->assertEquals(0, $this->locksPlugin->getTimeoutHeader());
+
+ }
+
+
+ function testGetTimeoutHeaderInfinite() {
+
+ $request = new HTTP\Request(array(
+ 'HTTP_TIMEOUT' => 'infinite',
+ ));
+
+ $this->server->httpRequest = $request;
+ $this->assertEquals(LockInfo::TIMEOUT_INFINITE, $this->locksPlugin->getTimeoutHeader());
+
+ }
+
+ /**
+ * @expectedException Sabre\DAV\Exception\BadRequest
+ */
+ function testGetTimeoutHeaderInvalid() {
+
+ $request = new HTTP\Request(array(
+ 'HTTP_TIMEOUT' => 'yourmom',
+ ));
+
+ $this->server->httpRequest = $request;
+ $this->locksPlugin->getTimeoutHeader();
+
+ }
+
+
+}
diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Mount/PluginTest.php b/vendor/sabre/dav/tests/Sabre/DAV/Mount/PluginTest.php
new file mode 100644
index 000000000..e818fe043
--- /dev/null
+++ b/vendor/sabre/dav/tests/Sabre/DAV/Mount/PluginTest.php
@@ -0,0 +1,58 @@
+<?php
+
+namespace Sabre\DAV\Mount;
+
+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 testPassThrough() {
+
+ $serverVars = array(
+ 'REQUEST_URI' => '/',
+ 'REQUEST_METHOD' => 'GET',
+ );
+
+ $request = new HTTP\Request($serverVars);
+ $this->server->httpRequest = ($request);
+ $this->server->exec();
+
+ $this->assertEquals('HTTP/1.1 501 Not Implemented',$this->response->status,'We expected GET to not be implemented for Directories. Response body: ' . $this->response->body);
+
+ }
+
+ function testMountResponse() {
+
+ $serverVars = array(
+ 'REQUEST_URI' => '/?mount',
+ 'REQUEST_METHOD' => 'GET',
+ 'QUERY_STRING' => 'mount',
+ 'HTTP_HOST' => 'example.org',
+ );
+
+ $request = new HTTP\Request($serverVars);
+ $this->server->httpRequest = ($request);
+ $this->server->exec();
+
+ $this->assertEquals('HTTP/1.1 200 OK',$this->response->status);
+
+ $xml = simplexml_load_string($this->response->body);
+ $this->assertTrue($xml==true,'Response was not a valid xml document');
+
+ $xml->registerXPathNamespace('dm','http://purl.org/NET/webdav/mount');
+ $url = $xml->xpath('//dm:url');
+ $this->assertEquals('http://example.org/',(string)$url[0]);
+
+ }
+
+}
diff --git a/vendor/sabre/dav/tests/Sabre/DAV/ObjectTreeTest.php b/vendor/sabre/dav/tests/Sabre/DAV/ObjectTreeTest.php
new file mode 100644
index 000000000..330058b6d
--- /dev/null
+++ b/vendor/sabre/dav/tests/Sabre/DAV/ObjectTreeTest.php
@@ -0,0 +1,100 @@
+<?php
+
+namespace Sabre\DAV;
+
+require_once 'Sabre/TestUtil.php';
+
+class ObjectTreeTest extends \PHPUnit_Framework_TestCase {
+
+ protected $tree;
+
+ function setup() {
+
+ \Sabre\TestUtil::clearTempDir();
+ mkdir(SABRE_TEMPDIR . '/root');
+ mkdir(SABRE_TEMPDIR . '/root/subdir');
+ file_put_contents(SABRE_TEMPDIR . '/root/file.txt','contents');
+ file_put_contents(SABRE_TEMPDIR . '/root/subdir/subfile.txt','subcontents');
+ $rootNode = new FSExt\Directory(SABRE_TEMPDIR . '/root');
+ $this->tree = new ObjectTree($rootNode);
+
+ }
+
+ function teardown() {
+
+ \Sabre\TestUtil::clearTempDir();
+
+ }
+
+ function testGetRootNode() {
+
+ $root = $this->tree->getNodeForPath('');
+ $this->assertInstanceOf('Sabre\\DAV\\FSExt\\Directory',$root);
+
+ }
+
+ function testGetSubDir() {
+
+ $root = $this->tree->getNodeForPath('subdir');
+ $this->assertInstanceOf('Sabre\\DAV\\FSExt\\Directory',$root);
+
+ }
+
+ function testCopyFile() {
+
+ $this->tree->copy('file.txt','file2.txt');
+ $this->assertTrue(file_exists(SABRE_TEMPDIR.'/root/file2.txt'));
+ $this->assertEquals('contents',file_get_contents(SABRE_TEMPDIR.'/root/file2.txt'));
+
+ }
+
+ /**
+ * @depends testCopyFile
+ */
+ function testCopyDirectory() {
+
+ $this->tree->copy('subdir','subdir2');
+ $this->assertTrue(file_exists(SABRE_TEMPDIR.'/root/subdir2'));
+ $this->assertTrue(file_exists(SABRE_TEMPDIR.'/root/subdir2/subfile.txt'));
+ $this->assertEquals('subcontents',file_get_contents(SABRE_TEMPDIR.'/root/subdir2/subfile.txt'));
+
+ }
+
+ /**
+ * @depends testCopyFile
+ */
+ function testMoveFile() {
+
+ $this->tree->move('file.txt','file2.txt');
+ $this->assertTrue(file_exists(SABRE_TEMPDIR.'/root/file2.txt'));
+ $this->assertFalse(file_exists(SABRE_TEMPDIR.'/root/file.txt'));
+ $this->assertEquals('contents',file_get_contents(SABRE_TEMPDIR.'/root/file2.txt'));
+
+ }
+
+ /**
+ * @depends testMoveFile
+ */
+ function testMoveFileNewParent() {
+
+ $this->tree->move('file.txt','subdir/file2.txt');
+ $this->assertTrue(file_exists(SABRE_TEMPDIR.'/root/subdir/file2.txt'));
+ $this->assertFalse(file_exists(SABRE_TEMPDIR.'/root/file.txt'));
+ $this->assertEquals('contents',file_get_contents(SABRE_TEMPDIR.'/root/subdir/file2.txt'));
+
+ }
+
+ /**
+ * @depends testCopyDirectory
+ */
+ function testMoveDirectory() {
+
+ $this->tree->move('subdir','subdir2');
+ $this->assertTrue(file_exists(SABRE_TEMPDIR.'/root/subdir2'));
+ $this->assertTrue(file_exists(SABRE_TEMPDIR.'/root/subdir2/subfile.txt'));
+ $this->assertFalse(file_exists(SABRE_TEMPDIR.'/root/subdir'));
+ $this->assertEquals('subcontents',file_get_contents(SABRE_TEMPDIR.'/root/subdir2/subfile.txt'));
+
+ }
+
+}
diff --git a/vendor/sabre/dav/tests/Sabre/DAV/PartialUpdate/FileMock.php b/vendor/sabre/dav/tests/Sabre/DAV/PartialUpdate/FileMock.php
new file mode 100644
index 000000000..e8cdc1666
--- /dev/null
+++ b/vendor/sabre/dav/tests/Sabre/DAV/PartialUpdate/FileMock.php
@@ -0,0 +1,79 @@
+<?php
+
+namespace Sabre\DAV\PartialUpdate;
+use Sabre\DAV;
+
+class FileMock implements IFile {
+
+ protected $data = '';
+
+ function put($str) {
+
+ if (is_resource($str)) {
+ $str = stream_get_contents($str);
+ }
+ $this->data = $str;
+
+ }
+
+ function putRange($str,$start) {
+
+ if (is_resource($str)) {
+ $str = stream_get_contents($str);
+ }
+ $this->data = substr($this->data, 0, $start) . $str . substr($this->data, $start + strlen($str));
+
+
+
+ }
+
+ function get() {
+
+ return $this->data;
+
+ }
+
+ function getContentType() {
+
+ return 'text/plain';
+
+ }
+
+ function getSize() {
+
+ return strlen($this->data);
+
+ }
+
+ function getETag() {
+
+ return '"' . $this->data . '"';
+
+ }
+
+ function delete() {
+
+ throw new DAV\Exception\MethodNotAllowed();
+
+ }
+
+ function setName($name) {
+
+ throw new DAV\Exception\MethodNotAllowed();
+
+ }
+
+ function getName() {
+
+ return 'partial';
+
+ }
+
+ 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
new file mode 100644
index 000000000..7b90429d4
--- /dev/null
+++ b/vendor/sabre/dav/tests/Sabre/DAV/PartialUpdate/PluginTest.php
@@ -0,0 +1,130 @@
+<?php
+
+namespace Sabre\DAV\PartialUpdate;
+
+use Sabre\DAV;
+use Sabre\HTTP;
+
+require_once 'Sabre/DAV/PartialUpdate/FileMock.php';
+
+class PluginTest extends \Sabre\DAVServerTest {
+
+ protected $node;
+ protected $plugin;
+
+ public function setUp() {
+
+ $this->node = new FileMock();
+ $this->tree[] = $this->node;
+
+ parent::setUp();
+
+ $this->plugin = new Plugin();
+ $this->server->addPlugin($this->plugin);
+
+
+
+ }
+
+ public function testInit() {
+
+ $this->assertEquals('partialupdate', $this->plugin->getPluginName());
+ $this->assertEquals(array('sabredav-partialupdate'), $this->plugin->getFeatures());
+ $this->assertEquals(array(
+ 'PATCH'
+ ), $this->plugin->getHTTPMethods('partial'));
+ $this->assertEquals(array(
+ ), $this->plugin->getHTTPMethods(''));
+
+ $this->assertNull($this->plugin->unknownMethod('FOO','partial'));
+
+ }
+
+ public function testPatchNoRange() {
+
+ $this->node->put('00000000');
+ $request = new HTTP\Request(array(
+ 'REQUEST_METHOD' => 'PATCH',
+ 'REQUEST_URI' => '/partial',
+ ));
+ $response = $this->request($request);
+
+ $this->assertEquals('HTTP/1.1 400 Bad request', $response->status, 'Full response body:' . $response->body);
+
+ }
+
+ public function testPatchNotSupported() {
+
+ $this->node->put('00000000');
+ $request = new HTTP\Request(array(
+ 'REQUEST_METHOD' => 'PATCH',
+ 'REQUEST_URI' => '/',
+ 'X_UPDATE_RANGE' => '3-4',
+
+ ));
+ $request->setBody(
+ '111'
+ );
+ $response = $this->request($request);
+
+ $this->assertEquals('HTTP/1.1 405 Method Not Allowed', $response->status, 'Full response body:' . $response->body);
+
+ }
+
+ public function testPatchNoContentType() {
+
+ $this->node->put('00000000');
+ $request = new HTTP\Request(array(
+ 'REQUEST_METHOD' => 'PATCH',
+ 'REQUEST_URI' => '/partial',
+ 'HTTP_X_UPDATE_RANGE' => 'bytes=3-4',
+
+ ));
+ $request->setBody(
+ '111'
+ );
+ $response = $this->request($request);
+
+ $this->assertEquals('HTTP/1.1 415 Unsupported Media Type', $response->status, 'Full response body:' . $response->body);
+
+ }
+
+ public function testPatchBadRange() {
+
+ $this->node->put('00000000');
+ $request = new HTTP\Request(array(
+ 'REQUEST_METHOD' => 'PATCH',
+ 'REQUEST_URI' => '/partial',
+ 'HTTP_X_UPDATE_RANGE' => 'bytes=3-4',
+ 'HTTP_CONTENT_TYPE' => 'application/x-sabredav-partialupdate',
+ ));
+ $request->setBody(
+ '111'
+ );
+ $response = $this->request($request);
+
+ $this->assertEquals('HTTP/1.1 416 Requested Range Not Satisfiable', $response->status, 'Full response body:' . $response->body);
+
+ }
+
+ public function testPatchSuccess() {
+
+ $this->node->put('00000000');
+ $request = new HTTP\Request(array(
+ 'REQUEST_METHOD' => 'PATCH',
+ 'REQUEST_URI' => '/partial',
+ 'HTTP_X_UPDATE_RANGE' => 'bytes=3-5',
+ 'HTTP_CONTENT_TYPE' => 'application/x-sabredav-partialupdate',
+ 'HTTP_CONTENT_LENGTH' => 3,
+ ));
+ $request->setBody(
+ '111'
+ );
+ $response = $this->request($request);
+
+ $this->assertEquals('HTTP/1.1 204 No Content', $response->status, 'Full response body:' . $response->body);
+ $this->assertEquals('00111000', $this->node->get());
+
+ }
+
+}
diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Property/GetLastModifiedTest.php b/vendor/sabre/dav/tests/Sabre/DAV/Property/GetLastModifiedTest.php
new file mode 100644
index 000000000..de8ca1283
--- /dev/null
+++ b/vendor/sabre/dav/tests/Sabre/DAV/Property/GetLastModifiedTest.php
@@ -0,0 +1,75 @@
+<?php
+
+namespace Sabre\DAV\Property;
+
+use Sabre\DAV;
+use Sabre\HTTP;
+
+class GetLastModifiedTest extends \PHPUnit_Framework_TestCase {
+
+ function testConstructDateTime() {
+
+ $dt = new \DateTime('2010-03-14 16:35', new \DateTimeZone('UTC'));
+ $lastMod = new GetLastModified($dt);
+ $this->assertEquals($dt->format(\DateTime::ATOM), $lastMod->getTime()->format(\DateTime::ATOM));
+
+ }
+
+ function testConstructString() {
+
+ $dt = new \DateTime('2010-03-14 16:35', new \DateTimeZone('UTC'));
+ $lastMod = new GetLastModified('2010-03-14 16:35');
+ $this->assertEquals($dt->format(\DateTime::ATOM), $lastMod->getTime()->format(\DateTime::ATOM));
+
+ }
+
+ function testConstructInt() {
+
+ $dt = new \DateTime('2010-03-14 16:35', new \DateTimeZone('UTC'));
+ $lastMod = new GetLastModified((int)$dt->format('U'));
+ $this->assertEquals($dt->format(\DateTime::ATOM), $lastMod->getTime()->format(\DateTime::ATOM));
+
+ }
+
+ function testSerialize() {
+
+ $dt = new \DateTime('2010-03-14 16:35', new \DateTimeZone('UTC'));
+ $lastMod = new GetLastModified($dt);
+
+ $doc = new \DOMDocument();
+ $root = $doc->createElement('d:getlastmodified');
+ $root->setAttribute('xmlns:d','DAV:');
+
+ $doc->appendChild($root);
+ $server = new DAV\Server();
+
+ $lastMod->serialize($server, $root);
+
+ $xml = $doc->saveXML();
+
+ /*
+ $this->assertEquals(
+'<?xml version="1.0"?>
+<d:getlastmodified xmlns:d="DAV:" xmlns:b="urn:uuid:c2f41010-65b3-11d1-a29f-00aa00c14882/" b:dt="dateTime.rfc1123">' .
+HTTP\Util::toHTTPDate($dt) .
+'</d:getlastmodified>
+', $xml);
+ */
+ $this->assertEquals(
+'<?xml version="1.0"?>
+<d:getlastmodified xmlns:d="DAV:">' .
+HTTP\Util::toHTTPDate($dt) .
+'</d:getlastmodified>
+', $xml);
+
+ $ok = false;
+ try {
+ GetLastModified::unserialize(DAV\XMLUtil::loadDOMDocument($xml)->firstChild);
+ } catch (DAV\Exception $e) {
+ $ok = true;
+ }
+ if (!$ok) $this->markTestFailed('Unserialize should not be supported');
+
+ }
+
+}
diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Property/HrefListTest.php b/vendor/sabre/dav/tests/Sabre/DAV/Property/HrefListTest.php
new file mode 100644
index 000000000..fe2bc81f9
--- /dev/null
+++ b/vendor/sabre/dav/tests/Sabre/DAV/Property/HrefListTest.php
@@ -0,0 +1,91 @@
+<?php
+
+namespace Sabre\DAV\Property;
+use Sabre\DAV;
+
+class HrefListTest extends \PHPUnit_Framework_TestCase {
+
+ function testConstruct() {
+
+ $href = new HrefList(array('foo','bar'));
+ $this->assertEquals(array('foo','bar'),$href->getHrefs());
+
+ }
+
+ function testSerialize() {
+
+ $href = new HrefList(array('foo','bar'));
+ $this->assertEquals(array('foo','bar'),$href->getHrefs());
+
+ $doc = new \DOMDocument();
+ $root = $doc->createElement('d:anything');
+ $root->setAttribute('xmlns:d','DAV:');
+
+ $doc->appendChild($root);
+ $server = new DAV\Server();
+ $server->setBaseUri('/bla/');
+
+ $href->serialize($server, $root);
+
+ $xml = $doc->saveXML();
+
+ $this->assertEquals(
+'<?xml version="1.0"?>
+<d:anything xmlns:d="DAV:"><d:href>/bla/foo</d:href><d:href>/bla/bar</d:href></d:anything>
+', $xml);
+
+ }
+
+ function testSerializeNoPrefix() {
+
+ $href = new HrefList(array('foo','bar'), false);
+ $this->assertEquals(array('foo','bar'),$href->getHrefs());
+
+ $doc = new \DOMDocument();
+ $root = $doc->createElement('d:anything');
+ $root->setAttribute('xmlns:d','DAV:');
+
+ $doc->appendChild($root);
+ $server = new DAV\Server();
+ $server->setBaseUri('/bla/');
+
+ $href->serialize($server, $root);
+
+ $xml = $doc->saveXML();
+
+ $this->assertEquals(
+'<?xml version="1.0"?>
+<d:anything xmlns:d="DAV:"><d:href>foo</d:href><d:href>bar</d:href></d:anything>
+', $xml);
+
+ }
+
+ function testUnserialize() {
+
+ $xml = '<?xml version="1.0"?>
+<d:anything xmlns:d="urn:DAV"><d:href>/bla/foo</d:href><d:href>/bla/bar</d:href></d:anything>
+';
+
+ $dom = new \DOMDocument();
+ $dom->loadXML($xml);
+
+ $href = HrefList::unserialize($dom->firstChild);
+ $this->assertEquals(array('/bla/foo','/bla/bar'),$href->getHrefs());
+
+ }
+
+ function testUnserializeIncompatible() {
+
+ $xml = '<?xml version="1.0"?>
+<d:anything xmlns:d="urn:DAV"><d:href2>/bla/foo</d:href2></d:anything>
+';
+
+ $dom = new \DOMDocument();
+ $dom->loadXML($xml);
+
+ $href = HrefList::unserialize($dom->firstChild);
+ $this->assertEquals(array(), $href->getHrefs());
+
+ }
+
+}
diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Property/HrefTest.php b/vendor/sabre/dav/tests/Sabre/DAV/Property/HrefTest.php
new file mode 100644
index 000000000..e5607f51b
--- /dev/null
+++ b/vendor/sabre/dav/tests/Sabre/DAV/Property/HrefTest.php
@@ -0,0 +1,119 @@
+<?php
+
+namespace Sabre\DAV\Property;
+
+use Sabre\DAV;
+
+class HrefTest extends \PHPUnit_Framework_TestCase {
+
+ function testConstruct() {
+
+ $href = new Href('path');
+ $this->assertEquals('path',$href->getHref());
+
+ }
+
+ function testSerialize() {
+
+ $href = new Href('path');
+ $this->assertEquals('path',$href->getHref());
+
+ $doc = new \DOMDocument();
+ $root = $doc->createElement('d:anything');
+ $root->setAttribute('xmlns:d','DAV:');
+
+ $doc->appendChild($root);
+ $server = new DAV\Server();
+ $server->setBaseUri('/bla/');
+
+ $href->serialize($server, $root);
+
+ $xml = $doc->saveXML();
+
+ $this->assertEquals(
+'<?xml version="1.0"?>
+<d:anything xmlns:d="DAV:"><d:href>/bla/path</d:href></d:anything>
+', $xml);
+
+ }
+
+ function testSerializeNoPrefix() {
+
+ $href = new Href('path',false);
+ $this->assertEquals('path',$href->getHref());
+
+ $doc = new \DOMDocument();
+ $root = $doc->createElement('d:anything');
+ $root->setAttribute('xmlns:d','DAV:');
+
+ $doc->appendChild($root);
+ $server = new DAV\Server();
+ $server->setBaseUri('/bla/');
+
+ $href->serialize($server, $root);
+
+ $xml = $doc->saveXML();
+
+ $this->assertEquals(
+'<?xml version="1.0"?>
+<d:anything xmlns:d="DAV:"><d:href>path</d:href></d:anything>
+', $xml);
+
+ }
+
+ function testUnserialize() {
+
+ $xml = '<?xml version="1.0"?>
+<d:anything xmlns:d="urn:DAV"><d:href>/bla/path</d:href></d:anything>
+';
+
+ $dom = new \DOMDocument();
+ $dom->loadXML($xml);
+
+ $href = Href::unserialize($dom->firstChild);
+ $this->assertEquals('/bla/path',$href->getHref());
+
+ }
+
+ function testUnserializeIncompatible() {
+
+ $xml = '<?xml version="1.0"?>
+<d:anything xmlns:d="urn:DAV"><d:href2>/bla/path</d:href2></d:anything>
+';
+
+ $dom = new \DOMDocument();
+ $dom->loadXML($xml);
+
+ $href = Href::unserialize($dom->firstChild);
+ $this->assertNull($href);
+
+ }
+
+ /**
+ * This method tests if hrefs containing & are correctly encoded.
+ */
+ function testSerializeEntity() {
+
+ $href = new Href('http://example.org/?a&b', false);
+ $this->assertEquals('http://example.org/?a&b',$href->getHref());
+
+ $doc = new \DOMDocument();
+ $root = $doc->createElement('d:anything');
+ $root->setAttribute('xmlns:d','DAV:');
+
+ $doc->appendChild($root);
+ $server = new DAV\Server();
+ $server->setBaseUri('/bla/');
+
+ $href->serialize($server, $root);
+
+ $xml = $doc->saveXML();
+
+ $this->assertEquals(
+'<?xml version="1.0"?>
+<d:anything xmlns:d="DAV:"><d:href>http://example.org/?a&amp;b</d:href></d:anything>
+', $xml);
+
+ }
+
+}
diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Property/ResourceTypeTest.php b/vendor/sabre/dav/tests/Sabre/DAV/Property/ResourceTypeTest.php
new file mode 100644
index 000000000..8a579baec
--- /dev/null
+++ b/vendor/sabre/dav/tests/Sabre/DAV/Property/ResourceTypeTest.php
@@ -0,0 +1,111 @@
+<?php
+
+namespace Sabre\DAV\Property;
+
+use Sabre\DAV;
+
+class ResourceTypeTest extends \PHPUnit_Framework_TestCase {
+
+ function testConstruct() {
+
+ $resourceType = new ResourceType(array('{DAV:}collection'));
+ $this->assertEquals(array('{DAV:}collection'),$resourceType->getValue());
+
+ $resourceType = new ResourceType(DAV\Server::NODE_FILE);
+ $this->assertEquals(array(),$resourceType->getValue());
+
+ $resourceType = new ResourceType(DAV\Server::NODE_DIRECTORY);
+ $this->assertEquals(array('{DAV:}collection'),$resourceType->getValue());
+
+ $resourceType = new ResourceType('{DAV:}principal');
+ $this->assertEquals(array('{DAV:}principal'),$resourceType->getValue());
+
+ }
+
+ /**
+ * @depends testConstruct
+ */
+ function testSerialize() {
+
+ $resourceType = new ResourceType(array('{DAV:}collection','{DAV:}principal'));
+
+ $doc = new \DOMDocument();
+ $root = $doc->createElement('d:anything');
+ $root->setAttribute('xmlns:d','DAV:');
+
+ $doc->appendChild($root);
+ $server = new DAV\Server();
+ $resourceType->serialize($server, $root);
+
+ $xml = $doc->saveXML();
+
+ $this->assertEquals(
+'<?xml version="1.0"?>
+<d:anything xmlns:d="DAV:"><d:collection/><d:principal/></d:anything>
+', $xml);
+
+ }
+
+ /**
+ * @depends testSerialize
+ */
+ function testSerializeCustomNS() {
+
+ $resourceType = new ResourceType(array('{http://example.org/NS}article'));
+
+ $doc = new \DOMDocument();
+ $root = $doc->createElement('d:anything');
+ $root->setAttribute('xmlns:d','DAV:');
+
+ $doc->appendChild($root);
+ $server = new DAV\Server();
+ $resourceType->serialize($server, $root);
+
+ $xml = $doc->saveXML();
+
+ $this->assertEquals(
+'<?xml version="1.0"?>
+<d:anything xmlns:d="DAV:"><custom:article xmlns:custom="http://example.org/NS"/></d:anything>
+', $xml);
+
+ }
+
+ /**
+ * @depends testConstruct
+ */
+ function testIs() {
+
+ $resourceType = new ResourceType(array('{DAV:}collection','{DAV:}principal'));
+ $this->assertTrue($resourceType->is('{DAV:}collection'));
+ $this->assertFalse($resourceType->is('{DAV:}blabla'));
+
+ }
+
+ /**
+ * @depends testConstruct
+ */
+ function testAdd() {
+
+ $resourceType = new ResourceType(array('{DAV:}collection','{DAV:}principal'));
+ $resourceType->add('{DAV:}foo');
+ $this->assertEquals(array('{DAV:}collection','{DAV:}principal','{DAV:}foo'), $resourceType->getValue());
+
+ }
+
+ /**
+ * @depends testConstruct
+ */
+ function testUnserialize() {
+
+ $xml ='<?xml version="1.0"?>
+<d:anything xmlns:d="DAV:"><d:collection/><d:principal/></d:anything>
+';
+
+ $dom = DAV\XMLUtil::loadDOMDocument($xml);
+
+ $resourceType = ResourceType::unserialize($dom->firstChild);
+ $this->assertEquals(array('{DAV:}collection','{DAV:}principal'),$resourceType->getValue());
+
+ }
+
+}
diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Property/ResponseListTest.php b/vendor/sabre/dav/tests/Sabre/DAV/Property/ResponseListTest.php
new file mode 100644
index 000000000..d13066b80
--- /dev/null
+++ b/vendor/sabre/dav/tests/Sabre/DAV/Property/ResponseListTest.php
@@ -0,0 +1,19 @@
+<?php
+
+namespace Sabre\DAV\Property;
+
+class ResponseListTest extends \PHPUnit_Framework_TestCase {
+
+ /**
+ * This was the only part not yet covered by other tests, so I'm going to
+ * be lazy and (for now) only test this case.
+ *
+ * @expectedException InvalidArgumentException
+ */
+ public function testInvalidArg() {
+
+ $response = new ResponseList(array(1,2));
+
+ }
+
+}
diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Property/ResponseTest.php b/vendor/sabre/dav/tests/Sabre/DAV/Property/ResponseTest.php
new file mode 100644
index 000000000..073cbb2ce
--- /dev/null
+++ b/vendor/sabre/dav/tests/Sabre/DAV/Property/ResponseTest.php
@@ -0,0 +1,230 @@
+<?php
+
+namespace Sabre\DAV\Property;
+
+use Sabre\DAV;
+
+class ResponseTest extends \PHPUnit_Framework_TestCase {
+
+ function testSimple() {
+
+ $innerProps = array(
+ 200 => array(
+ '{DAV:}displayname' => 'my file',
+ ),
+ 404 => array(
+ '{DAV:}owner' => null,
+ )
+ );
+
+ $property = new Response('uri',$innerProps);
+
+ $this->assertEquals('uri',$property->getHref());
+ $this->assertEquals($innerProps,$property->getResponseProperties());
+
+
+ }
+
+ /**
+ * @depends testSimple
+ */
+ function testSerialize() {
+
+ $innerProps = array(
+ 200 => array(
+ '{DAV:}displayname' => 'my file',
+ ),
+ 404 => array(
+ '{DAV:}owner' => null,
+ )
+ );
+
+ $property = new Response('uri',$innerProps);
+
+ $doc = new \DOMDocument();
+ $root = $doc->createElement('d:root');
+ $root->setAttribute('xmlns:d','DAV:');
+
+ $doc->appendChild($root);
+ $server = new DAV\Server();
+
+ $property->serialize($server, $root);
+
+ $xml = $doc->saveXML();
+
+ $this->assertEquals(
+'<?xml version="1.0"?>
+<d:root xmlns:d="DAV:">' .
+'<d:response>' .
+'<d:href>/uri</d:href>' .
+'<d:propstat>' .
+'<d:prop>' .
+'<d:displayname>my file</d:displayname>' .
+'</d:prop>' .
+'<d:status>HTTP/1.1 200 OK</d:status>' .
+'</d:propstat>' .
+'<d:propstat>' .
+'<d:prop>' .
+'<d:owner/>' .
+'</d:prop>' .
+'<d:status>HTTP/1.1 404 Not Found</d:status>' .
+'</d:propstat>' .
+'</d:response>' .
+'</d:root>
+', $xml);
+
+ }
+
+ /**
+ * This one is specifically for testing properties with no namespaces, which is legal xml
+ *
+ * @depends testSerialize
+ */
+ function testSerializeEmptyNamespace() {
+
+ $innerProps = array(
+ 200 => array(
+ '{}propertyname' => 'value',
+ ),
+ );
+
+ $property = new Response('uri',$innerProps);
+
+ $doc = new \DOMDocument();
+ $root = $doc->createElement('d:root');
+ $root->setAttribute('xmlns:d','DAV:');
+
+ $doc->appendChild($root);
+ $server = new DAV\Server();
+
+ $property->serialize($server, $root);
+
+ $xml = $doc->saveXML();
+
+ $this->assertEquals(
+'<?xml version="1.0"?>
+<d:root xmlns:d="DAV:">' .
+'<d:response>' .
+'<d:href>/uri</d:href>' .
+'<d:propstat>' .
+'<d:prop>' .
+'<propertyname xmlns="">value</propertyname>' .
+'</d:prop>' .
+'<d:status>HTTP/1.1 200 OK</d:status>' .
+'</d:propstat>' .
+'</d:response>' .
+'</d:root>
+', $xml);
+
+ }
+
+ /**
+ * This one is specifically for testing properties with no namespaces, which is legal xml
+ *
+ * @depends testSerialize
+ */
+ function testSerializeCustomNamespace() {
+
+ $innerProps = array(
+ 200 => array(
+ '{http://sabredav.org/NS/example}propertyname' => 'value',
+ ),
+ );
+
+ $property = new Response('uri',$innerProps);
+
+ $doc = new \DOMDocument();
+ $root = $doc->createElement('d:root');
+ $root->setAttribute('xmlns:d','DAV:');
+
+ $doc->appendChild($root);
+ $server = new DAV\Server();
+
+ $property->serialize($server, $root);
+
+ $xml = $doc->saveXML();
+
+ $this->assertEquals(
+'<?xml version="1.0"?>
+<d:root xmlns:d="DAV:">' .
+'<d:response>' .
+'<d:href>/uri</d:href>' .
+'<d:propstat>' .
+'<d:prop>' .
+'<x2:propertyname xmlns:x2="http://sabredav.org/NS/example">value</x2:propertyname>' .
+'</d:prop>' .
+'<d:status>HTTP/1.1 200 OK</d:status>' .
+'</d:propstat>' .
+'</d:response>' .
+'</d:root>
+', $xml);
+
+ }
+
+ /**
+ * @depends testSerialize
+ */
+ function testSerializeComplexProperty() {
+
+ $innerProps = array(
+ 200 => array(
+ '{DAV:}link' => new Href('http://sabredav.org/', false)
+ ),
+ );
+
+ $property = new Response('uri',$innerProps);
+
+ $doc = new \DOMDocument();
+ $root = $doc->createElement('d:root');
+ $root->setAttribute('xmlns:d','DAV:');
+
+ $doc->appendChild($root);
+ $server = new DAV\Server();
+
+ $property->serialize($server, $root);
+
+ $xml = $doc->saveXML();
+
+ $this->assertEquals(
+'<?xml version="1.0"?>
+<d:root xmlns:d="DAV:">' .
+'<d:response>' .
+'<d:href>/uri</d:href>' .
+'<d:propstat>' .
+'<d:prop>' .
+'<d:link><d:href>http://sabredav.org/</d:href></d:link>' .
+'</d:prop>' .
+'<d:status>HTTP/1.1 200 OK</d:status>' .
+'</d:propstat>' .
+'</d:response>' .
+'</d:root>
+', $xml);
+
+ }
+
+ /**
+ * @depends testSerialize
+ * @expectedException Sabre\DAV\Exception
+ */
+ function testSerializeBreak() {
+
+ $innerProps = array(
+ 200 => array(
+ '{DAV:}link' => new \STDClass()
+ ),
+ );
+
+ $property = new Response('uri',$innerProps);
+
+ $doc = new \DOMDocument();
+ $root = $doc->createElement('d:root');
+ $root->setAttribute('xmlns:d','DAV:');
+
+ $doc->appendChild($root);
+ $server = new DAV\Server();
+
+ $property->serialize($server, $root);
+
+ }
+
+}
diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Property/SupportedReportSetTest.php b/vendor/sabre/dav/tests/Sabre/DAV/Property/SupportedReportSetTest.php
new file mode 100644
index 000000000..445e22ab3
--- /dev/null
+++ b/vendor/sabre/dav/tests/Sabre/DAV/Property/SupportedReportSetTest.php
@@ -0,0 +1,128 @@
+<?php
+
+namespace Sabre\DAV\Property;
+
+use Sabre\DAV;
+use Sabre\HTTP;
+
+require_once 'Sabre/HTTP/ResponseMock.php';
+require_once 'Sabre/DAV/AbstractServer.php';
+
+class SupportedReportSetTest extends DAV\AbstractServer {
+
+ public function sendPROPFIND($body) {
+
+ $serverVars = array(
+ 'REQUEST_URI' => '/',
+ 'REQUEST_METHOD' => 'PROPFIND',
+ 'HTTP_DEPTH' => '0',
+ );
+
+ $request = new HTTP\Request($serverVars);
+ $request->setBody($body);
+
+ $this->server->httpRequest = ($request);
+ $this->server->exec();
+
+ }
+
+ /**
+ * @covers Sabre\DAV\Property\SupportedReportSet
+ */
+ function testNoReports() {
+
+ $xml = '<?xml version="1.0"?>
+<d:propfind xmlns:d="DAV:">
+ <d:prop>
+ <d:supported-report-set />
+ </d:prop>
+</d:propfind>';
+
+ $this->sendPROPFIND($xml);
+
+ $this->assertEquals('HTTP/1.1 207 Multi-Status',$this->response->status,'We expected a multi-status response. Full response body: ' . $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');
+
+ $data = $xml->xpath('/d:multistatus/d:response/d:propstat/d:prop');
+ $this->assertEquals(1,count($data),'We expected 1 \'d:prop\' element');
+
+ $data = $xml->xpath('/d:multistatus/d:response/d:propstat/d:prop/d:supported-report-set');
+ $this->assertEquals(1,count($data),'We expected 1 \'d:supported-report-set\' element');
+
+ $data = $xml->xpath('/d:multistatus/d:response/d:propstat/d:status');
+ $this->assertEquals(1,count($data),'We expected 1 \'d:status\' element');
+
+ $this->assertEquals('HTTP/1.1 200 OK',(string)$data[0],'The status for this property should have been 200');
+
+ }
+
+ /**
+ * @covers Sabre\DAV\Property\SupportedReportSet
+ * @depends testNoReports
+ */
+ function testCustomReport() {
+
+ // Intercepting the report property
+ $this->server->subscribeEvent('afterGetProperties',array($this,'addProp'));
+
+ $xml = '<?xml version="1.0"?>
+<d:propfind xmlns:d="DAV:">
+ <d:prop>
+ <d:supported-report-set />
+ </d:prop>
+</d:propfind>';
+
+ $this->sendPROPFIND($xml);
+
+ $this->assertEquals('HTTP/1.1 207 Multi-Status',$this->response->status,'We expected a multi-status response. Full response body: ' . $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');
+ $xml->registerXPathNamespace('x','http://www.rooftopsolutions.nl/testnamespace');
+
+ $data = $xml->xpath('/d:multistatus/d:response/d:propstat/d:prop');
+ $this->assertEquals(1,count($data),'We expected 1 \'d:prop\' element');
+
+ $data = $xml->xpath('/d:multistatus/d:response/d:propstat/d:prop/d:supported-report-set');
+ $this->assertEquals(1,count($data),'We expected 1 \'d:supported-report-set\' element');
+
+ $data = $xml->xpath('/d:multistatus/d:response/d:propstat/d:prop/d:supported-report-set/d:supported-report');
+ $this->assertEquals(2,count($data),'We expected 2 \'d:supported-report\' elements');
+
+ $data = $xml->xpath('/d:multistatus/d:response/d:propstat/d:prop/d:supported-report-set/d:supported-report/d:report');
+ $this->assertEquals(2,count($data),'We expected 2 \'d:report\' elements');
+
+ $data = $xml->xpath('/d:multistatus/d:response/d:propstat/d:prop/d:supported-report-set/d:supported-report/d:report/x:myreport');
+ $this->assertEquals(1,count($data),'We expected 1 \'x:myreport\' element. Full body: ' . $this->response->body);
+
+ $data = $xml->xpath('/d:multistatus/d:response/d:propstat/d:prop/d:supported-report-set/d:supported-report/d:report/d:anotherreport');
+ $this->assertEquals(1,count($data),'We expected 1 \'d:anotherreport\' element. Full body: ' . $this->response->body);
+
+ $data = $xml->xpath('/d:multistatus/d:response/d:propstat/d:status');
+ $this->assertEquals(1,count($data),'We expected 1 \'d:status\' element');
+
+ $this->assertEquals('HTTP/1.1 200 OK',(string)$data[0],'The status for this property should have been 200');
+
+ }
+
+ /**
+ * This method is used as a callback for afterGetProperties
+ */
+ function addProp($path, &$properties) {
+
+ if (isset($properties[200]['{DAV:}supported-report-set'])) {
+ $properties[200]['{DAV:}supported-report-set']->addReport('{http://www.rooftopsolutions.nl/testnamespace}myreport');
+ $properties[200]['{DAV:}supported-report-set']->addReport('{DAV:}anotherreport');
+ }
+
+ }
+
+
+
+}
+
+?>
diff --git a/vendor/sabre/dav/tests/Sabre/DAV/ServerCopyMoveTest.php b/vendor/sabre/dav/tests/Sabre/DAV/ServerCopyMoveTest.php
new file mode 100644
index 000000000..88e107c19
--- /dev/null
+++ b/vendor/sabre/dav/tests/Sabre/DAV/ServerCopyMoveTest.php
@@ -0,0 +1,268 @@
+<?php
+
+namespace Sabre\DAV;
+
+use Sabre\HTTP;
+
+require_once 'Sabre/HTTP/ResponseMock.php';
+
+class ServerCopyMoveTest extends \PHPUnit_Framework_TestCase {
+
+ private $response;
+ /**
+ * @var Server
+ */
+ private $server;
+
+ function setUp() {
+
+ $this->response = new HTTP\ResponseMock();
+ $dir = new FS\Directory(SABRE_TEMPDIR);
+ $tree = new ObjectTree($dir);
+ $this->server = new Server($tree);
+ $this->server->debugExceptions = true;
+ $this->server->httpResponse = $this->response;
+ file_put_contents(SABRE_TEMPDIR . '/test.txt', 'Test contents');
+ file_put_contents(SABRE_TEMPDIR . '/test2.txt', 'Test contents2');
+ mkdir(SABRE_TEMPDIR . '/col');
+ file_put_contents(SABRE_TEMPDIR . 'col/test.txt', 'Test contents');
+
+ }
+
+ function tearDown() {
+
+ $cleanUp = array('test.txt','testput.txt','testcol','test2.txt','test3.txt','col/test.txt','col','col2/test.txt','col2');
+ foreach($cleanUp as $file) {
+ $tmpFile = SABRE_TEMPDIR . '/' . $file;
+ if (file_exists($tmpFile)) {
+
+ if (is_dir($tmpFile)) {
+ rmdir($tmpFile);
+ } else {
+ unlink($tmpFile);
+ }
+
+ }
+ }
+
+ }
+
+
+ function testCopyOverWrite() {
+
+ $serverVars = array(
+ 'REQUEST_URI' => '/test.txt',
+ 'REQUEST_METHOD' => 'COPY',
+ 'HTTP_DESTINATION' => '/test2.txt',
+ );
+
+ $request = new HTTP\Request($serverVars);
+ $this->server->httpRequest = ($request);
+ $this->server->exec();
+
+ $this->assertEquals('HTTP/1.1 204 No Content',$this->response->status,'Received an incorrect HTTP status. Full body inspection: ' . $this->response->body);
+ $this->assertEquals(array(
+ 'Content-Length' => '0',
+ ),
+ $this->response->headers
+ );
+
+ $this->assertEquals('Test contents',file_get_contents(SABRE_TEMPDIR. '/test2.txt'));
+
+ }
+
+ function testCopyToSelf() {
+
+ $serverVars = array(
+ 'REQUEST_URI' => '/test.txt',
+ 'REQUEST_METHOD' => 'COPY',
+ 'HTTP_DESTINATION' => '/test.txt',
+ );
+
+ $request = new HTTP\Request($serverVars);
+ $this->server->httpRequest = ($request);
+ $this->server->exec();
+
+ $this->assertEquals('HTTP/1.1 403 Forbidden',$this->response->status,'Received an incorrect HTTP status. Full body inspection: ' . $this->response->body);
+ $this->assertEquals('Test contents',file_get_contents(SABRE_TEMPDIR. '/test.txt'));
+
+ }
+
+ function testMoveToSelf() {
+
+ $serverVars = array(
+ 'REQUEST_URI' => '/test.txt',
+ 'REQUEST_METHOD' => 'MOVE',
+ 'HTTP_DESTINATION' => '/test.txt',
+ );
+
+ $request = new HTTP\Request($serverVars);
+ $this->server->httpRequest = ($request);
+ $this->server->exec();
+
+ $this->assertEquals('HTTP/1.1 403 Forbidden',$this->response->status,'Received an incorrect HTTP status. Full body inspection: ' . $this->response->body);
+ $this->assertEquals('Test contents',file_get_contents(SABRE_TEMPDIR. '/test.txt'));
+
+ }
+
+ function testMoveOverWrite() {
+
+ $serverVars = array(
+ 'REQUEST_URI' => '/test.txt',
+ 'REQUEST_METHOD' => 'MOVE',
+ 'HTTP_DESTINATION' => '/test2.txt',
+ );
+
+ $request = new HTTP\Request($serverVars);
+ $this->server->httpRequest = ($request);
+ $this->server->exec();
+
+ $this->assertEquals(array(
+ 'Content-Length' => 0,
+ ),
+ $this->response->headers
+ );
+
+ $this->assertEquals('HTTP/1.1 204 No Content',$this->response->status);
+ $this->assertEquals('Test contents',file_get_contents(SABRE_TEMPDIR . '/test2.txt'));
+ $this->assertFalse(file_exists(SABRE_TEMPDIR . '/test.txt'),'The sourcefile test.txt should no longer exist at this point');
+
+ }
+
+ function testBlockedOverWrite() {
+
+ $serverVars = array(
+ 'REQUEST_URI' => '/test.txt',
+ 'REQUEST_METHOD' => 'COPY',
+ 'HTTP_DESTINATION' => '/test2.txt',
+ 'HTTP_OVERWRITE' => 'F',
+ );
+
+ $request = new HTTP\Request($serverVars);
+ $this->server->httpRequest = ($request);
+ $this->server->exec();
+
+ $this->assertEquals(array(
+ 'Content-Type' => 'application/xml; charset=utf-8',
+ ),
+ $this->response->headers
+ );
+
+ $this->assertEquals('HTTP/1.1 412 Precondition failed',$this->response->status);
+ $this->assertEquals('Test contents2',file_get_contents(SABRE_TEMPDIR . '/test2.txt'));
+
+
+ }
+
+ function testNonExistantParent() {
+
+ $serverVars = array(
+ 'REQUEST_URI' => '/test.txt',
+ 'REQUEST_METHOD' => 'COPY',
+ 'HTTP_DESTINATION' => '/testcol2/test2.txt',
+ 'HTTP_OVERWRITE' => 'F',
+ );
+
+ $request = new HTTP\Request($serverVars);
+ $this->server->httpRequest = ($request);
+ $this->server->exec();
+
+ $this->assertEquals(array(
+ 'Content-Type' => 'application/xml; charset=utf-8',
+ ),
+ $this->response->headers
+ );
+
+ $this->assertEquals('HTTP/1.1 409 Conflict',$this->response->status);
+
+ }
+
+ function testRandomOverwriteHeader() {
+
+ $serverVars = array(
+ 'REQUEST_URI' => '/test.txt',
+ 'REQUEST_METHOD' => 'COPY',
+ 'HTTP_DESTINATION' => '/testcol2/test2.txt',
+ 'HTTP_OVERWRITE' => 'SURE!',
+ );
+
+ $request = new HTTP\Request($serverVars);
+ $this->server->httpRequest = ($request);
+ $this->server->exec();
+
+ $this->assertEquals('HTTP/1.1 400 Bad request',$this->response->status);
+
+ }
+
+ function testCopyDirectory() {
+
+ $serverVars = array(
+ 'REQUEST_URI' => '/col',
+ 'REQUEST_METHOD' => 'COPY',
+ 'HTTP_DESTINATION' => '/col2',
+ );
+
+ $request = new HTTP\Request($serverVars);
+ $this->server->httpRequest = ($request);
+ $this->server->exec();
+
+ $this->assertEquals(array(
+ 'Content-Length' => '0',
+ ),
+ $this->response->headers
+ );
+
+ $this->assertEquals('HTTP/1.1 201 Created',$this->response->status);
+ $this->assertEquals('Test contents',file_get_contents(SABRE_TEMPDIR . '/col2/test.txt'));
+
+ }
+
+ function testSimpleCopyFile() {
+
+ $serverVars = array(
+ 'REQUEST_URI' => '/test.txt',
+ 'REQUEST_METHOD' => 'COPY',
+ 'HTTP_DESTINATION' => '/test3.txt',
+ );
+
+ $request = new HTTP\Request($serverVars);
+ $this->server->httpRequest = ($request);
+ $this->server->exec();
+
+ $this->assertEquals(array(
+ 'Content-Length' => '0',
+ ),
+ $this->response->headers
+ );
+
+ $this->assertEquals('HTTP/1.1 201 Created',$this->response->status);
+ $this->assertEquals('Test contents',file_get_contents(SABRE_TEMPDIR . '/test3.txt'));
+
+ }
+
+ function testSimpleCopyCollection() {
+
+ $serverVars = array(
+ 'REQUEST_URI' => '/col',
+ 'REQUEST_METHOD' => 'COPY',
+ 'HTTP_DESTINATION' => '/col2',
+ );
+
+ $request = new HTTP\Request($serverVars);
+ $this->server->httpRequest = ($request);
+ $this->server->exec();
+
+ $this->assertEquals('HTTP/1.1 201 Created',$this->response->status,'Incorrect status received. Full response body: ' . $this->response->body);
+
+ $this->assertEquals(array(
+ 'Content-Length' => '0',
+ ),
+ $this->response->headers
+ );
+
+
+ $this->assertEquals('Test contents',file_get_contents(SABRE_TEMPDIR . '/col2/test.txt'));
+
+ }
+
+}
diff --git a/vendor/sabre/dav/tests/Sabre/DAV/ServerEventsTest.php b/vendor/sabre/dav/tests/Sabre/DAV/ServerEventsTest.php
new file mode 100644
index 000000000..2c7a074df
--- /dev/null
+++ b/vendor/sabre/dav/tests/Sabre/DAV/ServerEventsTest.php
@@ -0,0 +1,76 @@
+<?php
+
+namespace Sabre\DAV;
+use Sabre\HTTP;
+
+require_once 'Sabre/DAV/AbstractServer.php';
+
+class ServerEventsTest extends AbstractServer {
+
+ private $tempPath;
+
+ private $exception;
+
+ function testAfterBind() {
+
+ $this->server->subscribeEvent('afterBind',array($this,'afterBindHandler'));
+ $newPath = 'afterBind';
+
+ $this->tempPath = '';
+ $this->server->createFile($newPath,'body');
+ $this->assertEquals($newPath, $this->tempPath);
+
+ }
+
+ function afterBindHandler($path) {
+
+ $this->tempPath = $path;
+
+ }
+
+ function testBeforeBindCancel() {
+
+ $this->server->subscribeEvent('beforeBind', array($this,'beforeBindCancelHandler'));
+ $this->assertFalse($this->server->createFile('bla','body'));
+
+ // Also testing put()
+ $req = new HTTP\Request(array(
+ 'REQUEST_METHOD' => 'PUT',
+ 'REQUEST_URI' => '/barbar',
+ ));
+
+ $this->server->httpRequest = $req;
+ $this->server->exec();
+
+ $this->assertEquals('',$this->server->httpResponse->status);
+
+ }
+
+ function beforeBindCancelHandler() {
+
+ return false;
+
+ }
+
+ function testException() {
+
+ $this->server->subscribeEvent('exception', array($this, 'exceptionHandler'));
+
+ $req = new HTTP\Request(array(
+ 'REQUEST_METHOD' => 'GET',
+ 'REQUEST_URI' => '/not/exisitng',
+ ));
+ $this->server->httpRequest = $req;
+ $this->server->exec();
+
+ $this->assertInstanceOf('Sabre\\DAV\\Exception\\NotFound', $this->exception);
+
+ }
+
+ function exceptionHandler(Exception $exception) {
+
+ $this->exception = $exception;
+
+ }
+
+}
diff --git a/vendor/sabre/dav/tests/Sabre/DAV/ServerFinderBlockTest.php b/vendor/sabre/dav/tests/Sabre/DAV/ServerFinderBlockTest.php
new file mode 100644
index 000000000..180f27b2a
--- /dev/null
+++ b/vendor/sabre/dav/tests/Sabre/DAV/ServerFinderBlockTest.php
@@ -0,0 +1,53 @@
+<?php
+
+namespace Sabre\DAV;
+
+use Sabre\HTTP;
+
+require_once 'Sabre/HTTP/ResponseMock.php';
+require_once 'Sabre/DAV/AbstractServer.php';
+
+class ServerFinderBlockTest extends AbstractServer{
+
+ function testPut() {
+
+ $serverVars = array(
+ 'REQUEST_URI' => '/testput.txt',
+ 'REQUEST_METHOD' => 'PUT',
+ 'HTTP_X_EXPECTED_ENTITY_LENGTH' => '20',
+ );
+
+ $request = new HTTP\Request($serverVars);
+ $request->setBody('Testing finder');
+ $this->server->httpRequest = $request;
+ $this->server->exec();
+
+ $this->assertEquals('', $this->response->body);
+ $this->assertEquals('HTTP/1.1 201 Created',$this->response->status);
+ $this->assertEquals('0', $this->response->headers['Content-Length']);
+
+ $this->assertEquals('Testing finder',file_get_contents(SABRE_TEMPDIR . '/testput.txt'));
+
+ }
+
+ function testPutFail() {
+
+ $serverVars = array(
+ 'REQUEST_URI' => '/testput.txt',
+ 'REQUEST_METHOD' => 'PUT',
+ 'HTTP_X_EXPECTED_ENTITY_LENGTH' => '20',
+ );
+
+ $request = new HTTP\Request($serverVars);
+ $request->setBody('');
+ $this->server->httpRequest = $request;
+ $this->server->exec();
+
+ $this->assertEquals('HTTP/1.1 403 Forbidden',$this->response->status);
+ $this->assertEquals(array(
+ 'Content-Type' => 'application/xml; charset=utf-8',
+ ),$this->response->headers);
+
+ $this->assertFalse(file_exists(SABRE_TEMPDIR . '/testput.txt'));
+ }
+}
diff --git a/vendor/sabre/dav/tests/Sabre/DAV/ServerMKCOLTest.php b/vendor/sabre/dav/tests/Sabre/DAV/ServerMKCOLTest.php
new file mode 100644
index 000000000..34b084dcd
--- /dev/null
+++ b/vendor/sabre/dav/tests/Sabre/DAV/ServerMKCOLTest.php
@@ -0,0 +1,371 @@
+<?php
+
+namespace Sabre\DAV;
+
+use Sabre\HTTP;
+
+require_once 'Sabre/HTTP/ResponseMock.php';
+require_once 'Sabre/DAV/AbstractServer.php';
+require_once 'Sabre/DAV/Exception.php';
+
+class ServerMKCOLTest extends AbstractServer {
+
+ function testMkcol() {
+
+ $serverVars = array(
+ 'REQUEST_URI' => '/testcol',
+ 'REQUEST_METHOD' => 'MKCOL',
+ );
+
+ $request = new HTTP\Request($serverVars);
+ $request->setBody("");
+ $this->server->httpRequest = ($request);
+ $this->server->exec();
+
+ $this->assertEquals(array(
+ 'Content-Length' => '0',
+ ),$this->response->headers);
+
+ $this->assertEquals('HTTP/1.1 201 Created',$this->response->status);
+ $this->assertEquals('', $this->response->body);
+ $this->assertTrue(is_dir($this->tempDir . '/testcol'));
+
+ }
+
+ /**
+ * @depends testMkcol
+ */
+ function testMKCOLUnknownBody() {
+
+ $serverVars = array(
+ 'REQUEST_URI' => '/testcol',
+ 'REQUEST_METHOD' => 'MKCOL',
+ );
+
+ $request = new HTTP\Request($serverVars);
+ $request->setBody("Hello");
+ $this->server->httpRequest = ($request);
+ $this->server->exec();
+
+ $this->assertEquals(array(
+ 'Content-Type' => 'application/xml; charset=utf-8',
+ ),$this->response->headers);
+
+ $this->assertEquals('HTTP/1.1 415 Unsupported Media Type',$this->response->status);
+
+ }
+
+ /**
+ * @depends testMkcol
+ */
+ function testMKCOLBrokenXML() {
+
+ $serverVars = array(
+ 'REQUEST_URI' => '/testcol',
+ 'REQUEST_METHOD' => 'MKCOL',
+ 'HTTP_CONTENT_TYPE' => 'application/xml',
+ );
+
+ $request = new HTTP\Request($serverVars);
+ $request->setBody("Hello");
+ $this->server->httpRequest = ($request);
+ $this->server->exec();
+
+ $this->assertEquals(array(
+ 'Content-Type' => 'application/xml; charset=utf-8',
+ ),$this->response->headers);
+
+ $this->assertEquals('HTTP/1.1 400 Bad request',$this->response->status);
+
+ }
+
+ /**
+ * @depends testMkcol
+ */
+ function testMKCOLUnknownXML() {
+
+ $serverVars = array(
+ 'REQUEST_URI' => '/testcol',
+ 'REQUEST_METHOD' => 'MKCOL',
+ 'HTTP_CONTENT_TYPE' => 'application/xml',
+ );
+
+ $request = new HTTP\Request($serverVars);
+ $request->setBody('<?xml version="1.0"?><html></html>');
+ $this->server->httpRequest = ($request);
+ $this->server->exec();
+
+ $this->assertEquals(array(
+ 'Content-Type' => 'application/xml; charset=utf-8',
+ ),$this->response->headers);
+
+ $this->assertEquals('HTTP/1.1 415 Unsupported Media Type',$this->response->status);
+
+ }
+
+ /**
+ * @depends testMkcol
+ */
+ function testMKCOLNoResourceType() {
+
+ $serverVars = array(
+ 'REQUEST_URI' => '/testcol',
+ 'REQUEST_METHOD' => 'MKCOL',
+ 'HTTP_CONTENT_TYPE' => 'application/xml',
+ );
+
+ $request = new HTTP\Request($serverVars);
+ $request->setBody('<?xml version="1.0"?>
+<mkcol xmlns="DAV:">
+ <set>
+ <prop>
+ <displayname>Evert</displayname>
+ </prop>
+ </set>
+</mkcol>');
+ $this->server->httpRequest = ($request);
+ $this->server->exec();
+
+ $this->assertEquals(array(
+ 'Content-Type' => 'application/xml; charset=utf-8',
+ ),$this->response->headers);
+
+ $this->assertEquals('HTTP/1.1 400 Bad request',$this->response->status,'Wrong statuscode received. Full response body: ' .$this->response->body);
+
+ }
+
+ /**
+ * @depends testMKCOLNoResourceType
+ */
+ function testMKCOLIncorrectResourceType() {
+
+ $serverVars = array(
+ 'REQUEST_URI' => '/testcol',
+ 'REQUEST_METHOD' => 'MKCOL',
+ 'HTTP_CONTENT_TYPE' => 'application/xml',
+ );
+
+ $request = new HTTP\Request($serverVars);
+ $request->setBody('<?xml version="1.0"?>
+<mkcol xmlns="DAV:">
+ <set>
+ <prop>
+ <resourcetype><blabla /></resourcetype>
+ </prop>
+ </set>
+</mkcol>');
+ $this->server->httpRequest = ($request);
+ $this->server->exec();
+
+ $this->assertEquals(array(
+ 'Content-Type' => 'application/xml; charset=utf-8',
+ ),$this->response->headers);
+
+ $this->assertEquals('HTTP/1.1 403 Forbidden',$this->response->status,'Wrong statuscode received. Full response body: ' .$this->response->body);
+
+ }
+
+ /**
+ * @depends testMKCOLIncorrectResourceType
+ */
+ function testMKCOLIncorrectResourceType2() {
+
+ $serverVars = array(
+ 'REQUEST_URI' => '/testcol',
+ 'REQUEST_METHOD' => 'MKCOL',
+ 'HTTP_CONTENT_TYPE' => 'application/xml',
+ );
+
+ $request = new HTTP\Request($serverVars);
+ $request->setBody('<?xml version="1.0"?>
+<mkcol xmlns="DAV:">
+ <set>
+ <prop>
+ <resourcetype><collection /><blabla /></resourcetype>
+ </prop>
+ </set>
+</mkcol>');
+ $this->server->httpRequest = ($request);
+ $this->server->exec();
+
+ $this->assertEquals(array(
+ 'Content-Type' => 'application/xml; charset=utf-8',
+ ),$this->response->headers);
+
+ $this->assertEquals('HTTP/1.1 403 Forbidden',$this->response->status,'Wrong statuscode received. Full response body: ' .$this->response->body);
+
+ }
+
+ /**
+ * @depends testMKCOLIncorrectResourceType2
+ */
+ function testMKCOLSuccess() {
+
+ $serverVars = array(
+ 'REQUEST_URI' => '/testcol',
+ 'REQUEST_METHOD' => 'MKCOL',
+ 'HTTP_CONTENT_TYPE' => 'application/xml',
+ );
+
+ $request = new HTTP\Request($serverVars);
+ $request->setBody('<?xml version="1.0"?>
+<mkcol xmlns="DAV:">
+ <set>
+ <prop>
+ <resourcetype><collection /></resourcetype>
+ </prop>
+ </set>
+</mkcol>');
+ $this->server->httpRequest = ($request);
+ $this->server->exec();
+
+ $this->assertEquals(array(
+ 'Content-Length' => '0',
+ ),$this->response->headers);
+
+ $this->assertEquals('HTTP/1.1 201 Created',$this->response->status,'Wrong statuscode received. Full response body: ' .$this->response->body);
+
+ }
+
+ /**
+ * @depends testMKCOLIncorrectResourceType2
+ */
+ function testMKCOLWhiteSpaceResourceType() {
+
+ $serverVars = array(
+ 'REQUEST_URI' => '/testcol',
+ 'REQUEST_METHOD' => 'MKCOL',
+ 'HTTP_CONTENT_TYPE' => 'application/xml',
+ );
+
+ $request = new HTTP\Request($serverVars);
+ $request->setBody('<?xml version="1.0"?>
+<mkcol xmlns="DAV:">
+ <set>
+ <prop>
+ <resourcetype>
+ <collection />
+ </resourcetype>
+ </prop>
+ </set>
+</mkcol>');
+ $this->server->httpRequest = ($request);
+ $this->server->exec();
+
+ $this->assertEquals(array(
+ 'Content-Length' => '0',
+ ),$this->response->headers);
+
+ $this->assertEquals('HTTP/1.1 201 Created',$this->response->status,'Wrong statuscode received. Full response body: ' .$this->response->body);
+
+ }
+
+ /**
+ * @depends testMKCOLIncorrectResourceType2
+ */
+ function testMKCOLNoParent() {
+
+ $serverVars = array(
+ 'REQUEST_URI' => '/testnoparent/409me',
+ 'REQUEST_METHOD' => 'MKCOL',
+ );
+
+ $request = new HTTP\Request($serverVars);
+ $request->setBody('');
+
+ $this->server->httpRequest = ($request);
+ $this->server->exec();
+
+ $this->assertEquals(array(
+ 'Content-Type' => 'application/xml; charset=utf-8',
+ ),$this->response->headers);
+
+ $this->assertEquals('HTTP/1.1 409 Conflict',$this->response->status,'Wrong statuscode received. Full response body: ' .$this->response->body);
+
+ }
+
+ /**
+ * @depends testMKCOLIncorrectResourceType2
+ */
+ function testMKCOLParentIsNoCollection() {
+
+ $serverVars = array(
+ 'REQUEST_URI' => '/test.txt/409me',
+ 'REQUEST_METHOD' => 'MKCOL',
+ );
+
+ $request = new HTTP\Request($serverVars);
+ $request->setBody('');
+
+ $this->server->httpRequest = ($request);
+ $this->server->exec();
+
+ $this->assertEquals(array(
+ 'Content-Type' => 'application/xml; charset=utf-8',
+ ),$this->response->headers);
+
+ $this->assertEquals('HTTP/1.1 409 Conflict',$this->response->status,'Wrong statuscode received. Full response body: ' .$this->response->body);
+
+ }
+
+ /**
+ * @depends testMKCOLIncorrectResourceType2
+ */
+ function testMKCOLAlreadyExists() {
+
+ $serverVars = array(
+ 'REQUEST_URI' => '/test.txt',
+ 'REQUEST_METHOD' => 'MKCOL',
+ );
+
+ $request = new HTTP\Request($serverVars);
+ $request->setBody('');
+
+ $this->server->httpRequest = ($request);
+ $this->server->exec();
+
+ $this->assertEquals(array(
+ 'Content-Type' => 'application/xml; charset=utf-8',
+ 'Allow' => 'OPTIONS, GET, HEAD, DELETE, PROPFIND, PUT, PROPPATCH, COPY, MOVE, REPORT',
+ ),$this->response->headers);
+
+ $this->assertEquals('HTTP/1.1 405 Method Not Allowed',$this->response->status,'Wrong statuscode received. Full response body: ' .$this->response->body);
+
+ }
+
+ /**
+ * @depends testMKCOLSuccess
+ * @depends testMKCOLAlreadyExists
+ */
+ function testMKCOLAndProps() {
+
+ $serverVars = array(
+ 'REQUEST_URI' => '/testcol',
+ 'REQUEST_METHOD' => 'MKCOL',
+ 'HTTP_CONTENT_TYPE' => 'application/xml',
+ );
+
+ $request = new HTTP\Request($serverVars);
+ $request->setBody('<?xml version="1.0"?>
+<mkcol xmlns="DAV:">
+ <set>
+ <prop>
+ <resourcetype><collection /></resourcetype>
+ <displayname>my new collection</displayname>
+ </prop>
+ </set>
+</mkcol>');
+ $this->server->httpRequest = ($request);
+ $this->server->exec();
+
+ $this->assertEquals('HTTP/1.1 207 Multi-Status',$this->response->status,'Wrong statuscode received. Full response body: ' .$this->response->body);
+
+ $this->assertEquals(array(
+ 'Content-Type' => 'application/xml; charset=utf-8',
+ ),$this->response->headers);
+
+
+
+ }
+
+}
diff --git a/vendor/sabre/dav/tests/Sabre/DAV/ServerPluginTest.php b/vendor/sabre/dav/tests/Sabre/DAV/ServerPluginTest.php
new file mode 100644
index 000000000..8f1451b49
--- /dev/null
+++ b/vendor/sabre/dav/tests/Sabre/DAV/ServerPluginTest.php
@@ -0,0 +1,98 @@
+<?php
+
+namespace Sabre\DAV;
+use Sabre\HTTP;
+
+require_once 'Sabre/DAV/AbstractServer.php';
+require_once 'Sabre/DAV/TestPlugin.php';
+
+class ServerPluginTest extends AbstractServer {
+
+ /**
+ * @var Sabre\DAV\TestPlugin
+ */
+ protected $testPlugin;
+
+ function setUp() {
+
+ parent::setUp();
+
+ $testPlugin = new TestPlugin();
+ $this->server->addPlugin($testPlugin);
+ $this->testPlugin = $testPlugin;
+
+ }
+
+ /**
+ * @covers \Sabre\DAV\ServerPlugin
+ */
+ function testBaseClass() {
+
+ $p = new ServerPluginMock();
+ $this->assertEquals(array(),$p->getFeatures());
+ $this->assertEquals(array(),$p->getHTTPMethods(''));
+
+ }
+
+ function testOptions() {
+
+ $serverVars = array(
+ 'REQUEST_URI' => '/',
+ 'REQUEST_METHOD' => 'OPTIONS',
+ );
+
+ $request = new HTTP\Request($serverVars);
+ $this->server->httpRequest = ($request);
+ $this->server->exec();
+
+ $this->assertEquals(array(
+ 'DAV' => '1, 3, extended-mkcol, drinking',
+ 'MS-Author-Via' => 'DAV',
+ 'Allow' => 'OPTIONS, GET, HEAD, DELETE, PROPFIND, PUT, PROPPATCH, COPY, MOVE, REPORT, BEER, WINE',
+ 'Accept-Ranges' => 'bytes',
+ 'Content-Length' => '0',
+ 'X-Sabre-Version' => Version::VERSION,
+ ),$this->response->headers);
+
+ $this->assertEquals('HTTP/1.1 200 OK',$this->response->status);
+ $this->assertEquals('', $this->response->body);
+ $this->assertEquals('OPTIONS',$this->testPlugin->beforeMethod);
+
+
+ }
+
+ function testGetPlugin() {
+
+ $this->assertEquals($this->testPlugin,$this->server->getPlugin(get_class($this->testPlugin)));
+
+ }
+
+ function testUnknownPlugin() {
+
+ $this->assertNull($this->server->getPlugin('SomeRandomClassName'));
+
+ }
+
+ function testGetSupportedReportSet() {
+
+ $this->assertEquals(array(), $this->testPlugin->getSupportedReportSet('/'));
+
+ }
+
+ function testGetPlugins() {
+
+ $this->assertEquals(
+ array(get_class($this->testPlugin) => $this->testPlugin),
+ $this->server->getPlugins()
+ );
+
+ }
+
+
+}
+
+class ServerPluginMock extends ServerPlugin {
+
+ function initialize(Server $s) { }
+
+}
diff --git a/vendor/sabre/dav/tests/Sabre/DAV/ServerPreconditionTest.php b/vendor/sabre/dav/tests/Sabre/DAV/ServerPreconditionTest.php
new file mode 100644
index 000000000..ea09852a7
--- /dev/null
+++ b/vendor/sabre/dav/tests/Sabre/DAV/ServerPreconditionTest.php
@@ -0,0 +1,395 @@
+<?php
+
+namespace Sabre\DAV;
+
+use Sabre\HTTP;
+
+require_once 'Sabre/HTTP/ResponseMock.php';
+
+class ServerPreconditionsTest extends \PHPUnit_Framework_TestCase {
+
+ /**
+ * @covers Sabre\DAV\Server::checkPreconditions
+ * @expectedException Sabre\DAV\Exception\PreconditionFailed
+ */
+ function testIfMatchNoNode() {
+
+ $root = new SimpleCollection('root',array(new ServerPreconditionsNode()));
+ $server = new Server($root);
+ $httpRequest = new HTTP\Request(array(
+ 'HTTP_IF_MATCH' => '*',
+ 'REQUEST_URI' => '/bar'
+ ));
+ $server->httpRequest = $httpRequest;
+
+ $server->checkPreconditions();
+
+ }
+
+ /**
+ * @covers \Sabre\DAV\Server::checkPreconditions
+ */
+ function testIfMatchHasNode() {
+
+ $root = new SimpleCollection('root',array(new ServerPreconditionsNode()));
+ $server = new Server($root);
+ $httpRequest = new HTTP\Request(array(
+ 'HTTP_IF_MATCH' => '*',
+ 'REQUEST_URI' => '/foo'
+ ));
+ $server->httpRequest = $httpRequest;
+
+ $this->assertTrue($server->checkPreconditions());
+
+ }
+
+ /**
+ * @covers \Sabre\DAV\Server::checkPreconditions
+ * @expectedException Sabre\DAV\Exception\PreconditionFailed
+ */
+ function testIfMatchWrongEtag() {
+
+ $root = new SimpleCollection('root',array(new ServerPreconditionsNode()));
+ $server = new Server($root);
+ $httpRequest = new HTTP\Request(array(
+ 'HTTP_IF_MATCH' => '1234',
+ 'REQUEST_URI' => '/foo'
+ ));
+ $server->httpRequest = $httpRequest;
+
+ $server->checkPreconditions();
+
+ }
+
+ /**
+ * @covers \Sabre\DAV\Server::checkPreconditions
+ */
+ function testIfMatchCorrectEtag() {
+
+ $root = new SimpleCollection('root',array(new ServerPreconditionsNode()));
+ $server = new Server($root);
+ $httpRequest = new HTTP\Request(array(
+ 'HTTP_IF_MATCH' => '"abc123"',
+ 'REQUEST_URI' => '/foo'
+ ));
+ $server->httpRequest = $httpRequest;
+
+ $this->assertTrue($server->checkPreconditions());
+
+ }
+
+ /**
+ * Evolution sometimes uses \" instead of " for If-Match headers.
+ *
+ * @covers \Sabre\DAV\Server::checkPreconditions
+ * @depends testIfMatchCorrectEtag
+ */
+ function testIfMatchEvolutionEtag() {
+
+ $root = new SimpleCollection('root',array(new ServerPreconditionsNode()));
+ $server = new Server($root);
+ $httpRequest = new HTTP\Request(array(
+ 'HTTP_IF_MATCH' => '\\"abc123\\"',
+ 'REQUEST_URI' => '/foo'
+ ));
+ $server->httpRequest = $httpRequest;
+
+ $this->assertTrue($server->checkPreconditions());
+
+ }
+
+ /**
+ * @covers \Sabre\DAV\Server::checkPreconditions
+ */
+ function testIfMatchMultiple() {
+
+ $root = new SimpleCollection('root',array(new ServerPreconditionsNode()));
+ $server = new Server($root);
+ $httpRequest = new HTTP\Request(array(
+ 'HTTP_IF_MATCH' => '"hellothere", "abc123"',
+ 'REQUEST_URI' => '/foo'
+ ));
+ $server->httpRequest = $httpRequest;
+
+ $this->assertTrue($server->checkPreconditions());
+
+ }
+
+ /**
+ * @covers \Sabre\DAV\Server::checkPreconditions
+ */
+ function testIfNoneMatchNoNode() {
+
+ $root = new SimpleCollection('root',array(new ServerPreconditionsNode()));
+ $server = new Server($root);
+ $httpRequest = new HTTP\Request(array(
+ 'HTTP_IF_NONE_MATCH' => '*',
+ 'REQUEST_URI' => '/bar'
+ ));
+ $server->httpRequest = $httpRequest;
+
+ $this->assertTrue($server->checkPreconditions());
+
+ }
+
+ /**
+ * @covers \Sabre\DAV\Server::checkPreconditions
+ * @expectedException Sabre\DAV\Exception\PreconditionFailed
+ */
+ function testIfNoneMatchHasNode() {
+
+ $root = new SimpleCollection('root',array(new ServerPreconditionsNode()));
+ $server = new Server($root);
+ $httpRequest = new HTTP\Request(array(
+ 'HTTP_IF_NONE_MATCH' => '*',
+ 'REQUEST_URI' => '/foo'
+ ));
+ $server->httpRequest = $httpRequest;
+
+ $server->checkPreconditions();
+
+ }
+
+ /**
+ * @covers \Sabre\DAV\Server::checkPreconditions
+ */
+ function testIfNoneMatchWrongEtag() {
+
+ $root = new SimpleCollection('root',array(new ServerPreconditionsNode()));
+ $server = new Server($root);
+ $httpRequest = new HTTP\Request(array(
+ 'HTTP_IF_NONE_MATCH' => '"1234"',
+ 'REQUEST_URI' => '/foo'
+ ));
+ $server->httpRequest = $httpRequest;
+
+ $this->assertTrue($server->checkPreconditions());
+
+ }
+
+ /**
+ * @covers \Sabre\DAV\Server::checkPreconditions
+ */
+ function testIfNoneMatchWrongEtagMultiple() {
+
+ $root = new SimpleCollection('root',array(new ServerPreconditionsNode()));
+ $server = new Server($root);
+ $httpRequest = new HTTP\Request(array(
+ 'HTTP_IF_NONE_MATCH' => '"1234", "5678"',
+ 'REQUEST_URI' => '/foo'
+ ));
+ $server->httpRequest = $httpRequest;
+
+ $this->assertTrue($server->checkPreconditions());
+
+ }
+
+ /**
+ * @covers \Sabre\DAV\Server::checkPreconditions
+ * @expectedException Sabre\DAV\Exception\PreconditionFailed
+ */
+ public function testIfNoneMatchCorrectEtag() {
+
+ $root = new SimpleCollection('root',array(new ServerPreconditionsNode()));
+ $server = new Server($root);
+ $httpRequest = new HTTP\Request(array(
+ 'HTTP_IF_NONE_MATCH' => '"abc123"',
+ 'REQUEST_URI' => '/foo'
+ ));
+ $server->httpRequest = $httpRequest;
+
+ $server->checkPreconditions();
+
+ }
+
+ /**
+ * @covers \Sabre\DAV\Server::checkPreconditions
+ * @expectedException Sabre\DAV\Exception\PreconditionFailed
+ */
+ public function testIfNoneMatchCorrectEtagMultiple() {
+
+ $root = new SimpleCollection('root',array(new ServerPreconditionsNode()));
+ $server = new Server($root);
+ $httpRequest = new HTTP\Request(array(
+ 'HTTP_IF_NONE_MATCH' => '"1234", "abc123"',
+ 'REQUEST_URI' => '/foo'
+ ));
+ $server->httpRequest = $httpRequest;
+
+ $server->checkPreconditions();
+
+ }
+
+ /**
+ * @covers \Sabre\DAV\Server::checkPreconditions
+ */
+ public function testIfNoneMatchCorrectEtagAsGet() {
+
+ $root = new SimpleCollection('root',array(new ServerPreconditionsNode()));
+ $server = new Server($root);
+ $httpRequest = new HTTP\Request(array(
+ 'HTTP_IF_NONE_MATCH' => '"abc123"',
+ 'REQUEST_URI' => '/foo'
+ ));
+ $server->httpRequest = $httpRequest;
+ $server->httpResponse = new HTTP\ResponseMock();
+
+ $this->assertFalse($server->checkPreconditions(true));
+ $this->assertEquals('HTTP/1.1 304 Not Modified',$server->httpResponse->status);
+
+ }
+
+ /**
+ * @covers \Sabre\DAV\Server::checkPreconditions
+ */
+ public function testIfModifiedSinceUnModified() {
+
+ $root = new SimpleCollection('root',array(new ServerPreconditionsNode()));
+ $server = new Server($root);
+ $httpRequest = new HTTP\Request(array(
+ 'HTTP_IF_MODIFIED_SINCE' => 'Sun, 06 Nov 1994 08:49:37 GMT',
+ 'REQUEST_URI' => '/foo'
+ ));
+ $server->httpRequest = $httpRequest;
+ $server->httpResponse = new HTTP\ResponseMock();
+ $this->assertFalse($server->checkPreconditions());
+
+ $this->assertEquals('HTTP/1.1 304 Not Modified',$server->httpResponse->status);
+ $this->assertEquals(array(
+ 'Last-Modified' => 'Sat, 06 Apr 1985 23:30:00 GMT',
+ ), $server->httpResponse->headers);
+
+ }
+
+
+ /**
+ * @covers \Sabre\DAV\Server::checkPreconditions
+ */
+ public function testIfModifiedSinceModified() {
+
+ $root = new SimpleCollection('root',array(new ServerPreconditionsNode()));
+ $server = new Server($root);
+ $httpRequest = new HTTP\Request(array(
+ 'HTTP_IF_MODIFIED_SINCE' => 'Tue, 06 Nov 1984 08:49:37 GMT',
+ 'REQUEST_URI' => '/foo'
+ ));
+ $server->httpRequest = $httpRequest;
+ $server->httpResponse = new HTTP\ResponseMock();
+ $this->assertTrue($server->checkPreconditions());
+
+ }
+
+ /**
+ * @covers \Sabre\DAV\Server::checkPreconditions
+ */
+ public function testIfModifiedSinceInvalidDate() {
+
+ $root = new SimpleCollection('root',array(new ServerPreconditionsNode()));
+ $server = new Server($root);
+ $httpRequest = new HTTP\Request(array(
+ 'HTTP_IF_MODIFIED_SINCE' => 'Your mother',
+ 'REQUEST_URI' => '/foo'
+ ));
+ $server->httpRequest = $httpRequest;
+ $server->httpResponse = new HTTP\ResponseMock();
+
+ // Invalid dates must be ignored, so this should return true
+ $this->assertTrue($server->checkPreconditions());
+
+ }
+
+ /**
+ * @covers \Sabre\DAV\Server::checkPreconditions
+ */
+ public function testIfModifiedSinceInvalidDate2() {
+
+ $root = new SimpleCollection('root',array(new ServerPreconditionsNode()));
+ $server = new Server($root);
+ $httpRequest = new HTTP\Request(array(
+ 'HTTP_IF_MODIFIED_SINCE' => 'Sun, 06 Nov 1994 08:49:37 EST',
+ 'REQUEST_URI' => '/foo'
+ ));
+ $server->httpRequest = $httpRequest;
+ $server->httpResponse = new HTTP\ResponseMock();
+ $this->assertTrue($server->checkPreconditions());
+
+ }
+
+
+ /**
+ * @covers \Sabre\DAV\Server::checkPreconditions
+ */
+ public function testIfUnmodifiedSinceUnModified() {
+
+ $root = new SimpleCollection('root',array(new ServerPreconditionsNode()));
+ $server = new Server($root);
+ $httpRequest = new HTTP\Request(array(
+ 'HTTP_IF_UNMODIFIED_SINCE' => 'Sun, 06 Nov 1994 08:49:37 GMT',
+ 'REQUEST_URI' => '/foo'
+ ));
+ $server->httpRequest = $httpRequest;
+ $this->assertTrue($server->checkPreconditions());
+
+ }
+
+
+ /**
+ * @covers \Sabre\DAV\Server::checkPreconditions
+ * @expectedException Sabre\DAV\Exception\PreconditionFailed
+ */
+ public function testIfUnmodifiedSinceModified() {
+
+ $root = new SimpleCollection('root',array(new ServerPreconditionsNode()));
+ $server = new Server($root);
+ $httpRequest = new HTTP\Request(array(
+ 'HTTP_IF_UNMODIFIED_SINCE' => 'Tue, 06 Nov 1984 08:49:37 GMT',
+ 'REQUEST_URI' => '/foo'
+ ));
+ $server->httpRequest = $httpRequest;
+ $server->httpResponse = new HTTP\ResponseMock();
+ $server->checkPreconditions();
+
+ }
+
+ /**
+ * @covers \Sabre\DAV\Server::checkPreconditions
+ */
+ public function testIfUnmodifiedSinceInvalidDate() {
+
+ $root = new SimpleCollection('root',array(new ServerPreconditionsNode()));
+ $server = new Server($root);
+ $httpRequest = new HTTP\Request(array(
+ 'HTTP_IF_UNMODIFIED_SINCE' => 'Sun, 06 Nov 1984 08:49:37 CET',
+ 'REQUEST_URI' => '/foo'
+ ));
+ $server->httpRequest = $httpRequest;
+ $server->httpResponse = new HTTP\ResponseMock();
+ $this->assertTrue($server->checkPreconditions());
+
+ }
+
+
+}
+
+class ServerPreconditionsNode extends File {
+
+ function getETag() {
+
+ return '"abc123"';
+
+ }
+
+ function getLastModified() {
+
+ /* my birthday & time, I believe */
+ return strtotime('1985-04-07 01:30 +02:00');
+
+ }
+
+ function getName() {
+
+ return 'foo';
+
+ }
+
+}
diff --git a/vendor/sabre/dav/tests/Sabre/DAV/ServerPropsTest.php b/vendor/sabre/dav/tests/Sabre/DAV/ServerPropsTest.php
new file mode 100644
index 000000000..859a91070
--- /dev/null
+++ b/vendor/sabre/dav/tests/Sabre/DAV/ServerPropsTest.php
@@ -0,0 +1,413 @@
+<?php
+
+namespace Sabre\DAV;
+use Sabre\HTTP;
+
+require_once 'Sabre/HTTP/ResponseMock.php';
+require_once 'Sabre/DAV/AbstractServer.php';
+
+class ServerPropsTest extends AbstractServer {
+
+ protected function getRootNode() {
+
+ return new FSExt\Directory(SABRE_TEMPDIR);
+
+ }
+
+ function setUp() {
+
+ if (file_exists(SABRE_TEMPDIR.'../.sabredav')) unlink(SABRE_TEMPDIR.'../.sabredav');
+ parent::setUp();
+ file_put_contents(SABRE_TEMPDIR . '/test2.txt', 'Test contents2');
+ mkdir(SABRE_TEMPDIR . '/col');
+ file_put_contents(SABRE_TEMPDIR . 'col/test.txt', 'Test contents');
+ $this->server->addPlugin(new Locks\Plugin(new Locks\Backend\File(SABRE_TEMPDIR . '/.locksdb')));
+
+ }
+
+ function tearDown() {
+
+ parent::tearDown();
+ if (file_exists(SABRE_TEMPDIR.'../.locksdb')) unlink(SABRE_TEMPDIR.'../.locksdb');
+
+ }
+
+ private function sendRequest($body) {
+
+ $serverVars = array(
+ 'REQUEST_URI' => '/',
+ 'REQUEST_METHOD' => 'PROPFIND',
+ 'HTTP_DEPTH' => '0',
+ );
+
+ $request = new HTTP\Request($serverVars);
+ $request->setBody($body);
+
+ $this->server->httpRequest = ($request);
+ $this->server->exec();
+
+ }
+
+ public function testPropFindEmptyBody() {
+
+ $hasFired = false;
+
+ $self = $this;
+ // Also testing the beforeGetPropertiesForPath event.
+ $this->server->subscribeEvent('beforeGetPropertiesForPath', function($path, $properties, $depth) use ($self, &$hasFired) {
+
+ $hasFired = true;
+ $self->assertEquals('', $path);
+ $self->assertEquals(array(), $properties);
+ $self->assertEquals(0, $depth);
+
+ });
+
+ $this->sendRequest("");
+
+ $this->assertTrue($hasFired);
+
+ $this->assertEquals('HTTP/1.1 207 Multi-Status',$this->response->status);
+
+ $this->assertEquals(array(
+ 'Content-Type' => 'application/xml; charset=utf-8',
+ 'DAV' => '1, 3, extended-mkcol, 2',
+ 'Vary' => 'Brief,Prefer',
+ ),
+ $this->response->headers
+ );
+
+ $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('/',(string)$data,'href element should have been /');
+
+ $data = $xml->xpath('/d:multistatus/d:response/d:propstat/d:prop/d:resourcetype');
+ $this->assertEquals(1,count($data));
+
+ }
+
+ function testSupportedLocks() {
+
+ $xml = '<?xml version="1.0"?>
+<d:propfind xmlns:d="DAV:">
+ <d:prop>
+ <d:supportedlock />
+ </d:prop>
+</d:propfind>';
+
+ $this->sendRequest($xml);
+
+ $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');
+
+ $data = $xml->xpath('/d:multistatus/d:response/d:propstat/d:prop/d:supportedlock/d:lockentry');
+ $this->assertEquals(2,count($data),'We expected two \'d:lockentry\' tags');
+
+ $data = $xml->xpath('/d:multistatus/d:response/d:propstat/d:prop/d:supportedlock/d:lockentry/d:lockscope');
+ $this->assertEquals(2,count($data),'We expected two \'d:lockscope\' tags');
+
+ $data = $xml->xpath('/d:multistatus/d:response/d:propstat/d:prop/d:supportedlock/d:lockentry/d:locktype');
+ $this->assertEquals(2,count($data),'We expected two \'d:locktype\' tags');
+
+ $data = $xml->xpath('/d:multistatus/d:response/d:propstat/d:prop/d:supportedlock/d:lockentry/d:lockscope/d:shared');
+ $this->assertEquals(1,count($data),'We expected a \'d:shared\' tag');
+
+ $data = $xml->xpath('/d:multistatus/d:response/d:propstat/d:prop/d:supportedlock/d:lockentry/d:lockscope/d:exclusive');
+ $this->assertEquals(1,count($data),'We expected a \'d:exclusive\' tag');
+
+ $data = $xml->xpath('/d:multistatus/d:response/d:propstat/d:prop/d:supportedlock/d:lockentry/d:locktype/d:write');
+ $this->assertEquals(2,count($data),'We expected two \'d:write\' tags');
+ }
+
+ function testLockDiscovery() {
+
+ $xml = '<?xml version="1.0"?>
+<d:propfind xmlns:d="DAV:">
+ <d:prop>
+ <d:lockdiscovery />
+ </d:prop>
+</d:propfind>';
+
+ $this->sendRequest($xml);
+
+ $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');
+
+ $data = $xml->xpath('/d:multistatus/d:response/d:propstat/d:prop/d:lockdiscovery');
+ $this->assertEquals(1,count($data),'We expected a \'d:lockdiscovery\' tag');
+
+ }
+
+ function testUnknownProperty() {
+
+ $xml = '<?xml version="1.0"?>
+<d:propfind xmlns:d="DAV:">
+ <d:prop>
+ <d:macaroni />
+ </d:prop>
+</d:propfind>';
+
+ $this->sendRequest($xml);
+ $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');
+ $pathTests = array(
+ '/d:multistatus',
+ '/d:multistatus/d:response',
+ '/d:multistatus/d:response/d:propstat',
+ '/d:multistatus/d:response/d:propstat/d:status',
+ '/d:multistatus/d:response/d:propstat/d:prop',
+ '/d:multistatus/d:response/d:propstat/d:prop/d:macaroni',
+ );
+ foreach($pathTests as $test) {
+ $this->assertTrue(count($xml->xpath($test))==true,'We expected the ' . $test . ' element to appear in the response, we got: ' . $body);
+ }
+
+ $val = $xml->xpath('/d:multistatus/d:response/d:propstat/d:status');
+ $this->assertEquals(1,count($val),$body);
+ $this->assertEquals('HTTP/1.1 404 Not Found',(string)$val[0]);
+
+ }
+
+ /**
+ * @covers Sabre\DAV\Server::parsePropPatchRequest
+ */
+ public function testParsePropPatchRequest() {
+
+ $body = '<?xml version="1.0"?>
+<d:propertyupdate xmlns:d="DAV:" xmlns:s="http://sabredav.org/NS/test">
+ <d:set><d:prop><s:someprop>somevalue</s:someprop></d:prop></d:set>
+ <d:remove><d:prop><s:someprop2 /></d:prop></d:remove>
+ <d:set><d:prop><s:someprop3>removeme</s:someprop3></d:prop></d:set>
+ <d:remove><d:prop><s:someprop3 /></d:prop></d:remove>
+</d:propertyupdate>';
+
+ $result = $this->server->parsePropPatchRequest($body);
+ $this->assertEquals(array(
+ '{http://sabredav.org/NS/test}someprop' => 'somevalue',
+ '{http://sabredav.org/NS/test}someprop2' => null,
+ '{http://sabredav.org/NS/test}someprop3' => null,
+ ), $result);
+
+ }
+
+ /**
+ * @covers Sabre\DAV\Server::updateProperties
+ */
+ public function testUpdateProperties() {
+
+ $props = array(
+ '{http://sabredav.org/NS/test}someprop' => 'somevalue',
+ );
+
+ $result = $this->server->updateProperties('/test2.txt',$props);
+
+ $this->assertEquals(array(
+ '200' => array('{http://sabredav.org/NS/test}someprop' => null),
+ 'href' => '/test2.txt',
+ ), $result);
+
+ }
+
+ /**
+ * @covers Sabre\DAV\Server::updateProperties
+ * @depends testUpdateProperties
+ */
+ public function testUpdatePropertiesProtected() {
+
+ $props = array(
+ '{http://sabredav.org/NS/test}someprop' => 'somevalue',
+ '{DAV:}getcontentlength' => 50,
+ );
+
+ $result = $this->server->updateProperties('/test2.txt',$props);
+
+ $this->assertEquals(array(
+ '424' => array('{http://sabredav.org/NS/test}someprop' => null),
+ '403' => array('{DAV:}getcontentlength' => null),
+ 'href' => '/test2.txt',
+ ), $result);
+
+ }
+
+ /**
+ * @covers Sabre\DAV\Server::updateProperties
+ * @depends testUpdateProperties
+ */
+ public function testUpdatePropertiesFail1() {
+
+ $dir = new PropTestDirMock('updatepropsfalse');
+ $objectTree = new ObjectTree($dir);
+ $this->server->tree = $objectTree;
+
+ $props = array(
+ '{http://sabredav.org/NS/test}someprop' => 'somevalue',
+ );
+
+ $result = $this->server->updateProperties('/',$props);
+
+ $this->assertEquals(array(
+ '403' => array('{http://sabredav.org/NS/test}someprop' => null),
+ 'href' => '/',
+ ), $result);
+
+ }
+
+ /**
+ * @covers Sabre\DAV\Server::updateProperties
+ * @depends testUpdateProperties
+ */
+ public function testUpdatePropertiesFail2() {
+
+ $dir = new PropTestDirMock('updatepropsarray');
+ $objectTree = new ObjectTree($dir);
+ $this->server->tree = $objectTree;
+
+ $props = array(
+ '{http://sabredav.org/NS/test}someprop' => 'somevalue',
+ );
+
+ $result = $this->server->updateProperties('/',$props);
+
+ $this->assertEquals(array(
+ '402' => array('{http://sabredav.org/NS/test}someprop' => null),
+ 'href' => '/',
+ ), $result);
+
+ }
+
+ /**
+ * @covers Sabre\DAV\Server::updateProperties
+ * @depends testUpdateProperties
+ * @expectedException Sabre\DAV\Exception
+ */
+ public function testUpdatePropertiesFail3() {
+
+ $dir = new PropTestDirMock('updatepropsobj');
+ $objectTree = new ObjectTree($dir);
+ $this->server->tree = $objectTree;
+
+ $props = array(
+ '{http://sabredav.org/NS/test}someprop' => 'somevalue',
+ );
+
+ $result = $this->server->updateProperties('/',$props);
+
+ }
+
+ /**
+ * @depends testParsePropPatchRequest
+ * @depends testUpdateProperties
+ * @covers Sabre\DAV\Server::httpPropPatch
+ */
+ public function testPropPatch() {
+
+ $serverVars = array(
+ 'REQUEST_URI' => '/',
+ 'REQUEST_METHOD' => 'PROPPATCH',
+ );
+
+ $body = '<?xml version="1.0"?>
+<d:propertyupdate xmlns:d="DAV:" xmlns:s="http://www.rooftopsolutions.nl/testnamespace">
+ <d:set><d:prop><s:someprop>somevalue</s:someprop></d:prop></d:set>
+</d:propertyupdate>';
+
+ $request = new HTTP\Request($serverVars);
+ $request->setBody($body);
+
+ $this->server->httpRequest = ($request);
+ $this->server->exec();
+
+ $this->assertEquals(array(
+ 'Content-Type' => 'application/xml; charset=utf-8',
+ 'Vary' => 'Brief,Prefer',
+ ),
+ $this->response->headers
+ );
+
+ $this->assertEquals('HTTP/1.1 207 Multi-Status',$this->response->status,'We got the wrong status. Full XML response: ' . $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');
+ $xml->registerXPathNamespace('bla','http://www.rooftopsolutions.nl/testnamespace');
+
+ $data = $xml->xpath('/d:multistatus/d:response/d:propstat/d:prop');
+ $this->assertEquals(1,count($data),'We expected one \'d:prop\' element. Response body: ' . $body);
+
+ $data = $xml->xpath('//bla:someprop');
+ $this->assertEquals(1,count($data),'We expected one \'s:someprop\' element. Response body: ' . $body);
+
+ $data = $xml->xpath('/d:multistatus/d:response/d:propstat/d:status');
+ $this->assertEquals(1,count($data),'We expected one \'s:status\' element. Response body: ' . $body);
+
+ $this->assertEquals('HTTP/1.1 200 OK',(string)$data[0]);
+
+ }
+
+ /**
+ * @depends testPropPatch
+ */
+ public function testPropPatchAndFetch() {
+
+ $this->testPropPatch();
+ $xml = '<?xml version="1.0"?>
+<d:propfind xmlns:d="DAV:" xmlns:s="http://www.rooftopsolutions.nl/testnamespace">
+ <d:prop>
+ <s:someprop />
+ </d:prop>
+</d:propfind>';
+
+ $this->sendRequest($xml);
+
+ $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');
+ $xml->registerXPathNamespace('bla','http://www.rooftopsolutions.nl/testnamespace');
+
+ $xpath='//bla:someprop';
+ $result = $xml->xpath($xpath);
+ $this->assertEquals(1,count($result),'We couldn\'t find our new property in the response. Full response body:' . "\n" . $body);
+ $this->assertEquals('somevalue',(string)$result[0],'We couldn\'t find our new property in the response. Full response body:' . "\n" . $body);
+
+ }
+
+}
+
+class PropTestDirMock extends SimpleCollection implements IProperties {
+
+ public $type;
+
+ function __construct($type) {
+
+ $this->type =$type;
+ parent::__construct('root');
+
+ }
+
+ function updateProperties($updateProperties) {
+
+ switch($this->type) {
+ case 'updatepropsfalse' : return false;
+ case 'updatepropsarray' :
+ $r = array(402 => array());
+ foreach($updateProperties as $k=>$v) $r[402][$k] = null;
+ return $r;
+ case 'updatepropsobj' :
+ return new \STDClass();
+ }
+
+ }
+
+ function getProperties($requestedPropeties) {
+
+ return array();
+
+ }
+
+}
diff --git a/vendor/sabre/dav/tests/Sabre/DAV/ServerRangeTest.php b/vendor/sabre/dav/tests/Sabre/DAV/ServerRangeTest.php
new file mode 100644
index 000000000..a06fcb0be
--- /dev/null
+++ b/vendor/sabre/dav/tests/Sabre/DAV/ServerRangeTest.php
@@ -0,0 +1,274 @@
+<?php
+
+namespace Sabre\DAV;
+use Sabre\HTTP;
+
+require_once 'Sabre/DAV/AbstractServer.php';
+
+class ServerRangeTest extends AbstractServer{
+
+ protected function getRootNode() {
+
+ return new FSExt\Directory(SABRE_TEMPDIR);
+
+ }
+
+ function testRange() {
+
+ $serverVars = array(
+ 'REQUEST_URI' => '/test.txt',
+ 'REQUEST_METHOD' => 'GET',
+ 'HTTP_RANGE' => 'bytes=2-5',
+ );
+
+ $request = new HTTP\Request($serverVars);
+ $this->server->httpRequest = ($request);
+ $this->server->exec();
+
+ $this->assertEquals(array(
+ 'Content-Type' => 'application/octet-stream',
+ 'Content-Length' => 4,
+ 'Content-Range' => 'bytes 2-5/13',
+ 'Last-Modified' => HTTP\Util::toHTTPDate(new \DateTime('@' . filemtime($this->tempDir . '/test.txt'))),
+ 'ETag' => '"' . md5(file_get_contents(SABRE_TEMPDIR . '/test.txt')). '"',
+ ),
+ $this->response->headers
+ );
+
+ $this->assertEquals('HTTP/1.1 206 Partial Content',$this->response->status);
+ $this->assertEquals('st c', stream_get_contents($this->response->body));
+
+ }
+
+ /**
+ * @depends testRange
+ */
+ function testStartRange() {
+
+ $serverVars = array(
+ 'REQUEST_URI' => '/test.txt',
+ 'REQUEST_METHOD' => 'GET',
+ 'HTTP_RANGE' => 'bytes=2-',
+ );
+
+ $request = new HTTP\Request($serverVars);
+ $this->server->httpRequest = ($request);
+ $this->server->exec();
+
+ $this->assertEquals(array(
+ 'Content-Type' => 'application/octet-stream',
+ 'Content-Length' => 11,
+ 'Content-Range' => 'bytes 2-12/13',
+ 'Last-Modified' => HTTP\Util::toHTTPDate(new \DateTime('@' . filemtime($this->tempDir . '/test.txt'))),
+ 'ETag' => '"' . md5(file_get_contents(SABRE_TEMPDIR . '/test.txt')) . '"',
+ ),
+ $this->response->headers
+ );
+
+ $this->assertEquals('HTTP/1.1 206 Partial Content',$this->response->status);
+ $this->assertEquals('st contents', stream_get_contents($this->response->body));
+
+ }
+
+ /**
+ * @depends testRange
+ */
+ function testEndRange() {
+
+ $serverVars = array(
+ 'REQUEST_URI' => '/test.txt',
+ 'REQUEST_METHOD' => 'GET',
+ 'HTTP_RANGE' => 'bytes=-8',
+ );
+
+ $request = new HTTP\Request($serverVars);
+ $this->server->httpRequest = ($request);
+ $this->server->exec();
+
+ $this->assertEquals(array(
+ 'Content-Type' => 'application/octet-stream',
+ 'Content-Length' => 8,
+ 'Content-Range' => 'bytes 5-12/13',
+ 'Last-Modified' => HTTP\Util::toHTTPDate(new \DateTime('@' . filemtime($this->tempDir . '/test.txt'))),
+ 'ETag' => '"' . md5(file_get_contents(SABRE_TEMPDIR . '/test.txt')). '"',
+ ),
+ $this->response->headers
+ );
+
+ $this->assertEquals('HTTP/1.1 206 Partial Content',$this->response->status);
+ $this->assertEquals('contents', stream_get_contents($this->response->body));
+
+ }
+
+ /**
+ * @depends testRange
+ */
+ function testTooHighRange() {
+
+ $serverVars = array(
+ 'REQUEST_URI' => '/test.txt',
+ 'REQUEST_METHOD' => 'GET',
+ 'HTTP_RANGE' => 'bytes=100-200',
+ );
+
+ $request = new HTTP\Request($serverVars);
+ $this->server->httpRequest = ($request);
+ $this->server->exec();
+
+ $this->assertEquals('HTTP/1.1 416 Requested Range Not Satisfiable',$this->response->status);
+
+ }
+
+ /**
+ * @depends testRange
+ */
+ function testCrazyRange() {
+
+ $serverVars = array(
+ 'REQUEST_URI' => '/test.txt',
+ 'REQUEST_METHOD' => 'GET',
+ 'HTTP_RANGE' => 'bytes=8-4',
+ );
+
+ $request = new HTTP\Request($serverVars);
+ $this->server->httpRequest = ($request);
+ $this->server->exec();
+
+ $this->assertEquals('HTTP/1.1 416 Requested Range Not Satisfiable',$this->response->status);
+
+ }
+
+ /**
+ * @depends testRange
+ * @covers \Sabre\DAV\Server::httpGet
+ */
+ function testIfRangeEtag() {
+
+ $node = $this->server->tree->getNodeForPath('test.txt');
+
+ $serverVars = array(
+ 'REQUEST_URI' => '/test.txt',
+ 'REQUEST_METHOD' => 'GET',
+ 'HTTP_RANGE' => 'bytes=2-5',
+ 'HTTP_IF_RANGE' => $node->getETag(),
+ );
+
+ $request = new HTTP\Request($serverVars);
+ $this->server->httpRequest = ($request);
+ $this->server->exec();
+
+ $this->assertEquals(array(
+ 'Content-Type' => 'application/octet-stream',
+ 'Content-Length' => 4,
+ 'Content-Range' => 'bytes 2-5/13',
+ 'Last-Modified' => HTTP\Util::toHTTPDate(new \DateTime('@' . filemtime($this->tempDir . '/test.txt'))),
+ 'ETag' => '"' . md5(file_get_contents(SABRE_TEMPDIR . '/test.txt')) . '"',
+ ),
+ $this->response->headers
+ );
+
+ $this->assertEquals('HTTP/1.1 206 Partial Content',$this->response->status);
+ $this->assertEquals('st c', stream_get_contents($this->response->body));
+
+ }
+
+ /**
+ * @depends testRange
+ * @covers \Sabre\DAV\Server::httpGet
+ */
+ function testIfRangeEtagIncorrect() {
+
+ $node = $this->server->tree->getNodeForPath('test.txt');
+
+ $serverVars = array(
+ 'REQUEST_URI' => '/test.txt',
+ 'REQUEST_METHOD' => 'GET',
+ 'HTTP_RANGE' => 'bytes=2-5',
+ 'HTTP_IF_RANGE' => $node->getETag() . 'blabla',
+ );
+
+ $request = new HTTP\Request($serverVars);
+ $this->server->httpRequest = ($request);
+ $this->server->exec();
+
+ $this->assertEquals(array(
+ 'Content-Type' => 'application/octet-stream',
+ 'Content-Length' => 13,
+ 'Last-Modified' => HTTP\Util::toHTTPDate(new \DateTime('@' . filemtime($this->tempDir . '/test.txt'))),
+ 'ETag' => '"' . md5(file_get_contents(SABRE_TEMPDIR . '/test.txt')) . '"',
+ ),
+ $this->response->headers
+ );
+
+ $this->assertEquals('HTTP/1.1 200 OK',$this->response->status);
+ $this->assertEquals('Test contents', stream_get_contents($this->response->body));
+
+ }
+
+ /**
+ * @depends testRange
+ * @covers \Sabre\DAV\Server::httpGet
+ */
+ function testIfRangeModificationDate() {
+
+ $node = $this->server->tree->getNodeForPath('test.txt');
+
+ $serverVars = array(
+ 'REQUEST_URI' => '/test.txt',
+ 'REQUEST_METHOD' => 'GET',
+ 'HTTP_RANGE' => 'bytes=2-5',
+ 'HTTP_IF_RANGE' => 'tomorrow',
+ );
+
+ $request = new HTTP\Request($serverVars);
+ $this->server->httpRequest = ($request);
+ $this->server->exec();
+
+ $this->assertEquals(array(
+ 'Content-Type' => 'application/octet-stream',
+ 'Content-Length' => 4,
+ 'Content-Range' => 'bytes 2-5/13',
+ 'Last-Modified' => HTTP\Util::toHTTPDate(new \DateTime('@' . filemtime($this->tempDir . '/test.txt'))),
+ 'ETag' => '"' . md5(file_get_contents(SABRE_TEMPDIR . '/test.txt')) . '"',
+ ),
+ $this->response->headers
+ );
+
+ $this->assertEquals('HTTP/1.1 206 Partial Content',$this->response->status);
+ $this->assertEquals('st c', stream_get_contents($this->response->body));
+
+ }
+
+ /**
+ * @depends testRange
+ * @covers \Sabre\DAV\Server::httpGet
+ */
+ function testIfRangeModificationDateModified() {
+
+ $node = $this->server->tree->getNodeForPath('test.txt');
+
+ $serverVars = array(
+ 'REQUEST_URI' => '/test.txt',
+ 'REQUEST_METHOD' => 'GET',
+ 'HTTP_RANGE' => 'bytes=2-5',
+ 'HTTP_IF_RANGE' => '-2 years',
+ );
+
+ $request = new HTTP\Request($serverVars);
+ $this->server->httpRequest = ($request);
+ $this->server->exec();
+
+ $this->assertEquals(array(
+ 'Content-Type' => 'application/octet-stream',
+ 'Content-Length' => 13,
+ 'Last-Modified' => HTTP\Util::toHTTPDate(new \DateTime('@' . filemtime($this->tempDir . '/test.txt'))),
+ 'ETag' => '"' . md5(file_get_contents(SABRE_TEMPDIR . '/test.txt')) . '"',
+ ),
+ $this->response->headers
+ );
+
+ $this->assertEquals('HTTP/1.1 200 OK',$this->response->status);
+ $this->assertEquals('Test contents', stream_get_contents($this->response->body));
+
+ }
+}
diff --git a/vendor/sabre/dav/tests/Sabre/DAV/ServerSimpleTest.php b/vendor/sabre/dav/tests/Sabre/DAV/ServerSimpleTest.php
new file mode 100644
index 000000000..afcd5c98f
--- /dev/null
+++ b/vendor/sabre/dav/tests/Sabre/DAV/ServerSimpleTest.php
@@ -0,0 +1,767 @@
+<?php
+
+namespace Sabre\DAV;
+
+use Sabre\HTTP;
+
+require_once 'Sabre/HTTP/ResponseMock.php';
+require_once 'Sabre/DAV/AbstractServer.php';
+require_once 'Sabre/DAV/Exception.php';
+
+class ServerSimpleTest extends AbstractServer{
+
+ function testConstructArray() {
+
+ $nodes = array(
+ new SimpleCollection('hello')
+ );
+
+ $server = new Server($nodes);
+ $this->assertEquals($nodes[0], $server->tree->getNodeForPath('hello'));
+
+ }
+
+ /**
+ * @expectedException Sabre\DAV\Exception
+ */
+ function testConstructIncorrectObj() {
+
+ $nodes = array(
+ new SimpleCollection('hello'),
+ new \STDClass(),
+ );
+
+ $server = new Server($nodes);
+
+ }
+
+ /**
+ * @expectedException Sabre\DAV\Exception
+ */
+ function testConstructInvalidArg() {
+
+ $server = new Server(1);
+
+ }
+
+ function testGet() {
+
+ $serverVars = array(
+ 'REQUEST_URI' => '/test.txt',
+ 'REQUEST_METHOD' => 'GET',
+ );
+
+ $request = new HTTP\Request($serverVars);
+ $this->server->httpRequest = ($request);
+ $this->server->exec();
+
+ $this->assertEquals(array(
+ 'Content-Type' => 'application/octet-stream',
+ 'Content-Length' => 13,
+ 'Last-Modified' => HTTP\Util::toHTTPDate(new \DateTime('@' . filemtime($this->tempDir . '/test.txt'))),
+ ),
+ $this->response->headers
+ );
+
+ $this->assertEquals('HTTP/1.1 200 OK',$this->response->status);
+ $this->assertEquals('Test contents', stream_get_contents($this->response->body));
+
+ }
+ function testGetHttp10() {
+
+ $serverVars = array(
+ 'REQUEST_URI' => '/test.txt',
+ 'REQUEST_METHOD' => 'GET',
+ 'SERVER_PROTOCOL' => 'HTTP/1.0',
+ );
+
+ $request = new HTTP\Request($serverVars);
+ $this->server->httpRequest = ($request);
+ $this->server->exec();
+
+ $this->assertEquals(array(
+ 'Content-Type' => 'application/octet-stream',
+ 'Content-Length' => 13,
+ 'Last-Modified' => HTTP\Util::toHTTPDate(new \DateTime('@' . filemtime($this->tempDir . '/test.txt'))),
+ ),
+ $this->response->headers
+ );
+
+ $this->assertEquals('HTTP/1.0 200 OK',$this->response->status);
+ $this->assertEquals('Test contents', stream_get_contents($this->response->body));
+
+ }
+
+ function testGetDoesntExist() {
+
+ $serverVars = array(
+ 'REQUEST_URI' => '/test.txt_randomblbla',
+ '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 testGetDoesntExist2() {
+
+ $serverVars = array(
+ 'REQUEST_URI' => '/test.txt/randomblbla',
+ '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);
+
+ }
+
+ /**
+ * This test should have the exact same result as testGet.
+ *
+ * The idea is that double slashes // are converted to single ones /
+ *
+ */
+ function testGetDoubleSlash() {
+
+ $serverVars = array(
+ 'REQUEST_URI' => '//test.txt',
+ 'REQUEST_METHOD' => 'GET',
+ );
+
+ $request = new HTTP\Request($serverVars);
+ $this->server->httpRequest = ($request);
+ $this->server->exec();
+
+ $this->assertEquals(array(
+ 'Content-Type' => 'application/octet-stream',
+ 'Content-Length' => 13,
+ 'Last-Modified' => HTTP\Util::toHTTPDate(new \DateTime('@' . filemtime($this->tempDir . '/test.txt'))),
+ ),
+ $this->response->headers
+ );
+
+ $this->assertEquals('HTTP/1.1 200 OK',$this->response->status);
+ $this->assertEquals('Test contents', stream_get_contents($this->response->body));
+
+ }
+
+
+ function testHEAD() {
+
+ $serverVars = array(
+ 'REQUEST_URI' => '/test.txt',
+ 'REQUEST_METHOD' => 'HEAD',
+ );
+
+ $request = new HTTP\Request($serverVars);
+ $this->server->httpRequest = ($request);
+ $this->server->exec();
+
+ $this->assertEquals(array(
+ 'Content-Type' => 'application/octet-stream',
+ 'Content-Length' => 13,
+ 'Last-Modified' => HTTP\Util::toHTTPDate(new \DateTime('@' . filemtime($this->tempDir . '/test.txt'))),
+ ),
+ $this->response->headers
+ );
+
+ $this->assertEquals('HTTP/1.1 200 OK',$this->response->status);
+ $this->assertEquals('', $this->response->body);
+
+ }
+
+ function testPut() {
+
+ $serverVars = array(
+ 'REQUEST_URI' => '/testput.txt',
+ 'REQUEST_METHOD' => 'PUT',
+ );
+
+ $request = new HTTP\Request($serverVars);
+ $request->setBody('Testing new file');
+ $this->server->httpRequest = ($request);
+ $this->server->exec();
+
+ $this->assertEquals('', $this->response->body);
+ $this->assertEquals('HTTP/1.1 201 Created',$this->response->status);
+ $this->assertEquals(array(
+ "Content-Length" => "0",
+ ), $this->response->headers);
+
+ $this->assertEquals('Testing new file',file_get_contents($this->tempDir . '/testput.txt'));
+
+ }
+
+ function testPutAlreadyExists() {
+
+ $serverVars = array(
+ 'REQUEST_URI' => '/test.txt',
+ 'REQUEST_METHOD' => 'PUT',
+ 'HTTP_IF_NONE_MATCH' => '*',
+ );
+
+ $request = new HTTP\Request($serverVars);
+ $request->setBody('Testing new file');
+ $this->server->httpRequest = ($request);
+ $this->server->exec();
+
+ $this->assertEquals(array(
+ 'Content-Type' => 'application/xml; charset=utf-8',
+ ),$this->response->headers);
+
+ $this->assertEquals('HTTP/1.1 412 Precondition failed',$this->response->status);
+ $this->assertNotEquals('Testing new file',file_get_contents($this->tempDir . '/test.txt'));
+
+ }
+
+ function testPutUpdate() {
+
+ $serverVars = array(
+ 'REQUEST_URI' => '/test.txt',
+ 'REQUEST_METHOD' => 'PUT',
+ );
+
+ $request = new HTTP\Request($serverVars);
+ $request->setBody('Testing updated file');
+ $this->server->httpRequest = ($request);
+ $this->server->exec();
+
+ $this->assertEquals('0', $this->response->headers['Content-Length']);
+
+ $this->assertEquals('HTTP/1.1 204 No Content',$this->response->status);
+ $this->assertEquals('', $this->response->body);
+ $this->assertEquals('Testing updated file',file_get_contents($this->tempDir . '/test.txt'));
+
+ }
+
+ function testPutNoParentCollection() {
+
+ $serverVars = array(
+ 'REQUEST_URI' => '/test.txt/item.txt',
+ 'REQUEST_METHOD' => 'PUT',
+ );
+
+ $request = new HTTP\Request($serverVars);
+ $request->setBody('Testing updated file');
+ $this->server->httpRequest = ($request);
+ $this->server->exec();
+
+ $this->assertEquals('HTTP/1.1 409 Conflict',$this->response->status);
+
+ }
+
+ function testPutContentRange() {
+
+ $serverVars = array(
+ 'REQUEST_URI' => '/testput.txt',
+ 'REQUEST_METHOD' => 'PUT',
+ 'HTTP_CONTENT_RANGE' => 'bytes/100-200',
+ );
+
+ $request = new HTTP\Request($serverVars);
+ $request->setBody('Testing new file');
+ $this->server->httpRequest = ($request);
+ $this->server->exec();
+
+ $this->assertEquals('HTTP/1.1 501 Not Implemented',$this->response->status);
+
+ }
+
+
+ function testDelete() {
+
+ $serverVars = array(
+ 'REQUEST_URI' => '/test.txt',
+ 'REQUEST_METHOD' => 'DELETE',
+ );
+
+ $request = new HTTP\Request($serverVars);
+ $this->server->httpRequest = ($request);
+ $this->server->exec();
+
+ $this->assertEquals(array(
+ 'Content-Length' => '0',
+ ),$this->response->headers);
+
+ $this->assertEquals('HTTP/1.1 204 No Content',$this->response->status);
+ $this->assertEquals('', $this->response->body);
+ $this->assertFalse(file_exists($this->tempDir . '/test.txt'));
+
+ }
+
+ function testDeleteDirectory() {
+
+ $serverVars = array(
+ 'REQUEST_URI' => '/testcol',
+ 'REQUEST_METHOD' => 'DELETE',
+ );
+
+ mkdir($this->tempDir.'/testcol');
+ file_put_contents($this->tempDir.'/testcol/test.txt','Hi! I\'m a file with a short lifespan');
+
+ $request = new HTTP\Request($serverVars);
+ $this->server->httpRequest = ($request);
+ $this->server->exec();
+
+ $this->assertEquals(array(
+ 'Content-Length' => '0',
+ ),$this->response->headers);
+ $this->assertEquals('HTTP/1.1 204 No Content',$this->response->status);
+ $this->assertEquals('', $this->response->body);
+ $this->assertFalse(file_exists($this->tempDir . '/col'));
+
+ }
+
+ function testOptions() {
+
+ $serverVars = array(
+ 'REQUEST_URI' => '/',
+ 'REQUEST_METHOD' => 'OPTIONS',
+ );
+
+ $request = new HTTP\Request($serverVars);
+ $this->server->httpRequest = ($request);
+ $this->server->exec();
+
+ $this->assertEquals(array(
+ 'DAV' => '1, 3, extended-mkcol',
+ 'MS-Author-Via' => 'DAV',
+ 'Allow' => 'OPTIONS, GET, HEAD, DELETE, PROPFIND, PUT, PROPPATCH, COPY, MOVE, REPORT',
+ 'Accept-Ranges' => 'bytes',
+ 'Content-Length' => '0',
+ 'X-Sabre-Version' => Version::VERSION,
+ ),$this->response->headers);
+
+ $this->assertEquals('HTTP/1.1 200 OK',$this->response->status);
+ $this->assertEquals('', $this->response->body);
+
+
+ }
+ function testNonExistantMethod() {
+
+ $serverVars = array(
+ 'REQUEST_URI' => '/',
+ 'REQUEST_METHOD' => 'BLABLA',
+ );
+
+ $request = new HTTP\Request($serverVars);
+ $this->server->httpRequest = ($request);
+ $this->server->exec();
+
+ $this->assertEquals(array(
+ 'Content-Type' => 'application/xml; charset=utf-8',
+ ),$this->response->headers);
+
+ $this->assertEquals('HTTP/1.1 501 Not Implemented',$this->response->status);
+
+
+ }
+
+ function testGETOnCollection() {
+
+ $serverVars = array(
+ 'REQUEST_URI' => '/',
+ 'REQUEST_METHOD' => 'GET',
+ );
+
+ $request = new HTTP\Request($serverVars);
+ $this->server->httpRequest = ($request);
+ $this->server->exec();
+
+ $this->assertEquals(array(
+ 'Content-Type' => 'application/xml; charset=utf-8',
+ ),$this->response->headers);
+
+ $this->assertEquals('HTTP/1.1 501 Not Implemented',$this->response->status);
+
+ }
+
+ function testHEADOnCollection() {
+
+ $serverVars = array(
+ 'REQUEST_URI' => '/',
+ 'REQUEST_METHOD' => 'HEAD',
+ );
+
+ $request = new HTTP\Request($serverVars);
+ $this->server->httpRequest = ($request);
+ $this->server->exec();
+
+ $this->assertEquals('HTTP/1.1 200 OK',$this->response->status);
+
+ }
+
+ function testBaseUri() {
+
+ $serverVars = array(
+ 'REQUEST_URI' => '/blabla/test.txt',
+ 'REQUEST_METHOD' => 'GET',
+ );
+
+ $request = new HTTP\Request($serverVars);
+ $this->server->setBaseUri('/blabla/');
+ $this->assertEquals('/blabla/',$this->server->getBaseUri());
+ $this->server->httpRequest = ($request);
+ $this->server->exec();
+
+ $this->assertEquals(array(
+ 'Content-Type' => 'application/octet-stream',
+ 'Content-Length' => 13,
+ 'Last-Modified' => HTTP\Util::toHTTPDate(new \DateTime('@' . filemtime($this->tempDir . '/test.txt'))),
+ ),
+ $this->response->headers
+ );
+
+ $this->assertEquals('HTTP/1.1 200 OK',$this->response->status);
+ $this->assertEquals('Test contents', stream_get_contents($this->response->body));
+
+ }
+
+ function testBaseUriAddSlash() {
+
+ $tests = array(
+ '/' => '/',
+ '/foo' => '/foo/',
+ '/foo/' => '/foo/',
+ '/foo/bar' => '/foo/bar/',
+ '/foo/bar/' => '/foo/bar/',
+ );
+
+ foreach($tests as $test=>$result) {
+ $this->server->setBaseUri($test);
+
+ $this->assertEquals($result, $this->server->getBaseUri());
+
+ }
+
+ }
+
+ function testCalculateUri() {
+
+ $uris = array(
+ 'http://www.example.org/root/somepath',
+ '/root/somepath',
+ '/root/somepath/',
+ );
+
+ $this->server->setBaseUri('/root/');
+
+ foreach($uris as $uri) {
+
+ $this->assertEquals('somepath',$this->server->calculateUri($uri));
+
+ }
+
+ $this->server->setBaseUri('/root');
+
+ foreach($uris as $uri) {
+
+ $this->assertEquals('somepath',$this->server->calculateUri($uri));
+
+ }
+
+ $this->assertEquals('', $this->server->calculateUri('/root'));
+
+ }
+
+ function testCalculateUriSpecialChars() {
+
+ $uris = array(
+ 'http://www.example.org/root/%C3%A0fo%C3%B3',
+ '/root/%C3%A0fo%C3%B3',
+ '/root/%C3%A0fo%C3%B3/'
+ );
+
+ $this->server->setBaseUri('/root/');
+
+ foreach($uris as $uri) {
+
+ $this->assertEquals("\xc3\xa0fo\xc3\xb3",$this->server->calculateUri($uri));
+
+ }
+
+ $this->server->setBaseUri('/root');
+
+ foreach($uris as $uri) {
+
+ $this->assertEquals("\xc3\xa0fo\xc3\xb3",$this->server->calculateUri($uri));
+
+ }
+
+ $this->server->setBaseUri('/');
+
+ foreach($uris as $uri) {
+
+ $this->assertEquals("root/\xc3\xa0fo\xc3\xb3",$this->server->calculateUri($uri));
+
+ }
+
+ }
+
+ function testBaseUriCheck() {
+
+ $uris = array(
+ 'http://www.example.org/root/somepath',
+ '/root/somepath',
+ '/root/somepath/'
+ );
+
+ try {
+
+ $this->server->setBaseUri('root/');
+ $this->server->calculateUri('/root/testuri');
+
+ $this->fail('Expected an exception');
+
+ } catch (Exception\Forbidden $e) {
+
+ // This was expected
+
+ }
+
+ }
+
+ /**
+ * @covers \Sabre\DAV\Server::guessBaseUri
+ */
+ function testGuessBaseUri() {
+
+ $serverVars = array(
+ 'REQUEST_URI' => '/index.php/root',
+ 'PATH_INFO' => '/root',
+ );
+
+ $httpRequest = new HTTP\Request($serverVars);
+ $server = new Server();
+ $server->httpRequest = $httpRequest;
+
+ $this->assertEquals('/index.php/', $server->guessBaseUri());
+
+ }
+
+ /**
+ * @depends testGuessBaseUri
+ * @covers Sabre\DAV\Server::guessBaseUri
+ */
+ function testGuessBaseUriPercentEncoding() {
+
+ $serverVars = array(
+ 'REQUEST_URI' => '/index.php/dir/path2/path%20with%20spaces',
+ 'PATH_INFO' => '/dir/path2/path with spaces',
+ );
+
+ $httpRequest = new HTTP\Request($serverVars);
+ $server = new Server();
+ $server->httpRequest = $httpRequest;
+
+ $this->assertEquals('/index.php/', $server->guessBaseUri());
+
+ }
+
+ /**
+ * @depends testGuessBaseUri
+ * @covers \Sabre\DAV\Server::guessBaseUri
+ */
+ /*
+ function testGuessBaseUriPercentEncoding2() {
+
+ $this->markTestIncomplete('This behaviour is not yet implemented');
+ $serverVars = array(
+ 'REQUEST_URI' => '/some%20directory+mixed/index.php/dir/path2/path%20with%20spaces',
+ 'PATH_INFO' => '/dir/path2/path with spaces',
+ );
+
+ $httpRequest = new HTTP\Request($serverVars);
+ $server = new Server();
+ $server->httpRequest = $httpRequest;
+
+ $this->assertEquals('/some%20directory+mixed/index.php/', $server->guessBaseUri());
+
+ }*/
+
+ function testGuessBaseUri2() {
+
+ $serverVars = array(
+ 'REQUEST_URI' => '/index.php/root/',
+ 'PATH_INFO' => '/root/',
+ );
+
+ $httpRequest = new HTTP\Request($serverVars);
+ $server = new Server();
+ $server->httpRequest = $httpRequest;
+
+ $this->assertEquals('/index.php/', $server->guessBaseUri());
+
+ }
+
+ function testGuessBaseUriNoPathInfo() {
+
+ $serverVars = array(
+ 'REQUEST_URI' => '/index.php/root',
+ );
+
+ $httpRequest = new HTTP\Request($serverVars);
+ $server = new Server();
+ $server->httpRequest = $httpRequest;
+
+ $this->assertEquals('/', $server->guessBaseUri());
+
+ }
+
+ function testGuessBaseUriNoPathInfo2() {
+
+ $serverVars = array(
+ 'REQUEST_URI' => '/a/b/c/test.php',
+ );
+
+ $httpRequest = new HTTP\Request($serverVars);
+ $server = new Server();
+ $server->httpRequest = $httpRequest;
+
+ $this->assertEquals('/', $server->guessBaseUri());
+
+ }
+
+
+ /**
+ * @covers \Sabre\DAV\Server::guessBaseUri
+ * @depends testGuessBaseUri
+ */
+ function testGuessBaseUriQueryString() {
+
+ $serverVars = array(
+ 'REQUEST_URI' => '/index.php/root?query_string=blabla',
+ 'PATH_INFO' => '/root',
+ );
+
+ $httpRequest = new HTTP\Request($serverVars);
+ $server = new Server();
+ $server->httpRequest = $httpRequest;
+
+ $this->assertEquals('/index.php/', $server->guessBaseUri());
+
+ }
+
+ /**
+ * @covers \Sabre\DAV\Server::guessBaseUri
+ * @depends testGuessBaseUri
+ * @expectedException \Sabre\DAV\Exception
+ */
+ function testGuessBaseUriBadConfig() {
+
+ $serverVars = array(
+ 'REQUEST_URI' => '/index.php/root/heyyy',
+ 'PATH_INFO' => '/root',
+ );
+
+ $httpRequest = new HTTP\Request($serverVars);
+ $server = new Server();
+ $server->httpRequest = $httpRequest;
+
+ $server->guessBaseUri();
+
+ }
+
+ function testTriggerException() {
+
+ $serverVars = array(
+ 'REQUEST_URI' => '/',
+ 'REQUEST_METHOD' => 'FOO',
+ );
+
+ $httpRequest = new HTTP\Request($serverVars);
+ $this->server->httpRequest = $httpRequest;
+ $this->server->subscribeEvent('beforeMethod',array($this,'exceptionTrigger'));
+ $this->server->exec();
+
+ $this->assertEquals(array(
+ 'Content-Type' => 'application/xml; charset=utf-8',
+ ),$this->response->headers);
+
+ $this->assertEquals('HTTP/1.1 500 Internal Server Error',$this->response->status);
+
+ }
+
+ function exceptionTrigger() {
+
+ throw new Exception('Hola');
+
+ }
+
+ function testReportNotFound() {
+
+ $serverVars = array(
+ 'REQUEST_URI' => '/',
+ 'REQUEST_METHOD' => 'REPORT',
+ );
+
+ $request = new HTTP\Request($serverVars);
+ $this->server->httpRequest = ($request);
+ $this->server->httpRequest->setBody('<?xml version="1.0"?><bla:myreport xmlns:bla="http://www.rooftopsolutions.nl/NS"></bla:myreport>');
+ $this->server->exec();
+
+ $this->assertEquals(array(
+ 'Content-Type' => 'application/xml; charset=utf-8',
+ ),
+ $this->response->headers
+ );
+
+ $this->assertEquals('HTTP/1.1 403 Forbidden',$this->response->status,'We got an incorrect status back. Full response body follows: ' . $this->response->body);
+
+ }
+
+ function testReportIntercepted() {
+
+ $serverVars = array(
+ 'REQUEST_URI' => '/',
+ 'REQUEST_METHOD' => 'REPORT',
+ );
+
+ $request = new HTTP\Request($serverVars);
+ $this->server->httpRequest = ($request);
+ $this->server->httpRequest->setBody('<?xml version="1.0"?><bla:myreport xmlns:bla="http://www.rooftopsolutions.nl/NS"></bla:myreport>');
+ $this->server->subscribeEvent('report',array($this,'reportHandler'));
+ $this->server->exec();
+
+ $this->assertEquals(array(
+ 'testheader' => 'testvalue',
+ ),
+ $this->response->headers
+ );
+
+ $this->assertEquals('HTTP/1.1 418 I\'m a teapot',$this->response->status,'We got an incorrect status back. Full response body follows: ' . $this->response->body);
+
+ }
+
+ function reportHandler($reportName) {
+
+ if ($reportName=='{http://www.rooftopsolutions.nl/NS}myreport') {
+ $this->server->httpResponse->sendStatus(418);
+ $this->server->httpResponse->setHeader('testheader','testvalue');
+ return false;
+ }
+ else return;
+
+ }
+
+ function testGetPropertiesForChildren() {
+
+ $result = $this->server->getPropertiesForChildren('',array(
+ '{DAV:}getcontentlength',
+ ));
+
+ $expected = array(
+ 'test.txt' => array('{DAV:}getcontentlength' => 13),
+ 'dir/' => array(),
+ );
+
+ $this->assertEquals($expected,$result);
+
+ }
+
+}
diff --git a/vendor/sabre/dav/tests/Sabre/DAV/ServerUpdatePropertiesTest.php b/vendor/sabre/dav/tests/Sabre/DAV/ServerUpdatePropertiesTest.php
new file mode 100644
index 000000000..a73e8d13f
--- /dev/null
+++ b/vendor/sabre/dav/tests/Sabre/DAV/ServerUpdatePropertiesTest.php
@@ -0,0 +1,130 @@
+<?php
+
+namespace Sabre\DAV;
+use Sabre\HTTP;
+
+class ServerUpdatePropertiesTest extends \PHPUnit_Framework_TestCase {
+
+ function testUpdatePropertiesFail() {
+
+ $tree = array(
+ new SimpleCollection('foo'),
+ );
+ $server = new Server($tree);
+
+ $result = $server->updateProperties('foo', array(
+ '{DAV:}foo' => 'bar'
+ ));
+
+ $expected = array(
+ 'href' => 'foo',
+ '403' => array(
+ '{DAV:}foo' => null,
+ ),
+ );
+ $this->assertEquals($expected, $result);
+
+ }
+
+ function testUpdatePropertiesProtected() {
+
+ $tree = array(
+ new SimpleCollection('foo'),
+ );
+ $server = new Server($tree);
+
+ $result = $server->updateProperties('foo', array(
+ '{DAV:}getetag' => 'bla',
+ '{DAV:}foo' => 'bar'
+ ));
+
+ $expected = array(
+ 'href' => 'foo',
+ '403' => array(
+ '{DAV:}getetag' => null,
+ ),
+ '424' => array(
+ '{DAV:}foo' => null,
+ ),
+ );
+ $this->assertEquals($expected, $result);
+
+ }
+
+ function testUpdatePropertiesEventFail() {
+
+ $tree = array(
+ new SimpleCollection('foo'),
+ );
+ $server = new Server($tree);
+ $server->subscribeEvent('updateProperties', array($this,'updatepropfail'));
+
+ $result = $server->updateProperties('foo', array(
+ '{DAV:}foo' => 'bar',
+ '{DAV:}foo2' => 'bla',
+ ));
+
+ $expected = array(
+ 'href' => 'foo',
+ '404' => array(
+ '{DAV:}foo' => null,
+ ),
+ '424' => array(
+ '{DAV:}foo2' => null,
+ ),
+ );
+ $this->assertEquals($expected, $result);
+
+ }
+
+ function updatePropFail(&$propertyDelta, &$result, $node) {
+
+ $result[404] = array(
+ '{DAV:}foo' => null,
+ );
+ unset($propertyDelta['{DAV:}foo']);
+ return false;
+
+ }
+
+
+ function testUpdatePropertiesEventSuccess() {
+
+ $tree = array(
+ new SimpleCollection('foo'),
+ );
+ $server = new Server($tree);
+ $server->subscribeEvent('updateProperties', array($this,'updatepropsuccess'));
+
+ $result = $server->updateProperties('foo', array(
+ '{DAV:}foo' => 'bar',
+ '{DAV:}foo2' => 'bla',
+ ));
+
+ $expected = array(
+ 'href' => 'foo',
+ '200' => array(
+ '{DAV:}foo' => null,
+ ),
+ '201' => array(
+ '{DAV:}foo2' => null,
+ ),
+ );
+ $this->assertEquals($expected, $result);
+
+ }
+
+ function updatePropSuccess(&$propertyDelta, &$result, $node) {
+
+ $result[200] = array(
+ '{DAV:}foo' => null,
+ );
+ $result[201] = array(
+ '{DAV:}foo2' => null,
+ );
+ unset($propertyDelta['{DAV:}foo']);
+ unset($propertyDelta['{DAV:}foo2']);
+ return;
+
+ }
+}
diff --git a/vendor/sabre/dav/tests/Sabre/DAV/SimpleFileTest.php b/vendor/sabre/dav/tests/Sabre/DAV/SimpleFileTest.php
new file mode 100644
index 000000000..de8b05734
--- /dev/null
+++ b/vendor/sabre/dav/tests/Sabre/DAV/SimpleFileTest.php
@@ -0,0 +1,19 @@
+<?php
+
+namespace Sabre\DAV;
+
+class SimpleFileTest extends \PHPUnit_Framework_TestCase {
+
+ function testAll() {
+
+ $file = new SimpleFile('filename.txt','contents','text/plain');
+
+ $this->assertEquals('filename.txt', $file->getName());
+ $this->assertEquals('contents', $file->get());
+ $this->assertEquals('8', $file->getSize());
+ $this->assertEquals('"' . md5('contents') . '"', $file->getETag());
+ $this->assertEquals('text/plain', $file->getContentType());
+
+ }
+
+}
diff --git a/vendor/sabre/dav/tests/Sabre/DAV/StringUtilTest.php b/vendor/sabre/dav/tests/Sabre/DAV/StringUtilTest.php
new file mode 100644
index 000000000..941d1f913
--- /dev/null
+++ b/vendor/sabre/dav/tests/Sabre/DAV/StringUtilTest.php
@@ -0,0 +1,122 @@
+<?php
+
+namespace Sabre\DAV;
+
+class StringUtilTest extends \PHPUnit_Framework_TestCase {
+
+ /**
+ * @dataProvider dataset
+ */
+ function testTextMatch($haystack, $needle, $collation, $matchType, $result) {
+
+ $this->assertEquals($result, StringUtil::textMatch($haystack, $needle, $collation, $matchType));
+
+ }
+
+ function dataset() {
+
+ return array(
+ array('FOOBAR', 'FOO', 'i;octet', 'contains', true),
+ array('FOOBAR', 'foo', 'i;octet', 'contains', false),
+ array('FÖÖBAR', 'FÖÖ', 'i;octet', 'contains', true),
+ array('FÖÖBAR', 'föö', 'i;octet', 'contains', false),
+ array('FOOBAR', 'FOOBAR', 'i;octet', 'equals', true),
+ array('FOOBAR', 'fooBAR', 'i;octet', 'equals', false),
+ array('FOOBAR', 'FOO', 'i;octet', 'starts-with', true),
+ array('FOOBAR', 'foo', 'i;octet', 'starts-with', false),
+ array('FOOBAR', 'BAR', 'i;octet', 'starts-with', false),
+ array('FOOBAR', 'bar', 'i;octet', 'starts-with', false),
+ array('FOOBAR', 'FOO', 'i;octet', 'ends-with', false),
+ array('FOOBAR', 'foo', 'i;octet', 'ends-with', false),
+ array('FOOBAR', 'BAR', 'i;octet', 'ends-with', true),
+ array('FOOBAR', 'bar', 'i;octet', 'ends-with', false),
+
+ array('FOOBAR', 'FOO', 'i;ascii-casemap', 'contains', true),
+ array('FOOBAR', 'foo', 'i;ascii-casemap', 'contains', true),
+ array('FÖÖBAR', 'FÖÖ', 'i;ascii-casemap', 'contains', true),
+ array('FÖÖBAR', 'föö', 'i;ascii-casemap', 'contains', false),
+ array('FOOBAR', 'FOOBAR', 'i;ascii-casemap', 'equals', true),
+ array('FOOBAR', 'fooBAR', 'i;ascii-casemap', 'equals', true),
+ array('FOOBAR', 'FOO', 'i;ascii-casemap', 'starts-with', true),
+ array('FOOBAR', 'foo', 'i;ascii-casemap', 'starts-with', true),
+ array('FOOBAR', 'BAR', 'i;ascii-casemap', 'starts-with', false),
+ array('FOOBAR', 'bar', 'i;ascii-casemap', 'starts-with', false),
+ array('FOOBAR', 'FOO', 'i;ascii-casemap', 'ends-with', false),
+ array('FOOBAR', 'foo', 'i;ascii-casemap', 'ends-with', false),
+ array('FOOBAR', 'BAR', 'i;ascii-casemap', 'ends-with', true),
+ array('FOOBAR', 'bar', 'i;ascii-casemap', 'ends-with', true),
+
+ array('FOOBAR', 'FOO', 'i;unicode-casemap', 'contains', true),
+ array('FOOBAR', 'foo', 'i;unicode-casemap', 'contains', true),
+ array('FÖÖBAR', 'FÖÖ', 'i;unicode-casemap', 'contains', true),
+ array('FÖÖBAR', 'föö', 'i;unicode-casemap', 'contains', true),
+ array('FOOBAR', 'FOOBAR', 'i;unicode-casemap', 'equals', true),
+ array('FOOBAR', 'fooBAR', 'i;unicode-casemap', 'equals', true),
+ array('FOOBAR', 'FOO', 'i;unicode-casemap', 'starts-with', true),
+ array('FOOBAR', 'foo', 'i;unicode-casemap', 'starts-with', true),
+ array('FOOBAR', 'BAR', 'i;unicode-casemap', 'starts-with', false),
+ array('FOOBAR', 'bar', 'i;unicode-casemap', 'starts-with', false),
+ array('FOOBAR', 'FOO', 'i;unicode-casemap', 'ends-with', false),
+ array('FOOBAR', 'foo', 'i;unicode-casemap', 'ends-with', false),
+ array('FOOBAR', 'BAR', 'i;unicode-casemap', 'ends-with', true),
+ array('FOOBAR', 'bar', 'i;unicode-casemap', 'ends-with', true),
+ );
+
+ }
+
+ /**
+ * @expectedException Sabre\DAV\Exception\BadRequest
+ */
+ public function testBadCollation() {
+
+ StringUtil::textMatch('foobar','foo','blabla','contains');
+
+ }
+
+
+ /**
+ * @expectedException Sabre\DAV\Exception\BadRequest
+ */
+ public function testBadMatchType() {
+
+ StringUtil::textMatch('foobar','foo','i;octet','booh');
+
+ }
+
+ public function testEnsureUTF8_ascii() {
+
+ $inputString = "harkema";
+ $outputString = "harkema";
+
+ $this->assertEquals(
+ $outputString,
+ StringUtil::ensureUTF8($inputString)
+ );
+
+ }
+
+ public function testEnsureUTF8_latin1() {
+
+ $inputString = "m\xfcnster";
+ $outputString = "münster";
+
+ $this->assertEquals(
+ $outputString,
+ StringUtil::ensureUTF8($inputString)
+ );
+
+ }
+
+ public function testEnsureUTF8_utf8() {
+
+ $inputString = "m\xc3\xbcnster";
+ $outputString = "münster";
+
+ $this->assertEquals(
+ $outputString,
+ StringUtil::ensureUTF8($inputString)
+ );
+
+ }
+
+}
diff --git a/vendor/sabre/dav/tests/Sabre/DAV/TemporaryFileFilterTest.php b/vendor/sabre/dav/tests/Sabre/DAV/TemporaryFileFilterTest.php
new file mode 100644
index 000000000..d136eeb17
--- /dev/null
+++ b/vendor/sabre/dav/tests/Sabre/DAV/TemporaryFileFilterTest.php
@@ -0,0 +1,252 @@
+<?php
+
+namespace Sabre\DAV;
+
+use Sabre\HTTP;
+
+class TemporaryFileFilterTest extends AbstractServer {
+
+ function setUp() {
+
+ parent::setUp();
+ $plugin = new TemporaryFileFilterPlugin(SABRE_TEMPDIR . '/tff');
+ $this->server->addPlugin($plugin);
+
+ }
+
+ function testPutNormal() {
+
+ $serverVars = array(
+ 'REQUEST_URI' => '/testput.txt',
+ 'REQUEST_METHOD' => 'PUT',
+ );
+
+ $request = new HTTP\Request($serverVars);
+ $request->setBody('Testing new file');
+ $this->server->httpRequest = ($request);
+ $this->server->exec();
+
+ $this->assertEquals('', $this->response->body);
+ $this->assertEquals('HTTP/1.1 201 Created',$this->response->status);
+ $this->assertEquals('0', $this->response->headers['Content-Length']);
+
+ $this->assertEquals('Testing new file',file_get_contents(SABRE_TEMPDIR . '/testput.txt'));
+
+ }
+
+ function testPutTemp() {
+
+ // mimicking an OS/X resource fork
+ $serverVars = array(
+ 'REQUEST_URI' => '/._testput.txt',
+ 'REQUEST_METHOD' => 'PUT',
+ );
+
+ $request = new HTTP\Request($serverVars);
+ $request->setBody('Testing new file');
+ $this->server->httpRequest = ($request);
+ $this->server->exec();
+
+ $this->assertEquals('', $this->response->body);
+ $this->assertEquals('HTTP/1.1 201 Created',$this->response->status);
+ $this->assertEquals(array(
+ 'X-Sabre-Temp' => 'true',
+ ),$this->response->headers);
+
+ $this->assertFalse(file_exists(SABRE_TEMPDIR . '/._testput.txt'),'._testput.txt should not exist in the regular file structure.');
+
+ }
+
+ function testPutTempIfNoneMatch() {
+
+ // mimicking an OS/X resource fork
+ $serverVars = array(
+ 'REQUEST_URI' => '/._testput.txt',
+ 'REQUEST_METHOD' => 'PUT',
+ 'HTTP_IF_NONE_MATCH' => '*',
+ );
+
+ $request = new HTTP\Request($serverVars);
+ $request->setBody('Testing new file');
+ $this->server->httpRequest = ($request);
+ $this->server->exec();
+
+ $this->assertEquals('', $this->response->body);
+ $this->assertEquals('HTTP/1.1 201 Created',$this->response->status);
+ $this->assertEquals(array(
+ 'X-Sabre-Temp' => 'true',
+ ),$this->response->headers);
+
+ $this->assertFalse(file_exists(SABRE_TEMPDIR . '/._testput.txt'),'._testput.txt should not exist in the regular file structure.');
+
+
+ $this->server->exec();
+
+ $this->assertEquals('HTTP/1.1 412 Precondition failed',$this->response->status);
+ $this->assertEquals(array(
+ 'X-Sabre-Temp' => 'true',
+ 'Content-Type' => 'application/xml; charset=utf-8',
+ ),$this->response->headers);
+
+ }
+
+ function testPutGet() {
+
+ // mimicking an OS/X resource fork
+ $serverVars = array(
+ 'REQUEST_URI' => '/._testput.txt',
+ 'REQUEST_METHOD' => 'PUT',
+ );
+
+ $request = new HTTP\Request($serverVars);
+ $request->setBody('Testing new file');
+ $this->server->httpRequest = ($request);
+ $this->server->exec();
+
+ $this->assertEquals('', $this->response->body);
+ $this->assertEquals('HTTP/1.1 201 Created',$this->response->status);
+ $this->assertEquals(array(
+ 'X-Sabre-Temp' => 'true',
+ ),$this->response->headers);
+
+ $serverVars = array(
+ 'REQUEST_URI' => '/._testput.txt',
+ '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(
+ 'X-Sabre-Temp' => 'true',
+ 'Content-Length' => 16,
+ 'Content-Type' => 'application/octet-stream',
+ ),$this->response->headers);
+
+ $this->assertEquals('Testing new file',stream_get_contents($this->response->body));
+
+ }
+
+ function testLockNonExistant() {
+
+ mkdir(SABRE_TEMPDIR . '/locksdir');
+ $locksBackend = new Locks\Backend\FS(SABRE_TEMPDIR . '/locksdir');
+ $locksPlugin = new Locks\Plugin($locksBackend);
+ $this->server->addPlugin($locksPlugin);
+
+ // mimicking an OS/X resource fork
+ $serverVars = array(
+ 'REQUEST_URI' => '/._testlock.txt',
+ 'REQUEST_METHOD' => 'LOCK',
+ );
+
+ $request = new HTTP\Request($serverVars);
+
+ $request->setBody('<?xml version="1.0"?>
+<D:lockinfo xmlns:D="DAV:">
+ <D:lockscope><D:exclusive/></D:lockscope>
+ <D:locktype><D:write/></D:locktype>
+ <D:owner>
+ <D:href>http://example.org/~ejw/contact.html</D:href>
+ </D:owner>
+</D:lockinfo>');
+
+ $this->server->httpRequest = ($request);
+ $this->server->exec();
+
+ $this->assertEquals('HTTP/1.1 201 Created',$this->response->status);
+ $this->assertEquals('application/xml; charset=utf-8',$this->response->headers['Content-Type']);
+ $this->assertTrue(preg_match('/^<opaquelocktoken:(.*)>$/',$this->response->headers['Lock-Token'])===1,'We did not get a valid Locktoken back (' . $this->response->headers['Lock-Token'] . ')');
+ $this->assertEquals('true',$this->response->headers['X-Sabre-Temp']);
+
+ $this->assertFalse(file_exists(SABRE_TEMPDIR . '/._testlock.txt'),'._testlock.txt should not exist in the regular file structure.');
+
+ }
+
+ function testPutDelete() {
+
+ // mimicking an OS/X resource fork
+ $serverVars = array(
+ 'REQUEST_URI' => '/._testput.txt',
+ 'REQUEST_METHOD' => 'PUT',
+ );
+
+ $request = new HTTP\Request($serverVars);
+ $request->setBody('Testing new file');
+ $this->server->httpRequest = ($request);
+ $this->server->exec();
+
+ $this->assertEquals('', $this->response->body);
+ $this->assertEquals('HTTP/1.1 201 Created',$this->response->status);
+ $this->assertEquals(array(
+ 'X-Sabre-Temp' => 'true',
+ ),$this->response->headers);
+
+ $serverVars = array(
+ 'REQUEST_URI' => '/._testput.txt',
+ 'REQUEST_METHOD' => 'DELETE',
+ );
+
+ $request = new HTTP\Request($serverVars);
+ $this->server->httpRequest = ($request);
+ $this->server->exec();
+
+ $this->assertEquals('HTTP/1.1 204 No Content',$this->response->status, "Incorrect status code received. Full body:\n". $this->response->body);
+ $this->assertEquals(array(
+ 'X-Sabre-Temp' => 'true',
+ ),$this->response->headers);
+
+ $this->assertEquals('',$this->response->body);
+
+ }
+
+ function testPutPropfind() {
+
+ // mimicking an OS/X resource fork
+ $serverVars = array(
+ 'REQUEST_URI' => '/._testput.txt',
+ 'REQUEST_METHOD' => 'PUT',
+ );
+
+ $request = new HTTP\Request($serverVars);
+ $request->setBody('Testing new file');
+ $this->server->httpRequest = ($request);
+ $this->server->exec();
+
+ $this->assertEquals('', $this->response->body);
+ $this->assertEquals('HTTP/1.1 201 Created',$this->response->status);
+ $this->assertEquals(array(
+ 'X-Sabre-Temp' => 'true',
+ ),$this->response->headers);
+
+ $serverVars = array(
+ 'REQUEST_URI' => '/._testput.txt',
+ 'REQUEST_METHOD' => 'PROPFIND',
+ );
+
+ $request = new HTTP\Request($serverVars);
+ $request->setBody('');
+ $this->server->httpRequest = ($request);
+ $this->server->exec();
+
+ $this->assertEquals('HTTP/1.1 207 Multi-Status',$this->response->status,'Incorrect status code returned. Body: ' . $this->response->body);
+ $this->assertEquals(array(
+ 'X-Sabre-Temp' => 'true',
+ 'Content-Type' => 'application/xml; charset=utf-8',
+ ),$this->response->headers);
+
+ $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');
+
+ $data = $xml->xpath('/d:multistatus/d:response/d:propstat/d:prop/d:resourcetype');
+ $this->assertEquals(1,count($data));
+
+ }
+
+}
diff --git a/vendor/sabre/dav/tests/Sabre/DAV/TestPlugin.php b/vendor/sabre/dav/tests/Sabre/DAV/TestPlugin.php
new file mode 100644
index 000000000..9cf5edbb0
--- /dev/null
+++ b/vendor/sabre/dav/tests/Sabre/DAV/TestPlugin.php
@@ -0,0 +1,34 @@
+<?php
+
+namespace Sabre\DAV;
+
+class TestPlugin extends ServerPlugin {
+
+ public $beforeMethod;
+
+ function getFeatures() {
+
+ return array('drinking');
+
+ }
+
+ function getHTTPMethods($uri) {
+
+ return array('BEER','WINE');
+
+ }
+
+ function initialize(Server $server) {
+
+ $server->subscribeEvent('beforeMethod',array($this,'beforeMethod'));
+
+ }
+
+ function beforeMethod($method) {
+
+ $this->beforeMethod = $method;
+ return true;
+
+ }
+
+}
diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Tree/FilesystemTest.php b/vendor/sabre/dav/tests/Sabre/DAV/Tree/FilesystemTest.php
new file mode 100644
index 000000000..19b08460f
--- /dev/null
+++ b/vendor/sabre/dav/tests/Sabre/DAV/Tree/FilesystemTest.php
@@ -0,0 +1,88 @@
+<?php
+
+namespace Sabre\DAV\Tree;
+
+use Sabre\DAV;
+
+/**
+ * @covers Sabre\DAV\Tree
+ * @covers Sabre\DAV\Tree\Filesystem
+ * @covers Sabre\DAV\FS\Node
+ * @covers Sabre\DAV\FS\File
+ * @covers Sabre\DAV\FS\Directory
+ */
+class FilesystemTest extends \PHPUnit_Framework_TestCase {
+
+ function setUp() {
+
+ \Sabre\TestUtil::clearTempDir();
+ file_put_contents(SABRE_TEMPDIR. '/file.txt','Body');
+ mkdir(SABRE_TEMPDIR.'/dir');
+ file_put_contents(SABRE_TEMPDIR.'/dir/subfile.txt','Body');
+
+ }
+
+ function tearDown() {
+
+ \Sabre\TestUtil::clearTempDir();
+
+ }
+
+ function testGetNodeForPath_File() {
+
+ $fs = new Filesystem(SABRE_TEMPDIR);
+ $node = $fs->getNodeForPath('file.txt');
+ $this->assertTrue($node instanceof DAV\FS\File);
+
+ }
+
+ /**
+ * @expectedException \Sabre\DAV\Exception\NotFound
+ */
+ function testGetNodeForPath_DoesntExist() {
+
+ $fs = new Filesystem(SABRE_TEMPDIR);
+ $node = $fs->getNodeForPath('whoop/file.txt');
+
+ }
+
+ function testGetNodeForPath_Directory() {
+
+ $fs = new Filesystem(SABRE_TEMPDIR);
+ $node = $fs->getNodeForPath('dir');
+ $this->assertTrue($node instanceof DAV\FS\Directory);
+ $this->assertEquals('dir', $node->getName());
+ $this->assertInternalType('array', $node->getChildren());
+
+ }
+
+ function testCopy() {
+
+ $fs = new Filesystem(SABRE_TEMPDIR);
+ $fs->copy('file.txt','file2.txt');
+ $this->assertTrue(file_exists(SABRE_TEMPDIR . '/file2.txt'));
+ $this->assertEquals('Body',file_get_contents(SABRE_TEMPDIR . '/file2.txt'));
+
+ }
+
+ function testCopyDir() {
+
+ $fs = new Filesystem(SABRE_TEMPDIR);
+ $fs->copy('dir','dir2');
+ $this->assertTrue(file_exists(SABRE_TEMPDIR . '/dir2'));
+ $this->assertEquals('Body',file_get_contents(SABRE_TEMPDIR . '/dir2/subfile.txt'));
+
+ }
+
+ function testMove() {
+
+ $fs = new Filesystem(SABRE_TEMPDIR);
+ $fs->move('file.txt','file2.txt');
+ $this->assertTrue(file_exists(SABRE_TEMPDIR . '/file2.txt'));
+ $this->assertTrue(!file_exists(SABRE_TEMPDIR . '/file.txt'));
+ $this->assertEquals('Body',file_get_contents(SABRE_TEMPDIR . '/file2.txt'));
+
+ }
+
+
+}
diff --git a/vendor/sabre/dav/tests/Sabre/DAV/TreeTest.php b/vendor/sabre/dav/tests/Sabre/DAV/TreeTest.php
new file mode 100644
index 000000000..90df6427e
--- /dev/null
+++ b/vendor/sabre/dav/tests/Sabre/DAV/TreeTest.php
@@ -0,0 +1,175 @@
+<?php
+
+namespace Sabre\DAV;
+
+/**
+ * @covers \Sabre\DAV\Tree
+ */
+class TreeTest extends \PHPUnit_Framework_TestCase {
+
+ function testNodeExists() {
+
+ $tree = new TreeMock();
+
+ $this->assertTrue($tree->nodeExists('hi'));
+ $this->assertFalse($tree->nodeExists('hello'));
+
+ }
+
+ function testCopy() {
+
+ $tree = new TreeMock();
+ $tree->copy('hi','hi2');
+
+ $this->assertArrayHasKey('hi2', $tree->getNodeForPath('')->newDirectories);
+ $this->assertEquals('foobar', $tree->getNodeForPath('hi/file')->get());
+ $this->assertEquals(array('test1'=>'value'), $tree->getNodeForPath('hi/file')->getProperties(array()));
+
+ }
+
+ function testMove() {
+
+ $tree = new TreeMock();
+ $tree->move('hi','hi2');
+
+ $this->assertEquals('hi2', $tree->getNodeForPath('hi')->getName());
+ $this->assertTrue($tree->getNodeForPath('hi')->isRenamed);
+
+ }
+
+ function testDeepMove() {
+
+ $tree = new TreeMock();
+ $tree->move('hi/sub','hi2');
+
+ $this->assertArrayHasKey('hi2', $tree->getNodeForPath('')->newDirectories);
+ $this->assertTrue($tree->getNodeForPath('hi/sub')->isDeleted);
+
+ }
+
+ function testDelete() {
+
+ $tree = new TreeMock();
+ $tree->delete('hi');
+ $this->assertTrue($tree->getNodeForPath('hi')->isDeleted);
+
+ }
+
+ function testGetChildren() {
+
+ $tree = new TreeMock();
+ $children = $tree->getChildren('');
+ $this->assertEquals(1,count($children));
+ $this->assertEquals('hi', $children[0]->getName());
+
+ }
+
+}
+
+class TreeMock extends Tree {
+
+ private $nodes = array();
+
+ function __construct() {
+
+ $this->nodes['hi/sub'] = new TreeDirectoryTester('sub');
+ $this->nodes['hi/file'] = new TreeFileTester('file');
+ $this->nodes['hi/file']->properties = array('test1' => 'value');
+ $this->nodes['hi/file']->data = 'foobar';
+ $this->nodes['hi'] = new TreeDirectoryTester('hi',array($this->nodes['hi/sub'], $this->nodes['hi/file']));
+ $this->nodes[''] = new TreeDirectoryTester('hi', array($this->nodes['hi']));
+
+ }
+
+ function getNodeForPath($path) {
+
+ if (isset($this->nodes[$path])) return $this->nodes[$path];
+ throw new Exception\NotFound('item not found');
+
+ }
+
+}
+
+class TreeDirectoryTester extends SimpleCollection {
+
+ public $newDirectories = array();
+ public $newFiles = array();
+ public $isDeleted = false;
+ public $isRenamed = false;
+
+ function createDirectory($name) {
+
+ $this->newDirectories[$name] = true;
+
+ }
+
+ function createFile($name,$data = null) {
+
+ $this->newFiles[$name] = $data;
+
+ }
+
+ function getChild($name) {
+
+ if (isset($this->newDirectories[$name])) return new TreeDirectoryTester($name);
+ if (isset($this->newFiles[$name])) return new TreeFileTester($name, $this->newFiles[$name]);
+ return parent::getChild($name);
+
+ }
+
+ function delete() {
+
+ $this->isDeleted = true;
+
+ }
+
+ function setName($name) {
+
+ $this->isRenamed = true;
+ $this->name = $name;
+
+ }
+
+}
+
+class TreeFileTester extends File implements IProperties {
+
+ public $name;
+ public $data;
+ public $properties;
+
+ function __construct($name, $data = null) {
+
+ $this->name = $name;
+ if (is_null($data)) $data = 'bla';
+ $this->data = $data;
+
+ }
+
+ function getName() {
+
+ return $this->name;
+
+ }
+
+ function get() {
+
+ return $this->data;
+
+ }
+
+ function getProperties($properties) {
+
+ return $this->properties;
+
+ }
+
+ function updateProperties($properties) {
+
+ $this->properties = $properties;
+ return true;
+
+ }
+
+}
+
diff --git a/vendor/sabre/dav/tests/Sabre/DAV/URLUtilTest.php b/vendor/sabre/dav/tests/Sabre/DAV/URLUtilTest.php
new file mode 100644
index 000000000..f17ca4b85
--- /dev/null
+++ b/vendor/sabre/dav/tests/Sabre/DAV/URLUtilTest.php
@@ -0,0 +1,131 @@
+<?php
+
+namespace Sabre\DAV;
+
+class URLUtilTest extends \PHPUnit_Framework_TestCase{
+
+ function testEncodePath() {
+
+ $str = '';
+ for($i=0;$i<128;$i++) $str.=chr($i);
+
+ $newStr = URLUtil::encodePath($str);
+
+ $this->assertEquals(
+ '%00%01%02%03%04%05%06%07%08%09%0a%0b%0c%0d%0e%0f'.
+ '%10%11%12%13%14%15%16%17%18%19%1a%1b%1c%1d%1e%1f'.
+ '%20%21%22%23%24%25%26%27()%2a%2b%2c-./'.
+ '0123456789%3a%3b%3c%3d%3e%3f'.
+ '%40ABCDEFGHIJKLMNO' .
+ 'PQRSTUVWXYZ%5b%5c%5d%5e_' .
+ '%60abcdefghijklmno' .
+ 'pqrstuvwxyz%7b%7c%7d~%7f',
+ $newStr);
+
+ $this->assertEquals($str,URLUtil::decodePath($newStr));
+
+ }
+
+ function testEncodePathSegment() {
+
+ $str = '';
+ for($i=0;$i<128;$i++) $str.=chr($i);
+
+ $newStr = URLUtil::encodePathSegment($str);
+
+ // Note: almost exactly the same as the last test, with the
+ // exception of the encoding of / (ascii code 2f)
+ $this->assertEquals(
+ '%00%01%02%03%04%05%06%07%08%09%0a%0b%0c%0d%0e%0f'.
+ '%10%11%12%13%14%15%16%17%18%19%1a%1b%1c%1d%1e%1f'.
+ '%20%21%22%23%24%25%26%27()%2a%2b%2c-.%2f'.
+ '0123456789%3a%3b%3c%3d%3e%3f'.
+ '%40ABCDEFGHIJKLMNO' .
+ 'PQRSTUVWXYZ%5b%5c%5d%5e_' .
+ '%60abcdefghijklmno' .
+ 'pqrstuvwxyz%7b%7c%7d~%7f',
+ $newStr);
+
+ $this->assertEquals($str,URLUtil::decodePathSegment($newStr));
+
+ }
+
+ function testDecode() {
+
+ $str = 'Hello%20Test+Test2.txt';
+ $newStr = URLUtil::decodePath($str);
+ $this->assertEquals('Hello Test+Test2.txt',$newStr);
+
+ }
+
+ /**
+ * @depends testDecode
+ */
+ function testDecodeUmlaut() {
+
+ $str = 'Hello%C3%BC.txt';
+ $newStr = URLUtil::decodePath($str);
+ $this->assertEquals("Hello\xC3\xBC.txt",$newStr);
+
+ }
+
+ /**
+ * @depends testDecodeUmlaut
+ */
+ function testDecodeUmlautLatin1() {
+
+ $str = 'Hello%FC.txt';
+ $newStr = URLUtil::decodePath($str);
+ $this->assertEquals("Hello\xC3\xBC.txt",$newStr);
+
+ }
+
+ /**
+ * This testcase was sent by a bug reporter
+ *
+ * @depends testDecode
+ */
+ function testDecodeAccentsWindows7() {
+
+ $str = '/webdav/%C3%A0fo%C3%B3';
+ $newStr = URLUtil::decodePath($str);
+ $this->assertEquals(strtolower($str),URLUtil::encodePath($newStr));
+
+ }
+
+ function testSplitPath() {
+
+ $strings = array(
+
+ // input // expected result
+ '/foo/bar' => array('/foo','bar'),
+ '/foo/bar/' => array('/foo','bar'),
+ 'foo/bar/' => array('foo','bar'),
+ 'foo/bar' => array('foo','bar'),
+ 'foo/bar/baz' => array('foo/bar','baz'),
+ 'foo/bar/baz/' => array('foo/bar','baz'),
+ 'foo' => array('','foo'),
+ 'foo/' => array('','foo'),
+ '/foo/' => array('','foo'),
+ '/foo' => array('','foo'),
+ '' => array(null,null),
+
+ // UTF-8
+ "/\xC3\xA0fo\xC3\xB3/bar" => array("/\xC3\xA0fo\xC3\xB3",'bar'),
+ "/\xC3\xA0foo/b\xC3\xBCr/" => array("/\xC3\xA0foo","b\xC3\xBCr"),
+ "foo/\xC3\xA0\xC3\xBCr" => array("foo","\xC3\xA0\xC3\xBCr"),
+
+ );
+
+ foreach($strings as $input => $expected) {
+
+ $output = URLUtil::splitPath($input);
+ $this->assertEquals($expected, $output, 'The expected output for \'' . $input . '\' was incorrect');
+
+
+ }
+
+
+ }
+
+}
diff --git a/vendor/sabre/dav/tests/Sabre/DAV/UUIDUtilTest.php b/vendor/sabre/dav/tests/Sabre/DAV/UUIDUtilTest.php
new file mode 100644
index 000000000..f005ecc75
--- /dev/null
+++ b/vendor/sabre/dav/tests/Sabre/DAV/UUIDUtilTest.php
@@ -0,0 +1,25 @@
+<?php
+
+namespace Sabre\DAV;
+
+class UUIDUtilTest extends \PHPUnit_Framework_TestCase {
+
+ function testValidateUUID() {
+
+ $this->assertTrue(
+ UUIDUtil::validateUUID('11111111-2222-3333-4444-555555555555')
+ );
+ $this->assertFalse(
+ UUIDUtil::validateUUID(' 11111111-2222-3333-4444-555555555555')
+ );
+ $this->assertTrue(
+ UUIDUtil::validateUUID('ffffffff-2222-3333-4444-555555555555')
+ );
+ $this->assertFalse(
+ UUIDUtil::validateUUID('fffffffg-2222-3333-4444-555555555555')
+ );
+
+
+ }
+
+}
diff --git a/vendor/sabre/dav/tests/Sabre/DAV/XMLUtilTest.php b/vendor/sabre/dav/tests/Sabre/DAV/XMLUtilTest.php
new file mode 100644
index 000000000..1d2bfd133
--- /dev/null
+++ b/vendor/sabre/dav/tests/Sabre/DAV/XMLUtilTest.php
@@ -0,0 +1,284 @@
+<?php
+
+namespace Sabre\DAV;
+
+class XMLUtilTest extends \PHPUnit_Framework_TestCase {
+
+ function testToClarkNotation() {
+
+ $dom = new \DOMDocument();
+ $dom->loadXML('<?xml version="1.0"?><test1 xmlns="http://www.example.org/">Testdoc</test1>');
+
+ $this->assertEquals(
+ '{http://www.example.org/}test1',
+ XMLUtil::toClarkNotation($dom->firstChild)
+ );
+
+ }
+
+ function testToClarkNotation2() {
+
+ $dom = new \DOMDocument();
+ $dom->loadXML('<?xml version="1.0"?><s:test1 xmlns:s="http://www.example.org/">Testdoc</s:test1>');
+
+ $this->assertEquals(
+ '{http://www.example.org/}test1',
+ XMLUtil::toClarkNotation($dom->firstChild)
+ );
+
+ }
+
+ function testToClarkNotationDAVNamespace() {
+
+ $dom = new \DOMDocument();
+ $dom->loadXML('<?xml version="1.0"?><s:test1 xmlns:s="urn:DAV">Testdoc</s:test1>');
+
+ $this->assertEquals(
+ '{DAV:}test1',
+ XMLUtil::toClarkNotation($dom->firstChild)
+ );
+
+ }
+
+ function testToClarkNotationNoElem() {
+
+ $dom = new \DOMDocument();
+ $dom->loadXML('<?xml version="1.0"?><s:test1 xmlns:s="urn:DAV">Testdoc</s:test1>');
+
+ $this->assertNull(
+ XMLUtil::toClarkNotation($dom->firstChild->firstChild)
+ );
+
+ }
+
+ function testConvertDAVNamespace() {
+
+ $xml='<?xml version="1.0"?><document xmlns="DAV:">blablabla</document>';
+ $this->assertEquals(
+ '<?xml version="1.0"?><document xmlns="urn:DAV">blablabla</document>',
+ XMLUtil::convertDAVNamespace($xml)
+ );
+
+ }
+
+ function testConvertDAVNamespace2() {
+
+ $xml='<?xml version="1.0"?><s:document xmlns:s="DAV:">blablabla</s:document>';
+ $this->assertEquals(
+ '<?xml version="1.0"?><s:document xmlns:s="urn:DAV">blablabla</s:document>',
+ XMLUtil::convertDAVNamespace($xml)
+ );
+
+ }
+
+ function testConvertDAVNamespace3() {
+
+ $xml='<?xml version="1.0"?><s:document xmlns="http://bla" xmlns:s="DAV:" xmlns:z="http://othernamespace">blablabla</s:document>';
+ $this->assertEquals(
+ '<?xml version="1.0"?><s:document xmlns="http://bla" xmlns:s="urn:DAV" xmlns:z="http://othernamespace">blablabla</s:document>',
+ XMLUtil::convertDAVNamespace($xml)
+ );
+
+ }
+
+ function testConvertDAVNamespace4() {
+
+ $xml='<?xml version="1.0"?><document xmlns=\'DAV:\'>blablabla</document>';
+ $this->assertEquals(
+ '<?xml version="1.0"?><document xmlns=\'urn:DAV\'>blablabla</document>',
+ XMLUtil::convertDAVNamespace($xml)
+ );
+
+ }
+
+ function testConvertDAVNamespaceMixedQuotes() {
+
+ $xml='<?xml version="1.0"?><document xmlns=\'DAV:" xmlns="Another attribute\'>blablabla</document>';
+ $this->assertEquals(
+ $xml,
+ XMLUtil::convertDAVNamespace($xml)
+ );
+
+ }
+
+ /**
+ * @depends testConvertDAVNamespace
+ */
+ function testLoadDOMDocument() {
+
+ $xml='<?xml version="1.0"?><document></document>';
+ $dom = XMLUtil::loadDOMDocument($xml);
+ $this->assertTrue($dom instanceof \DOMDocument);
+
+ }
+
+ /**
+ * @depends testLoadDOMDocument
+ * @expectedException Sabre\DAV\Exception\BadRequest
+ */
+ function testLoadDOMDocumentEmpty() {
+
+ XMLUtil::loadDOMDocument('');
+
+ }
+
+ /**
+ * @expectedException Sabre\DAV\Exception\BadRequest
+ * @depends testConvertDAVNamespace
+ */
+ function testLoadDOMDocumentInvalid() {
+
+ $xml='<?xml version="1.0"?><document></docu';
+ $dom = XMLUtil::loadDOMDocument($xml);
+
+ }
+
+ /**
+ * @depends testLoadDOMDocument
+ */
+ function testLoadDOMDocumentUTF16() {
+
+ $xml='<?xml version="1.0" encoding="UTF-16"?><root xmlns="DAV:">blabla</root>';
+ $xml = iconv('UTF-8','UTF-16LE',$xml);
+ $dom = XMLUtil::loadDOMDocument($xml);
+ $this->assertEquals('blabla',$dom->firstChild->nodeValue);
+
+ }
+
+
+ function testParseProperties() {
+
+ $xml='<?xml version="1.0"?>
+<root xmlns="DAV:">
+ <prop>
+ <displayname>Calendars</displayname>
+ </prop>
+</root>';
+
+ $dom = XMLUtil::loadDOMDocument($xml);
+ $properties = XMLUtil::parseProperties($dom->firstChild);
+
+ $this->assertEquals(array(
+ '{DAV:}displayname' => 'Calendars',
+ ), $properties);
+
+
+
+ }
+
+ /**
+ * @depends testParseProperties
+ */
+ function testParsePropertiesEmpty() {
+
+ $xml='<?xml version="1.0"?>
+<root xmlns="DAV:" xmlns:s="http://www.rooftopsolutions.nl/example">
+ <prop>
+ <displayname>Calendars</displayname>
+ </prop>
+ <prop>
+ <s:example />
+ </prop>
+</root>';
+
+ $dom = XMLUtil::loadDOMDocument($xml);
+ $properties = XMLUtil::parseProperties($dom->firstChild);
+
+ $this->assertEquals(array(
+ '{DAV:}displayname' => 'Calendars',
+ '{http://www.rooftopsolutions.nl/example}example' => null
+ ), $properties);
+
+ }
+
+
+ /**
+ * @depends testParseProperties
+ */
+ function testParsePropertiesComplex() {
+
+ $xml='<?xml version="1.0"?>
+<root xmlns="DAV:">
+ <prop>
+ <displayname>Calendars</displayname>
+ </prop>
+ <prop>
+ <someprop>Complex value <b>right here</b></someprop>
+ </prop>
+</root>';
+
+ $dom = XMLUtil::loadDOMDocument($xml);
+ $properties = XMLUtil::parseProperties($dom->firstChild);
+
+ $this->assertEquals(array(
+ '{DAV:}displayname' => 'Calendars',
+ '{DAV:}someprop' => 'Complex value right here',
+ ), $properties);
+
+ }
+
+
+ /**
+ * @depends testParseProperties
+ */
+ function testParsePropertiesNoProperties() {
+
+ $xml='<?xml version="1.0"?>
+<root xmlns="DAV:">
+ <prop>
+ </prop>
+</root>';
+
+ $dom = XMLUtil::loadDOMDocument($xml);
+ $properties = XMLUtil::parseProperties($dom->firstChild);
+
+ $this->assertEquals(array(), $properties);
+
+ }
+
+ function testParsePropertiesMapHref() {
+
+ $xml='<?xml version="1.0"?>
+<root xmlns="DAV:">
+ <prop>
+ <displayname>Calendars</displayname>
+ </prop>
+ <prop>
+ <someprop><href>http://sabredav.org/</href></someprop>
+ </prop>
+</root>';
+
+ $dom = XMLUtil::loadDOMDocument($xml);
+ $properties = XMLUtil::parseProperties($dom->firstChild,array('{DAV:}someprop'=>'Sabre\\DAV\\Property\\Href'));
+
+ $this->assertEquals(array(
+ '{DAV:}displayname' => 'Calendars',
+ '{DAV:}someprop' => new Property\Href('http://sabredav.org/',false),
+ ), $properties);
+
+ }
+
+ function testParseClarkNotation() {
+
+ $this->assertEquals(array(
+ 'DAV:',
+ 'foo',
+ ), XMLUtil::parseClarkNotation('{DAV:}foo'));
+
+ $this->assertEquals(array(
+ 'http://example.org/ns/bla',
+ 'bar-soap',
+ ), XMLUtil::parseClarkNotation('{http://example.org/ns/bla}bar-soap'));
+ }
+
+ /**
+ * @expectedException InvalidArgumentException
+ */
+ function testParseClarkNotationFail() {
+
+ XMLUtil::parseClarkNotation('}foo');
+
+ }
+
+}
+