28 $pdo->exec(
"INSERT INTO addressbooks (principaluri, displayname, uri, description, synctoken) VALUES ('principals/user1', 'book1', 'book1', 'addressbook 1', 1)");
29 $pdo->exec(
"INSERT INTO cards (addressbookid, carddata, uri, lastmodified, etag, size) VALUES (1, 'card1', 'card1', 0, '" . md5(
'card1') .
"', 5)");
35 $result = $this->backend->getAddressBooksForUser(
'principals/user1');
41 'principaluri' =>
'principals/user1',
42 '{DAV:}displayname' =>
'book1',
44 '{http://calendarserver.org/ns/}getctag' => 1,
45 '{http://sabredav.org/ns}sync-token' => 1
49 $this->assertEquals($expected,
$result);
56 '{DAV:}displayname' =>
'updated',
61 $this->backend->updateAddressBook(1, $propPatch);
66 $result = $this->backend->getAddressBooksForUser(
'principals/user1');
72 'principaluri' =>
'principals/user1',
73 '{DAV:}displayname' =>
'book1',
75 '{http://calendarserver.org/ns/}getctag' => 1,
76 '{http://sabredav.org/ns}sync-token' => 1
80 $this->assertEquals($expected,
$result);
89 $this->backend->updateAddressBook(1, $propPatch);
93 $result = $this->backend->getAddressBooksForUser(
'principals/user1');
99 'principaluri' =>
'principals/user1',
100 '{DAV:}displayname' =>
'book1',
102 '{http://calendarserver.org/ns/}getctag' => 1,
103 '{http://sabredav.org/ns}sync-token' => 1
107 $this->assertEquals($expected,
$result);
115 '{DAV:}displayname' =>
'updated',
119 $this->backend->updateAddressBook(1, $propPatch);
120 $result = $propPatch->commit();
124 $result = $this->backend->getAddressBooksForUser(
'principals/user1');
130 'principaluri' =>
'principals/user1',
131 '{DAV:}displayname' =>
'updated',
133 '{http://calendarserver.org/ns/}getctag' => 2,
134 '{http://sabredav.org/ns}sync-token' => 2
138 $this->assertEquals($expected,
$result);
145 $this->backend->deleteAddressBook(1);
147 $this->assertEquals([], $this->backend->getAddressBooksForUser(
'principals/user1'));
156 $this->backend->createAddressBook(
'principals/user1',
'book2', [
157 '{DAV:}foo' =>
'bar',
164 $this->backend->createAddressBook(
'principals/user1',
'book2', [
165 '{DAV:}displayname' =>
'book2',
173 'principaluri' =>
'principals/user1',
174 '{DAV:}displayname' =>
'book1',
176 '{http://calendarserver.org/ns/}getctag' => 1,
177 '{http://sabredav.org/ns}sync-token' => 1,
182 'principaluri' =>
'principals/user1',
183 '{DAV:}displayname' =>
'book2',
185 '{http://calendarserver.org/ns/}getctag' => 1,
186 '{http://sabredav.org/ns}sync-token' => 1,
189 $result = $this->backend->getAddressBooksForUser(
'principals/user1');
190 $this->assertEquals($expected,
$result);
196 $result = $this->backend->getCards(1);
203 'etag' =>
'"' . md5(
'card1') .
'"',
208 $this->assertEquals($expected,
$result);
214 $result = $this->backend->getCard(1,
'card1');
219 'carddata' =>
'card1',
221 'etag' =>
'"' . md5(
'card1') .
'"',
225 if (is_resource(
$result[
'carddata'])) {
229 $this->assertEquals($expected,
$result);
238 $result = $this->backend->createCard(1,
'card2',
'data2');
239 $this->assertEquals(
'"' . md5(
'data2') .
'"',
$result);
240 $result = $this->backend->getCard(1,
'card2');
241 $this->assertEquals(2,
$result[
'id']);
242 $this->assertEquals(
'card2',
$result[
'uri']);
243 if (is_resource(
$result[
'carddata'])) {
246 $this->assertEquals(
'data2',
$result[
'carddata']);
255 $result = $this->backend->createCard(1,
'card2',
'data2');
256 $result = $this->backend->createCard(1,
'card3',
'data3');
261 'carddata' =>
'card1',
267 'carddata' =>
'data2',
268 'lastmodified' => time(),
273 'carddata' =>
'data3',
274 'lastmodified' => time(),
278 $result = $this->backend->getMultipleCards(1, [
'card1',
'card2',
'card3']);
280 foreach ($check as
$index => $node) {
282 foreach ($node as $k => $v) {
288 case 'lastmodified' :
289 $this->assertInternalType(
'int', $actual);
292 if (is_resource($actual)) {
293 $actual = stream_get_contents($actual);
297 $this->assertEquals($expected, $actual);
313 $result = $this->backend->updateCard(1,
'card1',
'newdata');
314 $this->assertEquals(
'"' . md5(
'newdata') .
'"',
$result);
316 $result = $this->backend->getCard(1,
'card1');
317 $this->assertEquals(1,
$result[
'id']);
318 if (is_resource(
$result[
'carddata'])) {
321 $this->assertEquals(
'newdata',
$result[
'carddata']);
330 $this->backend->deleteCard(1,
'card1');
331 $result = $this->backend->getCard(1,
'card1');
346 $this->assertEquals([
353 $currentToken =
$result[
'syncToken'];
355 $dummyCard =
"BEGIN:VCARD\r\nEND:VCARD\r\n";
357 $backend->createCard(
$id,
"card1.ics", $dummyCard);
358 $backend->createCard(
$id,
"card2.ics", $dummyCard);
359 $backend->createCard(
$id,
"card3.ics", $dummyCard);
360 $backend->updateCard(
$id,
"card1.ics", $dummyCard);
365 $this->assertEquals([
367 'modified' => [
"card1.ics"],
368 'deleted' => [
"card2.ics"],
369 "added" => [
"card3.ics"],
testDeleteCard()
testGetCard
This class represents a set of properties that are going to be updated.
const NS_CARDDAV
xml namespace for CardDAV elements
testCreateCard()
testGetCard
if(!array_key_exists('StateId', $_REQUEST)) $id
testCreateAddressBookUnsupportedProp()
Sabre
dropTables($tableNames)
Drops tables, if they exist.
testUpdateCard()
testGetCard
testUpdateAddressBookInvalidProp()
createSchema($schemaName)
Uses .sql files from the examples directory to initialize the database.
testGetMultiple()
testCreateCard
testCreateAddressBookSuccess()
testGetAddressBooksForUser()
testUpdateAddressBookNoProps()
testUpdateAddressBookSuccess()