diff options
Diffstat (limited to 'vendor/sabre/dav/tests/Sabre/CalDAV/Notifications')
5 files changed, 616 insertions, 0 deletions
diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/Notifications/CollectionTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/Notifications/CollectionTest.php new file mode 100644 index 000000000..eaed4f503 --- /dev/null +++ b/vendor/sabre/dav/tests/Sabre/CalDAV/Notifications/CollectionTest.php @@ -0,0 +1,90 @@ +<?php + +namespace Sabre\CalDAV\Notifications; + +use Sabre\CalDAV; + +class CollectionTest extends \PHPUnit_Framework_TestCase { + + protected $caldavBackend; + protected $principalUri; + protected $notification; + + function getInstance() { + + $this->principalUri = 'principals/user1'; + + $this->notification = new Notification\SystemStatus(1,'"1"'); + + $this->caldavBackend = new CalDAV\Backend\Mock(array(),array(), array( + 'principals/user1' => array( + $this->notification + ) + )); + + return new Collection($this->caldavBackend, $this->principalUri); + + } + + function testGetChildren() { + + $col = $this->getInstance(); + $this->assertEquals('notifications', $col->getName()); + + $this->assertEquals(array( + new Node($this->caldavBackend, $this->principalUri, $this->notification) + ), $col->getChildren()); + + } + + function testGetOwner() { + + $col = $this->getInstance(); + $this->assertEquals('principals/user1', $col->getOwner()); + + } + + function testGetGroup() { + + $col = $this->getInstance(); + $this->assertNull($col->getGroup()); + + } + + function testGetACL() { + + $col = $this->getInstance(); + $expected = array( + array( + 'privilege' => '{DAV:}read', + 'principal' => $this->principalUri, + 'protected' => true, + ), + array( + 'privilege' => '{DAV:}write', + 'principal' => $this->principalUri, + 'protected' => true, + ), + ); + + $this->assertEquals($expected, $col->getACL()); + + } + + /** + * @expectedException Sabre\DAV\Exception\NotImplemented + */ + function testSetACL() { + + $col = $this->getInstance(); + $col->setACL(array()); + + } + + function testGetSupportedPrivilegeSet() { + + $col = $this->getInstance(); + $this->assertNull($col->getSupportedPrivilegeSet()); + + } +} diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/Notifications/NodeTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/Notifications/NodeTest.php new file mode 100644 index 000000000..28e43ce08 --- /dev/null +++ b/vendor/sabre/dav/tests/Sabre/CalDAV/Notifications/NodeTest.php @@ -0,0 +1,101 @@ +<?php + +namespace Sabre\CalDAV\Notifications; + +use Sabre\CalDAV; + +class NodeTest extends \PHPUnit_Framework_TestCase { + + protected $systemStatus; + protected $caldavBackend; + + function getInstance() { + + $principalUri = 'principals/user1'; + + $this->systemStatus = new Notification\SystemStatus(1,'"1"'); + + $this->caldavBackend = new CalDAV\Backend\Mock(array(),array(), array( + 'principals/user1' => array( + $this->systemStatus + ) + )); + + $node = new Node($this->caldavBackend, 'principals/user1', $this->systemStatus); + return $node; + + } + + function testGetId() { + + $node = $this->getInstance(); + $this->assertEquals($this->systemStatus->getId() . '.xml', $node->getName()); + + } + + function testGetEtag() { + + $node = $this->getInstance(); + $this->assertEquals('"1"', $node->getETag()); + + } + + function testGetNotificationType() { + + $node = $this->getInstance(); + $this->assertEquals($this->systemStatus, $node->getNotificationType()); + + } + + function testDelete() { + + $node = $this->getInstance(); + $node->delete(); + $this->assertEquals(array(), $this->caldavBackend->getNotificationsForPrincipal('principals/user1')); + + } + + function testGetGroup() { + + $node = $this->getInstance(); + $this->assertNull($node->getGroup()); + + } + + function testGetACL() { + + $node = $this->getInstance(); + $expected = array( + array( + 'privilege' => '{DAV:}read', + 'principal' => 'principals/user1', + 'protected' => true, + ), + array( + 'privilege' => '{DAV:}write', + 'principal' => 'principals/user1', + 'protected' => true, + ), + ); + + $this->assertEquals($expected, $node->getACL()); + + } + + /** + * @expectedException Sabre\DAV\Exception\NotImplemented + */ + function testSetACL() { + + $node = $this->getInstance(); + $node->setACL(array()); + + } + + function testGetSupportedPrivilegeSet() { + + $node = $this->getInstance(); + $this->assertNull($node->getSupportedPrivilegeSet()); + + } +} diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/Notifications/Notification/InviteReplyTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/Notifications/Notification/InviteReplyTest.php new file mode 100644 index 000000000..c53f68cee --- /dev/null +++ b/vendor/sabre/dav/tests/Sabre/CalDAV/Notifications/Notification/InviteReplyTest.php @@ -0,0 +1,134 @@ +<?php + +namespace Sabre\CalDAV\Notifications\Notification; + +use Sabre\CalDAV; +use Sabre\DAV; + +class InviteReplyTest extends \PHPUnit_Framework_TestCase { + + /** + * @dataProvider dataProvider + */ + function testSerializers($notification, $expected) { + + $notification = new InviteReply($notification); + + $this->assertEquals('foo', $notification->getId()); + $this->assertEquals('"1"', $notification->getETag()); + + $simpleExpected = '<?xml version="1.0" encoding="UTF-8"?>' . "\n" . '<cs:root xmlns:cs="http://calendarserver.org/ns/"><cs:invite-reply/></cs:root>' . "\n"; + + $dom = new \DOMDocument('1.0','UTF-8'); + $elem = $dom->createElement('cs:root'); + $elem->setAttribute('xmlns:cs',CalDAV\Plugin::NS_CALENDARSERVER); + $dom->appendChild($elem); + $notification->serialize(new DAV\Server(), $elem); + $this->assertEquals($simpleExpected, $dom->saveXML()); + + $dom = new \DOMDocument('1.0','UTF-8'); + $dom->formatOutput = true; + $elem = $dom->createElement('cs:root'); + $elem->setAttribute('xmlns:cs',CalDAV\Plugin::NS_CALENDARSERVER); + $elem->setAttribute('xmlns:d','DAV:'); + $dom->appendChild($elem); + $notification->serializeBody(new DAV\Server(), $elem); + $this->assertEquals($expected, $dom->saveXML()); + + + } + + function dataProvider() { + + $dtStamp = new \DateTime('2012-01-01 00:00:00 GMT'); + return array( + array( + array( + 'id' => 'foo', + 'dtStamp' => $dtStamp, + 'etag' => '"1"', + 'inReplyTo' => 'bar', + 'href' => 'mailto:foo@example.org', + 'type' => CalDAV\SharingPlugin::STATUS_ACCEPTED, + 'hostUrl' => 'calendar' + ), +<<<FOO +<?xml version="1.0" encoding="UTF-8"?> +<cs:root xmlns:cs="http://calendarserver.org/ns/" xmlns:d="DAV:"> + <cs:dtstamp>20120101T000000Z</cs:dtstamp> + <cs:invite-reply> + <cs:uid>foo</cs:uid> + <cs:in-reply-to>bar</cs:in-reply-to> + <d:href>mailto:foo@example.org</d:href> + <cs:invite-accepted/> + <cs:hosturl> + <d:href>/calendar</d:href> + </cs:hosturl> + </cs:invite-reply> +</cs:root> + +FOO + ), + array( + array( + 'id' => 'foo', + 'dtStamp' => $dtStamp, + 'etag' => '"1"', + 'inReplyTo' => 'bar', + 'href' => 'mailto:foo@example.org', + 'type' => CalDAV\SharingPlugin::STATUS_DECLINED, + 'hostUrl' => 'calendar', + 'summary' => 'Summary!' + ), +<<<FOO +<?xml version="1.0" encoding="UTF-8"?> +<cs:root xmlns:cs="http://calendarserver.org/ns/" xmlns:d="DAV:"> + <cs:dtstamp>20120101T000000Z</cs:dtstamp> + <cs:invite-reply> + <cs:uid>foo</cs:uid> + <cs:in-reply-to>bar</cs:in-reply-to> + <d:href>mailto:foo@example.org</d:href> + <cs:invite-declined/> + <cs:hosturl> + <d:href>/calendar</d:href> + </cs:hosturl> + <cs:summary>Summary!</cs:summary> + </cs:invite-reply> +</cs:root> + +FOO + ), + + ); + + } + + /** + * @expectedException InvalidArgumentException + */ + function testMissingArg() { + + new InviteReply(array()); + + } + + /** + * @expectedException InvalidArgumentException + */ + function testUnknownArg() { + + new InviteReply(array( + 'foo-i-will-break' => true, + + 'id' => 1, + 'etag' => '"bla"', + 'href' => 'abc', + 'dtStamp' => 'def', + 'inReplyTo' => 'qrs', + 'type' => 'ghi', + 'hostUrl' => 'jkl', + )); + + } + +} diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/Notifications/Notification/InviteTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/Notifications/Notification/InviteTest.php new file mode 100644 index 000000000..d2c114f4c --- /dev/null +++ b/vendor/sabre/dav/tests/Sabre/CalDAV/Notifications/Notification/InviteTest.php @@ -0,0 +1,230 @@ +<?php + +namespace Sabre\CalDAV\Notifications\Notification; + +use Sabre\CalDAV; +use Sabre\DAV; + +class InviteTest extends \PHPUnit_Framework_TestCase { + + /** + * @dataProvider dataProvider + */ + function testSerializers($notification, $expected) { + + $notification = new Invite($notification); + + $this->assertEquals('foo', $notification->getId()); + $this->assertEquals('"1"', $notification->getETag()); + + $simpleExpected = '<?xml version="1.0" encoding="UTF-8"?>' . "\n" . '<cs:root xmlns:cs="http://calendarserver.org/ns/"><cs:invite-notification/></cs:root>' . "\n"; + + $dom = new \DOMDocument('1.0','UTF-8'); + $elem = $dom->createElement('cs:root'); + $elem->setAttribute('xmlns:cs',CalDAV\Plugin::NS_CALENDARSERVER); + $dom->appendChild($elem); + $notification->serialize(new DAV\Server(), $elem); + $this->assertEquals($simpleExpected, $dom->saveXML()); + + $dom = new \DOMDocument('1.0','UTF-8'); + $dom->formatOutput = true; + $elem = $dom->createElement('cs:root'); + $elem->setAttribute('xmlns:cs',CalDAV\Plugin::NS_CALENDARSERVER); + $elem->setAttribute('xmlns:d','DAV:'); + $elem->setAttribute('xmlns:cal',CalDAV\Plugin::NS_CALDAV); + $dom->appendChild($elem); + $notification->serializeBody(new DAV\Server(), $elem); + $this->assertEquals($expected, $dom->saveXML()); + + + } + + function dataProvider() { + + $dtStamp = new \DateTime('2012-01-01 00:00:00', new \DateTimeZone('GMT')); + return array( + array( + array( + 'id' => 'foo', + 'dtStamp' => $dtStamp, + 'etag' => '"1"', + 'href' => 'mailto:foo@example.org', + 'type' => CalDAV\SharingPlugin::STATUS_ACCEPTED, + 'readOnly' => true, + 'hostUrl' => 'calendar', + 'organizer' => 'principal/user1', + 'commonName' => 'John Doe', + 'summary' => 'Awesome stuff!' + ), +<<<FOO +<?xml version="1.0" encoding="UTF-8"?> +<cs:root xmlns:cs="http://calendarserver.org/ns/" xmlns:d="DAV:" xmlns:cal="urn:ietf:params:xml:ns:caldav"> + <cs:dtstamp>20120101T000000Z</cs:dtstamp> + <cs:invite-notification> + <cs:uid>foo</cs:uid> + <d:href>mailto:foo@example.org</d:href> + <cs:invite-accepted/> + <cs:hosturl> + <d:href>/calendar</d:href> + </cs:hosturl> + <cs:access> + <cs:read/> + </cs:access> + <cs:organizer-cn>John Doe</cs:organizer-cn> + <cs:organizer> + <d:href>/principal/user1</d:href> + <cs:common-name>John Doe</cs:common-name> + </cs:organizer> + <cs:summary>Awesome stuff!</cs:summary> + </cs:invite-notification> +</cs:root> + +FOO + ), + array( + array( + 'id' => 'foo', + 'dtStamp' => $dtStamp, + 'etag' => '"1"', + 'href' => 'mailto:foo@example.org', + 'type' => CalDAV\SharingPlugin::STATUS_DECLINED, + 'readOnly' => true, + 'hostUrl' => 'calendar', + 'organizer' => 'principal/user1', + 'commonName' => 'John Doe', + ), +<<<FOO +<?xml version="1.0" encoding="UTF-8"?> +<cs:root xmlns:cs="http://calendarserver.org/ns/" xmlns:d="DAV:" xmlns:cal="urn:ietf:params:xml:ns:caldav"> + <cs:dtstamp>20120101T000000Z</cs:dtstamp> + <cs:invite-notification> + <cs:uid>foo</cs:uid> + <d:href>mailto:foo@example.org</d:href> + <cs:invite-declined/> + <cs:hosturl> + <d:href>/calendar</d:href> + </cs:hosturl> + <cs:access> + <cs:read/> + </cs:access> + <cs:organizer-cn>John Doe</cs:organizer-cn> + <cs:organizer> + <d:href>/principal/user1</d:href> + <cs:common-name>John Doe</cs:common-name> + </cs:organizer> + </cs:invite-notification> +</cs:root> + +FOO + ), + array( + array( + 'id' => 'foo', + 'dtStamp' => $dtStamp, + 'etag' => '"1"', + 'href' => 'mailto:foo@example.org', + 'type' => CalDAV\SharingPlugin::STATUS_NORESPONSE, + 'readOnly' => true, + 'hostUrl' => 'calendar', + 'organizer' => 'principal/user1', + 'firstName' => 'Foo', + 'lastName' => 'Bar', + ), +<<<FOO +<?xml version="1.0" encoding="UTF-8"?> +<cs:root xmlns:cs="http://calendarserver.org/ns/" xmlns:d="DAV:" xmlns:cal="urn:ietf:params:xml:ns:caldav"> + <cs:dtstamp>20120101T000000Z</cs:dtstamp> + <cs:invite-notification> + <cs:uid>foo</cs:uid> + <d:href>mailto:foo@example.org</d:href> + <cs:invite-noresponse/> + <cs:hosturl> + <d:href>/calendar</d:href> + </cs:hosturl> + <cs:access> + <cs:read/> + </cs:access> + <cs:organizer-first>Foo</cs:organizer-first> + <cs:organizer-last>Bar</cs:organizer-last> + <cs:organizer> + <d:href>/principal/user1</d:href> + <cs:first-name>Foo</cs:first-name> + <cs:last-name>Bar</cs:last-name> + </cs:organizer> + </cs:invite-notification> +</cs:root> + +FOO + ), + array( + array( + 'id' => 'foo', + 'dtStamp' => $dtStamp, + 'etag' => '"1"', + 'href' => 'mailto:foo@example.org', + 'type' => CalDAV\SharingPlugin::STATUS_DELETED, + 'readOnly' => false, + 'hostUrl' => 'calendar', + 'organizer' => 'mailto:user1@fruux.com', + 'supportedComponents' => new CalDAV\Property\SupportedCalendarComponentSet(array('VEVENT','VTODO')), + ), +<<<FOO +<?xml version="1.0" encoding="UTF-8"?> +<cs:root xmlns:cs="http://calendarserver.org/ns/" xmlns:d="DAV:" xmlns:cal="urn:ietf:params:xml:ns:caldav"> + <cs:dtstamp>20120101T000000Z</cs:dtstamp> + <cs:invite-notification> + <cs:uid>foo</cs:uid> + <d:href>mailto:foo@example.org</d:href> + <cs:invite-deleted/> + <cs:hosturl> + <d:href>/calendar</d:href> + </cs:hosturl> + <cs:access> + <cs:read-write/> + </cs:access> + <cs:organizer> + <d:href>mailto:user1@fruux.com</d:href> + </cs:organizer> + <cal:supported-calendar-component-set> + <cal:comp name="VEVENT"/> + <cal:comp name="VTODO"/> + </cal:supported-calendar-component-set> + </cs:invite-notification> +</cs:root> + +FOO + ), + + ); + + } + + /** + * @expectedException InvalidArgumentException + */ + function testMissingArg() { + + new Invite(array()); + + } + + /** + * @expectedException InvalidArgumentException + */ + function testUnknownArg() { + + new Invite(array( + 'foo-i-will-break' => true, + + 'id' => 1, + 'etag' => '"bla"', + 'href' => 'abc', + 'dtStamp' => 'def', + 'type' => 'ghi', + 'readOnly' => true, + 'hostUrl' => 'jkl', + 'organizer' => 'mno', + )); + + } +} diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/Notifications/Notification/SystemStatusTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/Notifications/Notification/SystemStatusTest.php new file mode 100644 index 000000000..8dc494932 --- /dev/null +++ b/vendor/sabre/dav/tests/Sabre/CalDAV/Notifications/Notification/SystemStatusTest.php @@ -0,0 +1,61 @@ +<?php + +namespace Sabre\CalDAV\Notifications\Notification; + +use Sabre\CalDAV; +use Sabre\DAV; + +class SystemStatusTest extends \PHPUnit_Framework_TestCase { + + /** + * @dataProvider dataProvider + */ + function testSerializers($notification, $expected1, $expected2) { + + $this->assertEquals('foo', $notification->getId()); + $this->assertEquals('"1"', $notification->getETag()); + + + $dom = new \DOMDocument('1.0','UTF-8'); + $elem = $dom->createElement('cs:root'); + $elem->setAttribute('xmlns:cs',CalDAV\Plugin::NS_CALENDARSERVER); + $dom->appendChild($elem); + $notification->serialize(new DAV\Server(), $elem); + $this->assertEquals($expected1, $dom->saveXML()); + + $dom = new \DOMDocument('1.0','UTF-8'); + $elem = $dom->createElement('cs:root'); + $elem->setAttribute('xmlns:cs',CalDAV\Plugin::NS_CALENDARSERVER); + $dom->appendChild($elem); + $notification->serializeBody(new DAV\Server(), $elem); + $this->assertEquals($expected2, $dom->saveXML()); + + + } + + function dataProvider() { + + return array( + + array( + new SystemStatus('foo', '"1"'), + '<?xml version="1.0" encoding="UTF-8"?>' . "\n" . '<cs:root xmlns:cs="http://calendarserver.org/ns/"><cs:systemstatus type="high"/></cs:root>' . "\n", + '<?xml version="1.0" encoding="UTF-8"?>' . "\n" . '<cs:root xmlns:cs="http://calendarserver.org/ns/"><cs:systemstatus type="high"/></cs:root>' . "\n", + ), + + array( + new SystemStatus('foo', '"1"', SystemStatus::TYPE_MEDIUM,'bar'), + '<?xml version="1.0" encoding="UTF-8"?>' . "\n" . '<cs:root xmlns:cs="http://calendarserver.org/ns/"><cs:systemstatus type="medium"/></cs:root>' . "\n", + '<?xml version="1.0" encoding="UTF-8"?>' . "\n" . '<cs:root xmlns:cs="http://calendarserver.org/ns/"><cs:systemstatus type="medium"><cs:description>bar</cs:description></cs:systemstatus></cs:root>' . "\n", + ), + + array( + new SystemStatus('foo', '"1"', SystemStatus::TYPE_LOW,null,'http://example.org/'), + '<?xml version="1.0" encoding="UTF-8"?>' . "\n" . '<cs:root xmlns:cs="http://calendarserver.org/ns/"><cs:systemstatus type="low"/></cs:root>' . "\n", + '<?xml version="1.0" encoding="UTF-8"?>' . "\n" . '<cs:root xmlns:cs="http://calendarserver.org/ns/"><cs:systemstatus type="low"><d:href>http://example.org/</d:href></cs:systemstatus></cs:root>' . "\n", + ) + ); + + } + +} |