ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
Sabre\CardDAV\AddressBookTest Class Reference
+ Inheritance diagram for Sabre\CardDAV\AddressBookTest:
+ Collaboration diagram for Sabre\CardDAV\AddressBookTest:

Public Member Functions

 setUp ()
 
 testGetName ()
 
 testGetChild ()
 
 testGetChildNotFound ()
 @expectedException Sabre\DAV\Exception\NotFound More...
 
 testGetChildren ()
 
 testCreateDirectory ()
 @expectedException Sabre\DAV\Exception\MethodNotAllowed More...
 
 testCreateFile ()
 
 testDelete ()
 
 testSetName ()
 @expectedException Sabre\DAV\Exception\MethodNotAllowed More...
 
 testGetLastModified ()
 
 testUpdateProperties ()
 
 testGetProperties ()
 
 testACLMethods ()
 
 testSetACL ()
 @expectedException Sabre\DAV\Exception\Forbidden More...
 
 testGetSupportedPrivilegeSet ()
 
 testGetSyncTokenNoSyncSupport ()
 
 testGetChangesNoSyncSupport ()
 
 testGetSyncToken ()
 
 testGetSyncToken2 ()
 

Protected Attributes

 $ab
 
 $backend
 

Detailed Description

Definition at line 7 of file AddressBookTest.php.

Member Function Documentation

◆ setUp()

Sabre\CardDAV\AddressBookTest::setUp ( )

Definition at line 17 of file AddressBookTest.php.

17 {
18
19 $this->backend = new Backend\Mock();
20 $this->ab = new AddressBook(
21 $this->backend,
22 [
23 'uri' => 'book1',
24 'id' => 'foo',
25 '{DAV:}displayname' => 'd-name',
26 'principaluri' => 'principals/user1',
27 ]
28 );
29
30 }

◆ testACLMethods()

Sabre\CardDAV\AddressBookTest::testACLMethods ( )

Definition at line 128 of file AddressBookTest.php.

128 {
129
130 $this->assertEquals('principals/user1', $this->ab->getOwner());
131 $this->assertNull($this->ab->getGroup());
132 $this->assertEquals([
133 [
134 'privilege' => '{DAV:}all',
135 'principal' => '{DAV:}owner',
136 'protected' => true,
137 ],
138 ], $this->ab->getACL());
139
140 }

◆ testCreateDirectory()

Sabre\CardDAV\AddressBookTest::testCreateDirectory ( )

@expectedException Sabre\DAV\Exception\MethodNotAllowed

Definition at line 68 of file AddressBookTest.php.

68 {
69
70 $this->ab->createDirectory('name');
71
72 }

◆ testCreateFile()

Sabre\CardDAV\AddressBookTest::testCreateFile ( )

Definition at line 74 of file AddressBookTest.php.

74 {
75
76 $file = fopen('php://memory', 'r+');
77 fwrite($file, 'foo');
78 rewind($file);
79 $this->ab->createFile('card2', $file);
80
81 $this->assertEquals('foo', $this->backend->cards['foo']['card2']);
82
83 }

◆ testDelete()

Sabre\CardDAV\AddressBookTest::testDelete ( )

Definition at line 85 of file AddressBookTest.php.

85 {
86
87 $this->ab->delete();
88 $this->assertEquals(1, count($this->backend->addressBooks));
89
90 }

◆ testGetChangesNoSyncSupport()

Sabre\CardDAV\AddressBookTest::testGetChangesNoSyncSupport ( )

Definition at line 164 of file AddressBookTest.php.

164 {
165
166 $this->assertNull($this->ab->getChanges(1, null));
167
168 }

◆ testGetChild()

Sabre\CardDAV\AddressBookTest::testGetChild ( )

Definition at line 38 of file AddressBookTest.php.

38 {
39
40 $card = $this->ab->getChild('card1');
41 $this->assertInstanceOf('Sabre\\CardDAV\\Card', $card);
42 $this->assertEquals('card1', $card->getName());
43
44 }

◆ testGetChildNotFound()

Sabre\CardDAV\AddressBookTest::testGetChildNotFound ( )

@expectedException Sabre\DAV\Exception\NotFound

Definition at line 49 of file AddressBookTest.php.

49 {
50
51 $card = $this->ab->getChild('card3');
52
53 }

◆ testGetChildren()

Sabre\CardDAV\AddressBookTest::testGetChildren ( )

Definition at line 55 of file AddressBookTest.php.

55 {
56
57 $cards = $this->ab->getChildren();
58 $this->assertEquals(2, count($cards));
59
60 $this->assertEquals('card1', $cards[0]->getName());
61 $this->assertEquals('card2', $cards[1]->getName());
62
63 }

◆ testGetLastModified()

Sabre\CardDAV\AddressBookTest::testGetLastModified ( )

Definition at line 101 of file AddressBookTest.php.

101 {
102
103 $this->assertNull($this->ab->getLastModified());
104
105 }

◆ testGetName()

Sabre\CardDAV\AddressBookTest::testGetName ( )

Definition at line 32 of file AddressBookTest.php.

32 {
33
34 $this->assertEquals('book1', $this->ab->getName());
35
36 }

◆ testGetProperties()

Sabre\CardDAV\AddressBookTest::testGetProperties ( )

Definition at line 119 of file AddressBookTest.php.

119 {
120
121 $props = $this->ab->getProperties(['{DAV:}displayname']);
122 $this->assertEquals([
123 '{DAV:}displayname' => 'd-name',
124 ], $props);
125
126 }

◆ testGetSupportedPrivilegeSet()

Sabre\CardDAV\AddressBookTest::testGetSupportedPrivilegeSet ( )

Definition at line 151 of file AddressBookTest.php.

151 {
152
153 $this->assertNull(
154 $this->ab->getSupportedPrivilegeSet()
155 );
156
157 }

◆ testGetSyncToken()

Sabre\CardDAV\AddressBookTest::testGetSyncToken ( )

Definition at line 170 of file AddressBookTest.php.

170 {
171
172 $this->driver = 'sqlite';
173 $this->dropTables(['addressbooks', 'cards', 'addressbookchanges']);
174 $this->createSchema('addressbooks');
175 $backend = new Backend\PDO(
176 $this->getPDO()
177 );
178 $ab = new AddressBook($backend, ['id' => 1, '{DAV:}sync-token' => 2]);
179 $this->assertEquals(2, $ab->getSyncToken());
180 }
dropTables($tableNames)
Drops tables, if they exist.
getPDO()
Alias for getDb.
createSchema($schemaName)
Uses .sql files from the examples directory to initialize the database.

References Sabre\CardDAV\AddressBookTest\$ab, Sabre\CardDAV\AddressBookTest\$backend, Sabre\DAV\createSchema(), Sabre\DAV\dropTables(), and Sabre\DAV\getPDO().

+ Here is the call graph for this function:

◆ testGetSyncToken2()

Sabre\CardDAV\AddressBookTest::testGetSyncToken2 ( )

Definition at line 182 of file AddressBookTest.php.

182 {
183
184 $this->driver = 'sqlite';
185 $this->dropTables(['addressbooks', 'cards', 'addressbookchanges']);
186 $this->createSchema('addressbooks');
187 $backend = new Backend\PDO(
188 $this->getPDO()
189 );
190 $ab = new AddressBook($backend, ['id' => 1, '{http://sabredav.org/ns}sync-token' => 2]);
191 $this->assertEquals(2, $ab->getSyncToken());
192 }

References Sabre\CardDAV\AddressBookTest\$ab, Sabre\CardDAV\AddressBookTest\$backend, Sabre\DAV\createSchema(), Sabre\DAV\dropTables(), and Sabre\DAV\getPDO().

+ Here is the call graph for this function:

◆ testGetSyncTokenNoSyncSupport()

Sabre\CardDAV\AddressBookTest::testGetSyncTokenNoSyncSupport ( )

Definition at line 159 of file AddressBookTest.php.

159 {
160
161 $this->assertNull($this->ab->getSyncToken());
162
163 }

◆ testSetACL()

Sabre\CardDAV\AddressBookTest::testSetACL ( )

@expectedException Sabre\DAV\Exception\Forbidden

Definition at line 145 of file AddressBookTest.php.

145 {
146
147 $this->ab->setACL([]);
148
149 }

◆ testSetName()

Sabre\CardDAV\AddressBookTest::testSetName ( )

@expectedException Sabre\DAV\Exception\MethodNotAllowed

Definition at line 95 of file AddressBookTest.php.

95 {
96
97 $this->ab->setName('foo');
98
99 }

◆ testUpdateProperties()

Sabre\CardDAV\AddressBookTest::testUpdateProperties ( )

Definition at line 107 of file AddressBookTest.php.

107 {
108
109 $propPatch = new PropPatch([
110 '{DAV:}displayname' => 'barrr',
111 ]);
112 $this->ab->propPatch($propPatch);
113 $this->assertTrue($propPatch->commit());
114
115 $this->assertEquals('barrr', $this->backend->addressBooks[0]['{DAV:}displayname']);
116
117 }

Field Documentation

◆ $ab

Sabre\CardDAV\AddressBookTest::$ab
protected

◆ $backend

Sabre\CardDAV\AddressBookTest::$backend
protected

The documentation for this class was generated from the following file: