aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/sabre/dav/tests/Sabre/DAVServerTest.php
diff options
context:
space:
mode:
authorredmatrix <git@macgirvin.com>2016-05-10 17:26:44 -0700
committerredmatrix <git@macgirvin.com>2016-05-10 17:26:44 -0700
commit0b02a6d123b2014705998c94ddf3d460948d3eac (patch)
tree78ff2cab9944a4f5ab3f80ec93cbe1120de90bb2 /vendor/sabre/dav/tests/Sabre/DAVServerTest.php
parent40b5b6e9d2da7ab65c8b4d38cdceac83a4d78deb (diff)
downloadvolse-hubzilla-0b02a6d123b2014705998c94ddf3d460948d3eac.tar.gz
volse-hubzilla-0b02a6d123b2014705998c94ddf3d460948d3eac.tar.bz2
volse-hubzilla-0b02a6d123b2014705998c94ddf3d460948d3eac.zip
initial sabre upgrade (needs lots of work - to wit: authentication, redo the browser interface, and rework event export/import)
Diffstat (limited to 'vendor/sabre/dav/tests/Sabre/DAVServerTest.php')
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAVServerTest.php120
1 files changed, 95 insertions, 25 deletions
diff --git a/vendor/sabre/dav/tests/Sabre/DAVServerTest.php b/vendor/sabre/dav/tests/Sabre/DAVServerTest.php
index 207687d90..d329b5b05 100644
--- a/vendor/sabre/dav/tests/Sabre/DAVServerTest.php
+++ b/vendor/sabre/dav/tests/Sabre/DAVServerTest.php
@@ -2,17 +2,9 @@
namespace Sabre;
-require_once 'Sabre/HTTP/ResponseMock.php';
-
-require_once 'Sabre/DAV/Auth/Backend/Mock.php';
-require_once 'Sabre/DAV/Mock/File.php';
-require_once 'Sabre/DAV/Mock/Collection.php';
-
-require_once 'Sabre/DAVACL/PrincipalBackend/Mock.php';
-
-require_once 'Sabre/CalDAV/Backend/Mock.php';
-
-require_once 'Sabre/CardDAV/Backend/Mock.php';
+use Sabre\HTTP\Request;
+use Sabre\HTTP\Response;
+use Sabre\HTTP\Sapi;
/**
* This class may be used as a basis for other webdav-related unittests.
@@ -20,7 +12,7 @@ require_once 'Sabre/CardDAV/Backend/Mock.php';
* This class is supposed to provide a reasonably big framework to quickly get
* a testing environment running.
*
- * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/).
+ * @copyright Copyright (C) fruux GmbH (https://fruux.com/)
* @author Evert Pot (http://evertpot.com/)
* @license http://sabre.io/license/ Modified BSD License
*/
@@ -30,22 +22,35 @@ abstract class DAVServerTest extends \PHPUnit_Framework_TestCase {
protected $setupCardDAV = false;
protected $setupACL = false;
protected $setupCalDAVSharing = false;
+ protected $setupCalDAVScheduling = false;
+ protected $setupCalDAVSubscriptions = false;
+ protected $setupCalDAVICSExport = false;
+ protected $setupLocks = false;
+ protected $setupFiles = false;
+ protected $setupPropertyStorage = false;
- protected $caldavCalendars = array();
- protected $caldavCalendarObjects = array();
+ /**
+ * An array with calendars. Every calendar should have
+ * - principaluri
+ * - uri
+ */
+ protected $caldavCalendars = [];
+ protected $caldavCalendarObjects = [];
- protected $carddavAddressBooks = array();
- protected $carddavCards = array();
+ protected $carddavAddressBooks = [];
+ protected $carddavCards = [];
/**
* @var Sabre\DAV\Server
*/
protected $server;
- protected $tree = array();
+ protected $tree = [];
protected $caldavBackend;
protected $carddavBackend;
protected $principalBackend;
+ protected $locksBackend;
+ protected $propertyStorageBackend;
/**
* @var Sabre\CalDAV\Plugin
@@ -68,11 +73,28 @@ abstract class DAVServerTest extends \PHPUnit_Framework_TestCase {
protected $caldavSharingPlugin;
/**
+ * CalDAV scheduling plugin
+ *
+ * @var CalDAV\Schedule\Plugin
+ */
+ protected $caldavSchedulePlugin;
+
+ /**
* @var Sabre\DAV\Auth\Plugin
*/
protected $authPlugin;
/**
+ * @var Sabre\DAV\Locks\Plugin
+ */
+ protected $locksPlugin;
+
+ /**
+ * @var Sabre\DAV\PropertyStorage\Plugin
+ */
+ protected $propertyStoragePlugin;
+
+ /**
* If this string is set, we will automatically log in the user with this
* name.
*/
@@ -84,6 +106,7 @@ abstract class DAVServerTest extends \PHPUnit_Framework_TestCase {
$this->setUpTree();
$this->server = new DAV\Server($this->tree);
+ $this->server->sapi = new HTTP\SapiMock();
$this->server->debugExceptions = true;
if ($this->setupCalDAV) {
@@ -94,6 +117,17 @@ abstract class DAVServerTest extends \PHPUnit_Framework_TestCase {
$this->caldavSharingPlugin = new CalDAV\SharingPlugin();
$this->server->addPlugin($this->caldavSharingPlugin);
}
+ if ($this->setupCalDAVScheduling) {
+ $this->caldavSchedulePlugin = new CalDAV\Schedule\Plugin();
+ $this->server->addPlugin($this->caldavSchedulePlugin);
+ }
+ if ($this->setupCalDAVSubscriptions) {
+ $this->server->addPlugin(new CalDAV\Subscriptions\Plugin());
+ }
+ if ($this->setupCalDAVICSExport) {
+ $this->caldavICSExportPlugin = new CalDAV\ICSExportPlugin();
+ $this->server->addPlugin($this->caldavICSExportPlugin);
+ }
if ($this->setupCardDAV) {
$this->carddavPlugin = new CardDAV\Plugin();
$this->server->addPlugin($this->carddavPlugin);
@@ -102,14 +136,26 @@ abstract class DAVServerTest extends \PHPUnit_Framework_TestCase {
$this->aclPlugin = new DAVACL\Plugin();
$this->server->addPlugin($this->aclPlugin);
}
+ if ($this->setupLocks) {
+ $this->locksPlugin = new DAV\Locks\Plugin(
+ $this->locksBackend
+ );
+ $this->server->addPlugin($this->locksPlugin);
+ }
+ if ($this->setupPropertyStorage) {
+ $this->propertyStoragePlugin = new DAV\PropertyStorage\Plugin(
+ $this->propertyStorageBackend
+ );
+ $this->server->addPlugin($this->propertyStoragePlugin);
+ }
if ($this->autoLogin) {
$authBackend = new DAV\Auth\Backend\Mock();
- $authBackend->defaultUser = $this->autoLogin;
- $this->authPlugin = new DAV\Auth\Plugin($authBackend, 'SabreDAV');
+ $authBackend->setPrincipal('principals/' . $this->autoLogin);
+ $this->authPlugin = new DAV\Auth\Plugin($authBackend);
$this->server->addPlugin($this->authPlugin);
// This will trigger the actual login procedure
- $this->authPlugin->beforeMethod('OPTIONS','/');
+ $this->authPlugin->beforeMethod(new Request(), new Response());
}
}
@@ -126,7 +172,7 @@ abstract class DAVServerTest extends \PHPUnit_Framework_TestCase {
function request($request) {
if (is_array($request)) {
- $request = new HTTP\Request($request);
+ $request = HTTP\Request::createFromServerArray($request);
}
$this->server->httpRequest = $request;
$this->server->httpResponse = new HTTP\ResponseMock();
@@ -136,10 +182,13 @@ abstract class DAVServerTest extends \PHPUnit_Framework_TestCase {
}
+ /**
+ * Override this to provide your own Tree for your test-case.
+ */
function setUpTree() {
if ($this->setupCalDAV) {
- $this->tree[] = new CalDAV\CalendarRootNode(
+ $this->tree[] = new CalDAV\CalendarRoot(
$this->principalBackend,
$this->caldavBackend
);
@@ -152,17 +201,32 @@ abstract class DAVServerTest extends \PHPUnit_Framework_TestCase {
}
if ($this->setupCardDAV || $this->setupCalDAV) {
- $this->tree[] = new DAVACL\PrincipalCollection(
+ $this->tree[] = new CalDAV\Principal\Collection(
$this->principalBackend
);
}
+ if ($this->setupFiles) {
+
+ $this->tree[] = new DAV\Mock\Collection('files');
+
+ }
}
function setUpBackends() {
+ if ($this->setupCalDAVSharing && is_null($this->caldavBackend)) {
+ $this->caldavBackend = new CalDAV\Backend\MockSharing($this->caldavCalendars, $this->caldavCalendarObjects);
+ }
+ if ($this->setupCalDAVSubscriptions && is_null($this->caldavBackend)) {
+ $this->caldavBackend = new CalDAV\Backend\MockSubscriptionSupport($this->caldavCalendars, $this->caldavCalendarObjects);
+ }
if ($this->setupCalDAV && is_null($this->caldavBackend)) {
- $this->caldavBackend = new CalDAV\Backend\Mock($this->caldavCalendars, $this->caldavCalendarObjects);
+ if ($this->setupCalDAVScheduling) {
+ $this->caldavBackend = new CalDAV\Backend\MockScheduling($this->caldavCalendars, $this->caldavCalendarObjects);
+ } else {
+ $this->caldavBackend = new CalDAV\Backend\Mock($this->caldavCalendars, $this->caldavCalendarObjects);
+ }
}
if ($this->setupCardDAV && is_null($this->carddavBackend)) {
$this->carddavBackend = new CardDAV\Backend\Mock($this->carddavAddressBooks, $this->carddavCards);
@@ -170,6 +234,12 @@ abstract class DAVServerTest extends \PHPUnit_Framework_TestCase {
if ($this->setupCardDAV || $this->setupCalDAV) {
$this->principalBackend = new DAVACL\PrincipalBackend\Mock();
}
+ if ($this->setupLocks) {
+ $this->locksBackend = new DAV\Locks\Backend\Mock();
+ }
+ if ($this->setupPropertyStorage) {
+ $this->propertyStorageBackend = new DAV\PropertyStorage\Backend\Mock();
+ }
}
@@ -177,7 +247,7 @@ abstract class DAVServerTest extends \PHPUnit_Framework_TestCase {
function assertHTTPStatus($expectedStatus, HTTP\Request $req) {
$resp = $this->request($req);
- $this->assertEquals($resp->getStatusMessage($expectedStatus), $resp->status,'Incorrect HTTP status received: ' . $resp->body);
+ $this->assertEquals((int)$expectedStatus, (int)$resp->status, 'Incorrect HTTP status received: ' . $resp->body);
}