aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/sabre/dav/tests/Sabre/CardDAV/Backend/AbstractPDOTest.php
diff options
context:
space:
mode:
authorredmatrix <git@macgirvin.com>2016-05-10 17:26:44 -0700
committerredmatrix <git@macgirvin.com>2016-05-10 17:26:44 -0700
commit0b02a6d123b2014705998c94ddf3d460948d3eac (patch)
tree78ff2cab9944a4f5ab3f80ec93cbe1120de90bb2 /vendor/sabre/dav/tests/Sabre/CardDAV/Backend/AbstractPDOTest.php
parent40b5b6e9d2da7ab65c8b4d38cdceac83a4d78deb (diff)
downloadvolse-hubzilla-0b02a6d123b2014705998c94ddf3d460948d3eac.tar.gz
volse-hubzilla-0b02a6d123b2014705998c94ddf3d460948d3eac.tar.bz2
volse-hubzilla-0b02a6d123b2014705998c94ddf3d460948d3eac.zip
initial sabre upgrade (needs lots of work - to wit: authentication, redo the browser interface, and rework event export/import)
Diffstat (limited to 'vendor/sabre/dav/tests/Sabre/CardDAV/Backend/AbstractPDOTest.php')
-rw-r--r--vendor/sabre/dav/tests/Sabre/CardDAV/Backend/AbstractPDOTest.php129
1 files changed, 115 insertions, 14 deletions
diff --git a/vendor/sabre/dav/tests/Sabre/CardDAV/Backend/AbstractPDOTest.php b/vendor/sabre/dav/tests/Sabre/CardDAV/Backend/AbstractPDOTest.php
index 623188d32..d2ec278be 100644
--- a/vendor/sabre/dav/tests/Sabre/CardDAV/Backend/AbstractPDOTest.php
+++ b/vendor/sabre/dav/tests/Sabre/CardDAV/Backend/AbstractPDOTest.php
@@ -3,6 +3,7 @@
namespace Sabre\CardDAV\Backend;
use Sabre\CardDAV;
+use Sabre\DAV\PropPatch;
abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase {
@@ -19,7 +20,10 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase {
public function setUp() {
- $this->backend = new PDO($this->getPDO());
+ $pdo = $this->getPDO();
+ $this->backend = new PDO($pdo);
+ $pdo->exec('INSERT INTO addressbooks (principaluri, displayname, uri, description, synctoken) VALUES ("principals/user1", "book1", "book1", "addressbook 1", 1)');
+ $pdo->exec('INSERT INTO cards (addressbookid, carddata, uri, lastmodified, etag, size) VALUES (1, "card1", "card1", 0, "' . md5('card1') . '", 5)');
}
@@ -35,7 +39,7 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase {
'{DAV:}displayname' => 'book1',
'{' . CardDAV\Plugin::NS_CARDDAV . '}addressbook-description' => 'addressbook 1',
'{http://calendarserver.org/ns/}getctag' => 1,
- '{' . CardDAV\Plugin::NS_CARDDAV . '}supported-address-data' => new CardDAV\Property\SupportedAddressData(),
+ '{http://sabredav.org/ns}sync-token' => 1
)
);
@@ -45,11 +49,14 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase {
public function testUpdateAddressBookInvalidProp() {
- $result = $this->backend->updateAddressBook(1, array(
+ $propPatch = new PropPatch([
'{DAV:}displayname' => 'updated',
'{' . CardDAV\Plugin::NS_CARDDAV . '}addressbook-description' => 'updated',
'{DAV:}foo' => 'bar',
- ));
+ ]);
+
+ $this->backend->updateAddressBook(1, $propPatch);
+ $result = $propPatch->commit();
$this->assertFalse($result);
@@ -63,7 +70,7 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase {
'{DAV:}displayname' => 'book1',
'{' . CardDAV\Plugin::NS_CARDDAV . '}addressbook-description' => 'addressbook 1',
'{http://calendarserver.org/ns/}getctag' => 1,
- '{' . CardDAV\Plugin::NS_CARDDAV . '}supported-address-data' => new CardDAV\Property\SupportedAddressData(),
+ '{http://sabredav.org/ns}sync-token' => 1
)
);
@@ -73,9 +80,12 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase {
public function testUpdateAddressBookNoProps() {
- $result = $this->backend->updateAddressBook(1, array());
+ $propPatch = new PropPatch([
+ ]);
- $this->assertFalse($result);
+ $this->backend->updateAddressBook(1, $propPatch);
+ $result = $propPatch->commit();
+ $this->assertTrue($result);
$result = $this->backend->getAddressBooksForUser('principals/user1');
@@ -87,7 +97,7 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase {
'{DAV:}displayname' => 'book1',
'{' . CardDAV\Plugin::NS_CARDDAV . '}addressbook-description' => 'addressbook 1',
'{http://calendarserver.org/ns/}getctag' => 1,
- '{' . CardDAV\Plugin::NS_CARDDAV . '}supported-address-data' => new CardDAV\Property\SupportedAddressData(),
+ '{http://sabredav.org/ns}sync-token' => 1
)
);
@@ -98,10 +108,13 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase {
public function testUpdateAddressBookSuccess() {
- $result = $this->backend->updateAddressBook(1, array(
+ $propPatch = new PropPatch([
'{DAV:}displayname' => 'updated',
'{' . CardDAV\Plugin::NS_CARDDAV . '}addressbook-description' => 'updated',
- ));
+ ]);
+
+ $this->backend->updateAddressBook(1, $propPatch);
+ $result = $propPatch->commit();
$this->assertTrue($result);
@@ -115,7 +128,7 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase {
'{DAV:}displayname' => 'updated',
'{' . CardDAV\Plugin::NS_CARDDAV . '}addressbook-description' => 'updated',
'{http://calendarserver.org/ns/}getctag' => 2,
- '{' . CardDAV\Plugin::NS_CARDDAV . '}supported-address-data' => new CardDAV\Property\SupportedAddressData(),
+ '{http://sabredav.org/ns}sync-token' => 2
)
);
@@ -158,7 +171,7 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase {
'{DAV:}displayname' => 'book1',
'{' . CardDAV\Plugin::NS_CARDDAV . '}addressbook-description' => 'addressbook 1',
'{http://calendarserver.org/ns/}getctag' => 1,
- '{' . CardDAV\Plugin::NS_CARDDAV . '}supported-address-data' => new CardDAV\Property\SupportedAddressData(),
+ '{http://sabredav.org/ns}sync-token' => 1,
),
array(
'id' => 2,
@@ -167,7 +180,7 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase {
'{DAV:}displayname' => 'book2',
'{' . CardDAV\Plugin::NS_CARDDAV . '}addressbook-description' => 'addressbook 2',
'{http://calendarserver.org/ns/}getctag' => 1,
- '{' . CardDAV\Plugin::NS_CARDDAV . '}supported-address-data' => new CardDAV\Property\SupportedAddressData(),
+ '{http://sabredav.org/ns}sync-token' => 1,
)
);
$result = $this->backend->getAddressBooksForUser('principals/user1');
@@ -183,8 +196,9 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase {
array(
'id' => 1,
'uri' => 'card1',
- 'carddata' => 'card1',
'lastmodified' => 0,
+ 'etag' => '"' . md5('card1') . '"',
+ 'size' => 5
)
);
@@ -201,6 +215,8 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase {
'uri' => 'card1',
'carddata' => 'card1',
'lastmodified' => 0,
+ 'etag' => '"' . md5('card1') . '"',
+ 'size' => 5
);
$this->assertEquals($expected, $result);
@@ -222,6 +238,53 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase {
}
/**
+ * @depends testCreateCard
+ */
+ public function testGetMultiple() {
+
+ $result = $this->backend->createCard(1, 'card2', 'data2');
+ $result = $this->backend->createCard(1, 'card3', 'data3');
+ $check = [
+ [
+ 'id' => 1,
+ 'uri' => 'card1',
+ 'carddata' => 'card1',
+ 'lastmodified' => 0,
+ ],
+ [
+ 'id' => 2,
+ 'uri' => 'card2',
+ 'carddata' => 'data2',
+ 'lastmodified' => time(),
+ ],
+ [
+ 'id' => 3,
+ 'uri' => 'card3',
+ 'carddata' => 'data3',
+ 'lastmodified' => time(),
+ ],
+ ];
+
+ $result = $this->backend->getMultipleCards(1, ['card1','card2','card3']);
+
+ foreach($check as $index=>$node) {
+
+ foreach($node as $k=>$v) {
+
+ if ($k!=='lastmodified') {
+ $this->assertEquals($v, $result[$index][$k]);
+ } else {
+ $this->assertTrue(isset($result[$index][$k]));
+ }
+
+ }
+
+ }
+
+
+ }
+
+ /**
* @depends testGetCard
*/
public function testUpdateCard() {
@@ -245,5 +308,43 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase {
$this->assertFalse($result);
}
+
+ function testGetChanges() {
+
+ $backend = $this->backend;
+ $id = $backend->createAddressBook(
+ 'principals/user1',
+ 'bla',
+ []
+ );
+ $result = $backend->getChangesForAddressBook($id, null, 1);
+
+ $this->assertEquals([
+ 'syncToken' => 1,
+ "added" => [],
+ 'modified' => [],
+ 'deleted' => [],
+ ], $result);
+
+ $currentToken = $result['syncToken'];
+
+ $dummyCard = "BEGIN:VCARD\r\nEND:VCARD\r\n";
+
+ $backend->createCard($id, "card1.ics", $dummyCard);
+ $backend->createCard($id, "card2.ics", $dummyCard);
+ $backend->createCard($id, "card3.ics", $dummyCard);
+ $backend->updateCard($id, "card1.ics", $dummyCard);
+ $backend->deleteCard($id, "card2.ics");
+
+ $result = $backend->getChangesForAddressBook($id, $currentToken, 1);
+
+ $this->assertEquals([
+ 'syncToken' => 6,
+ 'modified' => ["card1.ics"],
+ 'deleted' => ["card2.ics"],
+ "added" => ["card3.ics"],
+ ], $result);
+
+ }
}