3 class Sabre_CardDAV_UserAddressBooksTest extends PHPUnit_Framework_TestCase {
6 * @var Sabre_CardDAV_UserAddressBooks
13 $this->backend = new Sabre_CardDAV_Backend_Mock();
14 $this->s = new Sabre_CardDAV_UserAddressBooks(
21 function testGetName() {
23 $this->assertEquals('user1', $this->s->getName());
28 * @expectedException Sabre_DAV_Exception_MethodNotAllowed
30 function testSetName() {
32 $this->s->setName('user2');
37 * @expectedException Sabre_DAV_Exception_MethodNotAllowed
39 function testDelete() {
45 function testGetLastModified() {
47 $this->assertNull($this->s->getLastModified());
52 * @expectedException Sabre_DAV_Exception_MethodNotAllowed
54 function testCreateFile() {
56 $this->s->createFile('bla');
61 * @expectedException Sabre_DAV_Exception_MethodNotAllowed
63 function testCreateDirectory() {
65 $this->s->createDirectory('bla');
69 function testGetChild() {
71 $child = $this->s->getChild('book1');
72 $this->assertInstanceOf('Sabre_CardDAV_AddressBook', $child);
73 $this->assertEquals('book1', $child->getName());
78 * @expectedException Sabre_DAV_Exception_NotFound
80 function testGetChild404() {
82 $this->s->getChild('book2');
86 function testGetChildren() {
88 $children = $this->s->getChildren();
89 $this->assertEquals(1, count($children));
90 $this->assertInstanceOf('Sabre_CardDAV_AddressBook', $children[0]);
91 $this->assertEquals('book1', $children[0]->getName());
95 function testCreateExtendedCollection() {
97 $resourceType = array(
98 '{' . Sabre_CardDAV_Plugin::NS_CARDDAV . '}addressbook',
101 $this->s->createExtendedCollection('book2', $resourceType, array('{DAV:}displayname' => 'a-book 2'));
103 $this->assertEquals(array(
106 '{DAV:}displayname' => 'a-book 2',
107 'principaluri' => 'principals/user1',
108 ), $this->backend->addressBooks[1]);
113 * @expectedException Sabre_DAV_Exception_InvalidResourceType
115 function testCreateExtendedCollectionInvalid() {
117 $resourceType = array(
120 $this->s->createExtendedCollection('book2', $resourceType, array('{DAV:}displayname' => 'a-book 2'));
125 function testACLMethods() {
127 $this->assertEquals('principals/user1', $this->s->getOwner());
128 $this->assertNull($this->s->getGroup());
129 $this->assertEquals(array(
131 'privilege' => '{DAV:}read',
132 'principal' => 'principals/user1',
136 'privilege' => '{DAV:}write',
137 'principal' => 'principals/user1',
140 ), $this->s->getACL());
145 * @expectedException Sabre_DAV_Exception_MethodNotAllowed
147 function testSetACL() {
149 $this->s->setACL(array());
153 function testGetSupportedPrivilegeSet() {
156 $this->s->getSupportedPrivilegeSet()