aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/sabre/dav/tests/Sabre/CardDAV/AddressBookTest.php
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/CardDAV/AddressBookTest.php
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/CardDAV/AddressBookTest.php')
-rw-r--r--vendor/sabre/dav/tests/Sabre/CardDAV/AddressBookTest.php162
1 files changed, 162 insertions, 0 deletions
diff --git a/vendor/sabre/dav/tests/Sabre/CardDAV/AddressBookTest.php b/vendor/sabre/dav/tests/Sabre/CardDAV/AddressBookTest.php
new file mode 100644
index 000000000..aac749b37
--- /dev/null
+++ b/vendor/sabre/dav/tests/Sabre/CardDAV/AddressBookTest.php
@@ -0,0 +1,162 @@
+<?php
+
+namespace Sabre\CardDAV;
+
+
+require_once 'Sabre/CardDAV/Backend/Mock.php';
+
+class AddressBookTest extends \PHPUnit_Framework_TestCase {
+
+ /**
+ * @var Sabre\CardDAV\AddressBook
+ */
+ protected $ab;
+ protected $backend;
+
+ function setUp() {
+
+ $this->backend = new Backend\Mock();
+ $this->ab = new AddressBook(
+ $this->backend,
+ array(
+ 'uri' => 'book1',
+ 'id' => 'foo',
+ '{DAV:}displayname' => 'd-name',
+ 'principaluri' => 'principals/user1',
+ )
+ );
+
+ }
+
+ function testGetName() {
+
+ $this->assertEquals('book1', $this->ab->getName());
+
+ }
+
+ function testGetChild() {
+
+ $card = $this->ab->getChild('card1');
+ $this->assertInstanceOf('Sabre\\CardDAV\\Card', $card);
+ $this->assertEquals('card1', $card->getName());
+
+ }
+
+ /**
+ * @expectedException Sabre\DAV\Exception\NotFound
+ */
+ function testGetChildNotFound() {
+
+ $card = $this->ab->getChild('card3');
+
+ }
+
+ function testGetChildren() {
+
+ $cards = $this->ab->getChildren();
+ $this->assertEquals(2, count($cards));
+
+ $this->assertEquals('card1', $cards[0]->getName());
+ $this->assertEquals('card2', $cards[1]->getName());
+
+ }
+
+ /**
+ * @expectedException Sabre\DAV\Exception\MethodNotAllowed
+ */
+ function testCreateDirectory() {
+
+ $this->ab->createDirectory('name');
+
+ }
+
+ function testCreateFile() {
+
+ $file = fopen('php://memory','r+');
+ fwrite($file,'foo');
+ rewind($file);
+ $this->ab->createFile('card2',$file);
+
+ $this->assertEquals('foo', $this->backend->cards['foo']['card2']);
+
+ }
+
+ function testDelete() {
+
+ $this->ab->delete();
+ $this->assertEquals(array(), $this->backend->addressBooks);
+
+ }
+
+ /**
+ * @expectedException Sabre\DAV\Exception\MethodNotAllowed
+ */
+ function testSetName() {
+
+ $this->ab->setName('foo');
+
+ }
+
+ function testGetLastModified() {
+
+ $this->assertNull($this->ab->getLastModified());
+
+ }
+
+ function testUpdateProperties() {
+
+ $this->assertTrue(
+ $this->ab->updateProperties(array('{DAV:}displayname' => 'barrr'))
+ );
+
+ $this->assertEquals('barrr', $this->backend->addressBooks[0]['{DAV:}displayname']);
+
+ }
+
+ function testGetProperties() {
+
+ $props = $this->ab->getProperties(array('{DAV:}displayname'));
+ $this->assertEquals(array(
+ '{DAV:}displayname' => 'd-name',
+ ), $props);
+
+ }
+
+ function testACLMethods() {
+
+ $this->assertEquals('principals/user1', $this->ab->getOwner());
+ $this->assertNull($this->ab->getGroup());
+ $this->assertEquals(array(
+ array(
+ 'privilege' => '{DAV:}read',
+ 'principal' => 'principals/user1',
+ 'protected' => true,
+ ),
+ array(
+ 'privilege' => '{DAV:}write',
+ 'principal' => 'principals/user1',
+ 'protected' => true,
+ ),
+ ), $this->ab->getACL());
+
+ }
+
+ /**
+ * @expectedException Sabre\DAV\Exception\MethodNotAllowed
+ */
+ function testSetACL() {
+
+ $this->ab->setACL(array());
+
+ }
+
+ function testGetSupportedPrivilegeSet() {
+
+ $this->assertNull(
+ $this->ab->getSupportedPrivilegeSet()
+ );
+
+ }
+
+
+}