aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/sabre/dav/tests/Sabre/CalDAV/SharingPluginTest.php
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2019-11-10 12:49:51 +0000
committerMario <mario@mariovavti.com>2019-11-10 14:10:03 +0100
commit580c3f4ffe9608d2beb56d418c68b3b112420e76 (patch)
tree82335d01179ac361d3f547a4b8e8c598d302e9f3 /vendor/sabre/dav/tests/Sabre/CalDAV/SharingPluginTest.php
parentd22766f458a8539a40a57f3946459a9be1f21cd6 (diff)
downloadvolse-hubzilla-580c3f4ffe9608d2beb56d418c68b3b112420e76.tar.gz
volse-hubzilla-580c3f4ffe9608d2beb56d418c68b3b112420e76.tar.bz2
volse-hubzilla-580c3f4ffe9608d2beb56d418c68b3b112420e76.zip
another bulk of composer updates
(cherry picked from commit 6685381fd8db507493c3d7c1793f8c05c681bbce)
Diffstat (limited to 'vendor/sabre/dav/tests/Sabre/CalDAV/SharingPluginTest.php')
-rw-r--r--vendor/sabre/dav/tests/Sabre/CalDAV/SharingPluginTest.php200
1 files changed, 94 insertions, 106 deletions
diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/SharingPluginTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/SharingPluginTest.php
index 9589176a3..57732cd06 100644
--- a/vendor/sabre/dav/tests/Sabre/CalDAV/SharingPluginTest.php
+++ b/vendor/sabre/dav/tests/Sabre/CalDAV/SharingPluginTest.php
@@ -1,36 +1,38 @@
<?php
+declare(strict_types=1);
+
namespace Sabre\CalDAV;
use Sabre\DAV;
use Sabre\DAV\Xml\Element\Sharee;
use Sabre\HTTP;
-class SharingPluginTest extends \Sabre\DAVServerTest {
-
+class SharingPluginTest extends \Sabre\DAVServerTest
+{
protected $setupCalDAV = true;
protected $setupCalDAVSharing = true;
protected $setupACL = true;
protected $autoLogin = 'user1';
- function setUp() {
-
+ public function setUp()
+ {
$this->caldavCalendars = [
[
'principaluri' => 'principals/user1',
- 'id' => 1,
- 'uri' => 'cal1',
+ 'id' => 1,
+ 'uri' => 'cal1',
],
[
'principaluri' => 'principals/user1',
- 'id' => 2,
- 'uri' => 'cal2',
+ 'id' => 2,
+ 'uri' => 'cal2',
'share-access' => \Sabre\DAV\Sharing\Plugin::ACCESS_READWRITE,
],
[
'principaluri' => 'principals/user1',
- 'id' => 3,
- 'uri' => 'cal3',
+ 'id' => 3,
+ 'uri' => 'cal3',
],
];
@@ -38,86 +40,79 @@ class SharingPluginTest extends \Sabre\DAVServerTest {
// Making the logged in user an admin, for full access:
$this->aclPlugin->adminPrincipals[] = 'principals/user2';
-
}
- function testSimple() {
-
+ public function testSimple()
+ {
$this->assertInstanceOf('Sabre\\CalDAV\\SharingPlugin', $this->server->getPlugin('caldav-sharing'));
$this->assertEquals(
'caldav-sharing',
$this->caldavSharingPlugin->getPluginInfo()['name']
);
-
}
/**
* @expectedException \LogicException
*/
- function testSetupWithoutCoreSharingPlugin() {
-
+ public function testSetupWithoutCoreSharingPlugin()
+ {
$server = new DAV\Server();
$server->addPlugin(
new SharingPlugin()
);
-
}
- function testGetFeatures() {
-
+ public function testGetFeatures()
+ {
$this->assertEquals(['calendarserver-sharing'], $this->caldavSharingPlugin->getFeatures());
-
}
- function testBeforeGetShareableCalendar() {
-
+ public function testBeforeGetShareableCalendar()
+ {
// Forcing the server to authenticate:
- $this->authPlugin->beforeMethod(new HTTP\Request(), new HTTP\Response());
+ $this->authPlugin->beforeMethod(new HTTP\Request('GET', '/'), new HTTP\Response());
$props = $this->server->getProperties('calendars/user1/cal1', [
- '{' . Plugin::NS_CALENDARSERVER . '}invite',
- '{' . Plugin::NS_CALENDARSERVER . '}allowed-sharing-modes',
+ '{'.Plugin::NS_CALENDARSERVER.'}invite',
+ '{'.Plugin::NS_CALENDARSERVER.'}allowed-sharing-modes',
]);
- $this->assertInstanceOf('Sabre\\CalDAV\\Xml\\Property\\Invite', $props['{' . Plugin::NS_CALENDARSERVER . '}invite']);
- $this->assertInstanceOf('Sabre\\CalDAV\\Xml\\Property\\AllowedSharingModes', $props['{' . Plugin::NS_CALENDARSERVER . '}allowed-sharing-modes']);
-
+ $this->assertInstanceOf('Sabre\\CalDAV\\Xml\\Property\\Invite', $props['{'.Plugin::NS_CALENDARSERVER.'}invite']);
+ $this->assertInstanceOf('Sabre\\CalDAV\\Xml\\Property\\AllowedSharingModes', $props['{'.Plugin::NS_CALENDARSERVER.'}allowed-sharing-modes']);
}
- function testBeforeGetSharedCalendar() {
-
+ public function testBeforeGetSharedCalendar()
+ {
$props = $this->server->getProperties('calendars/user1/cal2', [
- '{' . Plugin::NS_CALENDARSERVER . '}shared-url',
- '{' . Plugin::NS_CALENDARSERVER . '}invite',
+ '{'.Plugin::NS_CALENDARSERVER.'}shared-url',
+ '{'.Plugin::NS_CALENDARSERVER.'}invite',
]);
- $this->assertInstanceOf('Sabre\\CalDAV\\Xml\\Property\\Invite', $props['{' . Plugin::NS_CALENDARSERVER . '}invite']);
+ $this->assertInstanceOf('Sabre\\CalDAV\\Xml\\Property\\Invite', $props['{'.Plugin::NS_CALENDARSERVER.'}invite']);
//$this->assertInstanceOf('Sabre\\DAV\\Xml\\Property\\Href', $props['{' . Plugin::NS_CALENDARSERVER . '}shared-url']);
-
}
- function testUpdateResourceType() {
-
+ public function testUpdateResourceType()
+ {
$this->caldavBackend->updateInvites(1,
[
new Sharee([
'href' => 'mailto:joe@example.org',
- ])
+ ]),
]
);
$result = $this->server->updateProperties('calendars/user1/cal1', [
- '{DAV:}resourcetype' => new DAV\Xml\Property\ResourceType(['{DAV:}collection'])
+ '{DAV:}resourcetype' => new DAV\Xml\Property\ResourceType(['{DAV:}collection']),
]);
$this->assertEquals([
- '{DAV:}resourcetype' => 200
+ '{DAV:}resourcetype' => 200,
], $result);
$this->assertEquals(0, count($this->caldavBackend->getInvites(1)));
-
}
- function testUpdatePropertiesPassThru() {
-
+ public function testUpdatePropertiesPassThru()
+ {
$result = $this->server->updateProperties('calendars/user1/cal3', [
'{DAV:}foo' => 'bar',
]);
@@ -125,52 +120,48 @@ class SharingPluginTest extends \Sabre\DAVServerTest {
$this->assertEquals([
'{DAV:}foo' => 200,
], $result);
-
}
- function testUnknownMethodNoPOST() {
-
+ public function testUnknownMethodNoPOST()
+ {
$request = HTTP\Sapi::createFromServerArray([
'REQUEST_METHOD' => 'PATCH',
- 'REQUEST_URI' => '/',
+ 'REQUEST_URI' => '/',
]);
$response = $this->request($request);
$this->assertEquals(501, $response->status, $response->body);
-
}
- function testUnknownMethodNoXML() {
-
+ public function testUnknownMethodNoXML()
+ {
$request = HTTP\Sapi::createFromServerArray([
'REQUEST_METHOD' => 'POST',
- 'REQUEST_URI' => '/',
- 'CONTENT_TYPE' => 'text/plain',
+ 'REQUEST_URI' => '/',
+ 'CONTENT_TYPE' => 'text/plain',
]);
$response = $this->request($request);
$this->assertEquals(501, $response->status, $response->body);
-
}
- function testUnknownMethodNoNode() {
-
+ public function testUnknownMethodNoNode()
+ {
$request = HTTP\Sapi::createFromServerArray([
'REQUEST_METHOD' => 'POST',
- 'REQUEST_URI' => '/foo',
- 'CONTENT_TYPE' => 'text/xml',
+ 'REQUEST_URI' => '/foo',
+ 'CONTENT_TYPE' => 'text/xml',
]);
$response = $this->request($request);
$this->assertEquals(501, $response->status, $response->body);
-
}
- function testShareRequest() {
-
+ public function testShareRequest()
+ {
$request = new HTTP\Request('POST', '/calendars/user1/cal1', ['Content-Type' => 'text/xml']);
$xml = <<<RRR
@@ -194,13 +185,13 @@ RRR;
$this->assertEquals(
[
new Sharee([
- 'href' => 'mailto:joe@example.org',
+ 'href' => 'mailto:joe@example.org',
'properties' => [
'{DAV:}displayname' => 'Joe Shmoe',
],
- 'access' => \Sabre\DAV\Sharing\Plugin::ACCESS_READWRITE,
+ 'access' => \Sabre\DAV\Sharing\Plugin::ACCESS_READWRITE,
'inviteStatus' => \Sabre\DAV\Sharing\Plugin::INVITE_NORESPONSE,
- 'comment' => '',
+ 'comment' => '',
]),
],
$this->caldavBackend->getInvites(1)
@@ -214,11 +205,10 @@ RRR;
$this->assertTrue(
$props['{DAV:}resourcetype']->is('{http://calendarserver.org/ns/}shared-owner')
);
-
}
- function testShareRequestNoShareableCalendar() {
-
+ public function testShareRequestNoShareableCalendar()
+ {
$request = new HTTP\Request(
'POST',
'/calendars/user1/cal2',
@@ -226,7 +216,7 @@ RRR;
);
$xml = '<?xml version="1.0"?>
-<cs:share xmlns:cs="' . Plugin::NS_CALENDARSERVER . '" xmlns:d="DAV:">
+<cs:share xmlns:cs="'.Plugin::NS_CALENDARSERVER.'" xmlns:d="DAV:">
<cs:set>
<d:href>mailto:joe@example.org</d:href>
<cs:common-name>Joe Shmoe</cs:common-name>
@@ -241,19 +231,18 @@ RRR;
$request->setBody($xml);
$response = $this->request($request, 403);
-
}
- function testInviteReply() {
-
+ public function testInviteReply()
+ {
$request = HTTP\Sapi::createFromServerArray([
'REQUEST_METHOD' => 'POST',
- 'REQUEST_URI' => '/calendars/user1',
- 'CONTENT_TYPE' => 'text/xml',
+ 'REQUEST_URI' => '/calendars/user1',
+ 'CONTENT_TYPE' => 'text/xml',
]);
$xml = '<?xml version="1.0"?>
-<cs:invite-reply xmlns:cs="' . Plugin::NS_CALENDARSERVER . '" xmlns:d="DAV:">
+<cs:invite-reply xmlns:cs="'.Plugin::NS_CALENDARSERVER.'" xmlns:d="DAV:">
<cs:hosturl><d:href>/principals/owner</d:href></cs:hosturl>
<cs:invite-accepted />
</cs:invite-reply>
@@ -262,37 +251,35 @@ RRR;
$request->setBody($xml);
$response = $this->request($request);
$this->assertEquals(200, $response->status, $response->body);
-
}
- function testInviteBadXML() {
-
+ public function testInviteBadXML()
+ {
$request = HTTP\Sapi::createFromServerArray([
'REQUEST_METHOD' => 'POST',
- 'REQUEST_URI' => '/calendars/user1',
- 'CONTENT_TYPE' => 'text/xml',
+ 'REQUEST_URI' => '/calendars/user1',
+ 'CONTENT_TYPE' => 'text/xml',
]);
$xml = '<?xml version="1.0"?>
-<cs:invite-reply xmlns:cs="' . Plugin::NS_CALENDARSERVER . '" xmlns:d="DAV:">
+<cs:invite-reply xmlns:cs="'.Plugin::NS_CALENDARSERVER.'" xmlns:d="DAV:">
</cs:invite-reply>
';
$request->setBody($xml);
$response = $this->request($request);
$this->assertEquals(400, $response->status, $response->body);
-
}
- function testInviteWrongUrl() {
-
+ public function testInviteWrongUrl()
+ {
$request = HTTP\Sapi::createFromServerArray([
'REQUEST_METHOD' => 'POST',
- 'REQUEST_URI' => '/calendars/user1/cal1',
- 'CONTENT_TYPE' => 'text/xml',
+ 'REQUEST_URI' => '/calendars/user1/cal1',
+ 'CONTENT_TYPE' => 'text/xml',
]);
$xml = '<?xml version="1.0"?>
-<cs:invite-reply xmlns:cs="' . Plugin::NS_CALENDARSERVER . '" xmlns:d="DAV:">
+<cs:invite-reply xmlns:cs="'.Plugin::NS_CALENDARSERVER.'" xmlns:d="DAV:">
<cs:hosturl><d:href>/principals/owner</d:href></cs:hosturl>
</cs:invite-reply>
';
@@ -303,27 +290,33 @@ RRR;
// If the plugin did not handle this request, it must ensure that the
// body is still accessible by other plugins.
$this->assertEquals($xml, $request->getBody(true));
-
}
- function testPublish() {
+ public function testPostWithoutContentType()
+ {
+ $request = new HTTP\Request('POST', '/');
+ $response = new HTTP\ResponseMock();
+
+ $this->caldavSharingPlugin->httpPost($request, $response);
+ $this->assertTrue(true);
+ }
+ public function testPublish()
+ {
$request = new HTTP\Request('POST', '/calendars/user1/cal1', ['Content-Type' => 'text/xml']);
$xml = '<?xml version="1.0"?>
-<cs:publish-calendar xmlns:cs="' . Plugin::NS_CALENDARSERVER . '" xmlns:d="DAV:" />
+<cs:publish-calendar xmlns:cs="'.Plugin::NS_CALENDARSERVER.'" xmlns:d="DAV:" />
';
$request->setBody($xml);
$response = $this->request($request);
$this->assertEquals(202, $response->status, $response->body);
-
}
-
- function testUnpublish() {
-
+ public function testUnpublish()
+ {
$request = new HTTP\Request(
'POST',
'/calendars/user1/cal1',
@@ -331,18 +324,17 @@ RRR;
);
$xml = '<?xml version="1.0"?>
-<cs:unpublish-calendar xmlns:cs="' . Plugin::NS_CALENDARSERVER . '" xmlns:d="DAV:" />
+<cs:unpublish-calendar xmlns:cs="'.Plugin::NS_CALENDARSERVER.'" xmlns:d="DAV:" />
';
$request->setBody($xml);
$response = $this->request($request);
$this->assertEquals(200, $response->status, $response->body);
-
}
- function testPublishWrongUrl() {
-
+ public function testPublishWrongUrl()
+ {
$request = new HTTP\Request(
'POST',
'/calendars/user1',
@@ -350,34 +342,31 @@ RRR;
);
$xml = '<?xml version="1.0"?>
-<cs:publish-calendar xmlns:cs="' . Plugin::NS_CALENDARSERVER . '" xmlns:d="DAV:" />
+<cs:publish-calendar xmlns:cs="'.Plugin::NS_CALENDARSERVER.'" xmlns:d="DAV:" />
';
$request->setBody($xml);
$this->request($request, 501);
-
}
- function testUnpublishWrongUrl() {
-
+ public function testUnpublishWrongUrl()
+ {
$request = new HTTP\Request(
'POST',
'/calendars/user1',
['Content-Type' => 'text/xml']
);
$xml = '<?xml version="1.0"?>
-<cs:unpublish-calendar xmlns:cs="' . Plugin::NS_CALENDARSERVER . '" xmlns:d="DAV:" />
+<cs:unpublish-calendar xmlns:cs="'.Plugin::NS_CALENDARSERVER.'" xmlns:d="DAV:" />
';
$request->setBody($xml);
$this->request($request, 501);
-
}
- function testUnknownXmlDoc() {
-
-
+ public function testUnknownXmlDoc()
+ {
$request = new HTTP\Request(
'POST',
'/calendars/user1/cal2',
@@ -385,12 +374,11 @@ RRR;
);
$xml = '<?xml version="1.0"?>
-<cs:foo-bar xmlns:cs="' . Plugin::NS_CALENDARSERVER . '" xmlns:d="DAV:" />';
+<cs:foo-bar xmlns:cs="'.Plugin::NS_CALENDARSERVER.'" xmlns:d="DAV:" />';
$request->setBody($xml);
$response = $this->request($request);
$this->assertEquals(501, $response->status, $response->body);
-
}
}