aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/sabre/dav/tests/Sabre/CardDAV
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/sabre/dav/tests/Sabre/CardDAV')
-rw-r--r--vendor/sabre/dav/tests/Sabre/CardDAV/AbstractPluginTest.php2
-rw-r--r--vendor/sabre/dav/tests/Sabre/CardDAV/AddressBookQueryParserTest.php329
-rw-r--r--vendor/sabre/dav/tests/Sabre/CardDAV/AddressBookQueryTest.php134
-rw-r--r--vendor/sabre/dav/tests/Sabre/CardDAV/AddressBookRootTest.php2
-rw-r--r--vendor/sabre/dav/tests/Sabre/CardDAV/AddressBookTest.php56
-rw-r--r--vendor/sabre/dav/tests/Sabre/CardDAV/Backend/AbstractPDOTest.php129
-rw-r--r--vendor/sabre/dav/tests/Sabre/CardDAV/Backend/Mock.php30
-rw-r--r--vendor/sabre/dav/tests/Sabre/CardDAV/Backend/PDOMySQLTest.php48
-rw-r--r--vendor/sabre/dav/tests/Sabre/CardDAV/Backend/PDOSqliteTest.php57
-rw-r--r--vendor/sabre/dav/tests/Sabre/CardDAV/CardTest.php33
-rw-r--r--vendor/sabre/dav/tests/Sabre/CardDAV/MultiGetTest.php50
-rw-r--r--vendor/sabre/dav/tests/Sabre/CardDAV/PluginTest.php96
-rw-r--r--vendor/sabre/dav/tests/Sabre/CardDAV/Property/SupportedAddressDataTest.php44
-rw-r--r--vendor/sabre/dav/tests/Sabre/CardDAV/SogoStripContentTypeTest.php17
-rw-r--r--vendor/sabre/dav/tests/Sabre/CardDAV/TestUtil.php18
-rw-r--r--vendor/sabre/dav/tests/Sabre/CardDAV/UserAddressBooksTest.php162
-rw-r--r--vendor/sabre/dav/tests/Sabre/CardDAV/VCFExportTest.php25
-rw-r--r--vendor/sabre/dav/tests/Sabre/CardDAV/ValidateVCardTest.php47
-rw-r--r--vendor/sabre/dav/tests/Sabre/CardDAV/VersionTest.php17
19 files changed, 533 insertions, 763 deletions
diff --git a/vendor/sabre/dav/tests/Sabre/CardDAV/AbstractPluginTest.php b/vendor/sabre/dav/tests/Sabre/CardDAV/AbstractPluginTest.php
index 94081fc8b..a123099a0 100644
--- a/vendor/sabre/dav/tests/Sabre/CardDAV/AbstractPluginTest.php
+++ b/vendor/sabre/dav/tests/Sabre/CardDAV/AbstractPluginTest.php
@@ -4,6 +4,7 @@ namespace Sabre\CardDAV;
use Sabre\DAV;
use Sabre\DAVACL;
+use Sabre\HTTP;
abstract class AbstractPluginTest extends \PHPUnit_Framework_TestCase {
@@ -33,6 +34,7 @@ abstract class AbstractPluginTest extends \PHPUnit_Framework_TestCase {
$this->plugin = new Plugin();
$this->plugin->directories = array('directory');
$this->server = new DAV\Server($tree);
+ $this->server->sapi = new HTTP\SapiMock();
$this->server->addPlugin($this->plugin);
$this->server->debugExceptions = true;
diff --git a/vendor/sabre/dav/tests/Sabre/CardDAV/AddressBookQueryParserTest.php b/vendor/sabre/dav/tests/Sabre/CardDAV/AddressBookQueryParserTest.php
deleted file mode 100644
index 51bea6c6c..000000000
--- a/vendor/sabre/dav/tests/Sabre/CardDAV/AddressBookQueryParserTest.php
+++ /dev/null
@@ -1,329 +0,0 @@
-<?php
-
-namespace Sabre\CardDAV;
-
-use Sabre\DAV;
-
-class AddressBookQueryParserTest extends \PHPUnit_Framework_TestCase {
-
- function parse($xml) {
-
- $xml = implode("\n", $xml);
- $dom = DAV\XMLUtil::loadDOMDocument($xml);
-
- $q = new AddressBookQueryParser($dom);
- $q->parse();
- return $q;
-
- }
-
- function testFilterBasic() {
-
- $xml = array(
- '<?xml version="1.0"?>',
- '<c:addressbook-query xmlns:c="urn:ietf:params:xml:ns:carddav" xmlns:d="DAV:">',
- ' <d:prop>',
- ' <d:foo />',
- ' </d:prop>',
- ' <c:filter>',
- ' <c:prop-filter name="NICKNAME" />',
- ' </c:filter>',
- '</c:addressbook-query>'
- );
-
- $q = $this->parse($xml);
-
- $this->assertEquals(
- array('{DAV:}foo'),
- $q->requestedProperties
- );
-
- $this->assertEquals(
- array(
- array(
- 'name' => 'NICKNAME',
- 'test' => 'anyof',
- 'is-not-defined' => false,
- 'param-filters' => array(),
- 'text-matches' => array(),
- ),
- ),
- $q->filters
- );
-
- $this->assertNull($q->limit);
- $this->assertEquals('anyof', $q->test);
-
- }
-
- function testNoFilter() {
-
- // This is non-standard, but helps working around a KDE bug
- $xml = array(
- '<?xml version="1.0"?>',
- '<c:addressbook-query xmlns:c="urn:ietf:params:xml:ns:carddav" xmlns:d="DAV:">',
- ' <d:prop>',
- ' <d:foo />',
- ' </d:prop>',
- '</c:addressbook-query>'
- );
-
- $q = $this->parse($xml);
-
- $this->assertEquals(
- array('{DAV:}foo'),
- $q->requestedProperties
- );
-
- $this->assertEquals(
- array(),
- $q->filters
- );
-
- $this->assertNull($q->limit);
- $this->assertEquals('anyof', $q->test);
-
- }
-
- /**
- * @expectedException Sabre\DAV\Exception\BadRequest
- */
- function testFilterDoubleFilter() {
-
- $xml = array(
- '<?xml version="1.0"?>',
- '<c:addressbook-query xmlns:c="urn:ietf:params:xml:ns:carddav" xmlns:d="DAV:">',
- ' <d:prop>',
- ' <d:foo />',
- ' </d:prop>',
- ' <c:filter>',
- ' <c:prop-filter name="NICKNAME" />',
- ' </c:filter>',
- ' <c:filter>',
- ' <c:prop-filter name="NICKNAME" />',
- ' </c:filter>',
- '</c:addressbook-query>'
- );
-
- $q = $this->parse($xml);
-
- }
- /**
- * @expectedException Sabre\DAV\Exception\BadRequest
- */
- function testFilterCorruptTest() {
-
- $xml = array(
- '<?xml version="1.0"?>',
- '<c:addressbook-query xmlns:c="urn:ietf:params:xml:ns:carddav" xmlns:d="DAV:">',
- ' <d:prop>',
- ' <d:foo />',
- ' </d:prop>',
- ' <c:filter test="foo">',
- ' <c:prop-filter name="NICKNAME" />',
- ' </c:filter>',
- '</c:addressbook-query>'
- );
-
- $q = $this->parse($xml);
-
- }
-
- function testPropFilter() {
-
- $xml = array(
- '<?xml version="1.0"?>',
- '<c:addressbook-query xmlns:c="urn:ietf:params:xml:ns:carddav" xmlns:d="DAV:">',
- ' <d:prop>',
- ' <d:foo />',
- ' </d:prop>',
- ' <c:filter test="allof">',
- ' <c:prop-filter name="NICKNAME" />',
- ' <c:prop-filter name="EMAIL" test="allof" />',
- ' <c:prop-filter name="FN">',
- ' <c:is-not-defined />',
- ' </c:prop-filter>',
- ' </c:filter>',
- ' <c:limit><c:nresults>4</c:nresults></c:limit>',
- '</c:addressbook-query>'
- );
-
- $q = $this->parse($xml);
-
- $this->assertEquals(
- array(
- array(
- 'name' => 'NICKNAME',
- 'test' => 'anyof',
- 'is-not-defined' => false,
- 'param-filters' => array(),
- 'text-matches' => array(),
- ),
- array(
- 'name' => 'EMAIL',
- 'test' => 'allof',
- 'is-not-defined' => false,
- 'param-filters' => array(),
- 'text-matches' => array(),
- ),
- array(
- 'name' => 'FN',
- 'test' => 'anyof',
- 'is-not-defined' => true,
- 'param-filters' => array(),
- 'text-matches' => array(),
- ),
- ),
- $q->filters
- );
-
- $this->assertEquals(4,$q->limit);
- $this->assertEquals('allof', $q->test);
-
- }
-
- function testParamFilter() {
-
- $xml = array(
- '<?xml version="1.0"?>',
- '<c:addressbook-query xmlns:c="urn:ietf:params:xml:ns:carddav" xmlns:d="DAV:">',
- ' <d:prop>',
- ' <d:foo />',
- ' </d:prop>',
- ' <c:filter>',
- ' <c:prop-filter name="NICKNAME">',
- ' <c:param-filter name="BLA" />',
- ' <c:param-filter name="BLA2">',
- ' <c:is-not-defined />',
- ' </c:param-filter>',
- ' </c:prop-filter>',
- ' </c:filter>',
- '</c:addressbook-query>'
- );
-
- $q = $this->parse($xml);
-
- $this->assertEquals(
- array(
- array(
- 'name' => 'NICKNAME',
- 'test' => 'anyof',
- 'is-not-defined' => false,
- 'param-filters' => array(
- array(
- 'name' => 'BLA',
- 'is-not-defined' => false,
- 'text-match' => null
- ),
- array(
- 'name' => 'BLA2',
- 'is-not-defined' => true,
- 'text-match' => null
- ),
- ),
- 'text-matches' => array(),
- ),
- ),
- $q->filters
- );
-
- }
-
- function testTextMatch() {
-
- $xml = array(
- '<?xml version="1.0"?>',
- '<c:addressbook-query xmlns:c="urn:ietf:params:xml:ns:carddav" xmlns:d="DAV:">',
- ' <d:prop>',
- ' <d:foo />',
- ' </d:prop>',
- ' <c:filter>',
- ' <c:prop-filter name="NICKNAME">',
- ' <c:text-match>evert</c:text-match>',
- ' <c:text-match collation="i;octet">evert</c:text-match>',
- ' <c:text-match negate-condition="yes">rene</c:text-match>',
- ' <c:text-match match-type="starts-with">e</c:text-match>',
- ' <c:param-filter name="BLA">',
- ' <c:text-match>foo</c:text-match>',
- ' </c:param-filter>',
- ' </c:prop-filter>',
- ' </c:filter>',
- '</c:addressbook-query>'
- );
-
- $q = $this->parse($xml);
-
- $this->assertEquals(
- array(
- array(
- 'name' => 'NICKNAME',
- 'test' => 'anyof',
- 'is-not-defined' => false,
- 'param-filters' => array(
- array(
- 'name' => 'BLA',
- 'is-not-defined' => false,
- 'text-match' => array(
- 'negate-condition' => false,
- 'collation' => 'i;unicode-casemap',
- 'match-type' => 'contains',
- 'value' => 'foo',
- ),
- ),
- ),
- 'text-matches' => array(
- array(
- 'negate-condition' => false,
- 'collation' => 'i;unicode-casemap',
- 'match-type' => 'contains',
- 'value' => 'evert',
- ),
- array(
- 'negate-condition' => false,
- 'collation' => 'i;octet',
- 'match-type' => 'contains',
- 'value' => 'evert',
- ),
- array(
- 'negate-condition' => true,
- 'collation' => 'i;unicode-casemap',
- 'match-type' => 'contains',
- 'value' => 'rene',
- ),
- array(
- 'negate-condition' => false,
- 'collation' => 'i;unicode-casemap',
- 'match-type' => 'starts-with',
- 'value' => 'e',
- ),
- ),
- ),
- ),
- $q->filters
- );
-
- }
-
- /**
- * @expectedException Sabre\DAV\Exception\BadRequest
- */
- function testBadTextMatch() {
-
- $xml = array(
- '<?xml version="1.0"?>',
- '<c:addressbook-query xmlns:c="urn:ietf:params:xml:ns:carddav" xmlns:d="DAV:">',
- ' <d:prop>',
- ' <d:foo />',
- ' </d:prop>',
- ' <c:filter>',
- ' <c:prop-filter name="NICKNAME">',
- ' <c:text-match match-type="foo">evert</c:text-match>',
- ' </c:prop-filter>',
- ' </c:filter>',
- '</c:addressbook-query>'
- );
-
- $q = $this->parse($xml);
-
- }
-}
diff --git a/vendor/sabre/dav/tests/Sabre/CardDAV/AddressBookQueryTest.php b/vendor/sabre/dav/tests/Sabre/CardDAV/AddressBookQueryTest.php
index c79f7e877..478f6beb5 100644
--- a/vendor/sabre/dav/tests/Sabre/CardDAV/AddressBookQueryTest.php
+++ b/vendor/sabre/dav/tests/Sabre/CardDAV/AddressBookQueryTest.php
@@ -12,7 +12,7 @@ class AddressBookQueryTest extends AbstractPluginTest {
function testQuery() {
- $request = new HTTP\Request(array(
+ $request = HTTP\Sapi::createFromServerArray(array(
'REQUEST_METHOD' => 'REPORT',
'REQUEST_URI' => '/addressbooks/user1/book1',
'HTTP_DEPTH' => '1',
@@ -37,7 +37,7 @@ class AddressBookQueryTest extends AbstractPluginTest {
$this->server->exec();
- $this->assertEquals('HTTP/1.1 207 Multi-Status', $response->status, 'Incorrect status code. Full response body:' . $response->body);
+ $this->assertEquals(207, $response->status, 'Incorrect status code. Full response body:' . $response->body);
// using the client for parsing
$client = new DAV\Client(array('baseUri'=>'/'));
@@ -62,7 +62,7 @@ class AddressBookQueryTest extends AbstractPluginTest {
function testQueryDepth0() {
- $request = new HTTP\Request(array(
+ $request = HTTP\Sapi::createFromServerArray(array(
'REQUEST_METHOD' => 'REPORT',
'REQUEST_URI' => '/addressbooks/user1/book1/card1',
'HTTP_DEPTH' => '0',
@@ -87,7 +87,7 @@ class AddressBookQueryTest extends AbstractPluginTest {
$this->server->exec();
- $this->assertEquals('HTTP/1.1 207 Multi-Status', $response->status, 'Incorrect status code. Full response body:' . $response->body);
+ $this->assertEquals(207, $response->status, 'Incorrect status code. Full response body:' . $response->body);
// using the client for parsing
$client = new DAV\Client(array('baseUri'=>'/'));
@@ -107,7 +107,7 @@ class AddressBookQueryTest extends AbstractPluginTest {
function testQueryNoMatch() {
- $request = new HTTP\Request(array(
+ $request = HTTP\Sapi::createFromServerArray(array(
'REQUEST_METHOD' => 'REPORT',
'REQUEST_URI' => '/addressbooks/user1/book1',
'HTTP_DEPTH' => '1',
@@ -132,7 +132,7 @@ class AddressBookQueryTest extends AbstractPluginTest {
$this->server->exec();
- $this->assertEquals('HTTP/1.1 207 Multi-Status', $response->status, 'Incorrect status code. Full response body:' . $response->body);
+ $this->assertEquals(207, $response->status, 'Incorrect status code. Full response body:' . $response->body);
// using the client for parsing
$client = new DAV\Client(array('baseUri'=>'/'));
@@ -145,7 +145,7 @@ class AddressBookQueryTest extends AbstractPluginTest {
function testQueryLimit() {
- $request = new HTTP\Request(array(
+ $request = HTTP\Sapi::createFromServerArray(array(
'REQUEST_METHOD' => 'REPORT',
'REQUEST_URI' => '/addressbooks/user1/book1',
'HTTP_DEPTH' => '1',
@@ -171,7 +171,7 @@ class AddressBookQueryTest extends AbstractPluginTest {
$this->server->exec();
- $this->assertEquals('HTTP/1.1 207 Multi-Status', $response->status, 'Incorrect status code. Full response body:' . $response->body);
+ $this->assertEquals(207, $response->status, 'Incorrect status code. Full response body:' . $response->body);
// using the client for parsing
$client = new DAV\Client(array('baseUri'=>'/'));
@@ -189,4 +189,122 @@ class AddressBookQueryTest extends AbstractPluginTest {
}
+ function testJson() {
+
+ $request = new HTTP\Request(
+ 'REPORT',
+ '/addressbooks/user1/book1/card1',
+ ['Depth' => '0']
+ );
+
+ $request->setBody(
+'<?xml version="1.0"?>
+<c:addressbook-query xmlns:d="DAV:" xmlns:c="urn:ietf:params:xml:ns:carddav">
+ <d:prop>
+ <c:address-data content-type="application/vcard+json" />
+ <d:getetag />
+ </d:prop>
+</c:addressbook-query>'
+ );
+
+ $response = new HTTP\ResponseMock();
+
+ $this->server->httpRequest = $request;
+ $this->server->httpResponse = $response;
+
+ $this->server->exec();
+
+ $this->assertEquals(207, $response->status, 'Incorrect status code. Full response body:' . $response->body);
+
+ // using the client for parsing
+ $client = new DAV\Client(array('baseUri'=>'/'));
+
+ $result = $client->parseMultiStatus($response->body);
+
+ $vobjVersion = \Sabre\VObject\Version::VERSION;
+
+ $this->assertEquals(array(
+ '/addressbooks/user1/book1/card1' => array(
+ 200 => array(
+ '{DAV:}getetag' => '"' . md5("BEGIN:VCARD\nVERSION:3.0\nUID:12345\nEND:VCARD"). '"',
+ '{urn:ietf:params:xml:ns:carddav}address-data' => '["vcard",[["version",{},"text","4.0"],["prodid",{},"text","-\/\/Sabre\/\/Sabre VObject ' . $vobjVersion . '\/\/EN"],["uid",{},"text","12345"]]]',
+ ),
+ ),
+ ), $result);
+
+ }
+
+ function testVCard4() {
+
+ $request = new HTTP\Request(
+ 'REPORT',
+ '/addressbooks/user1/book1/card1',
+ ['Depth' => '0']
+ );
+
+ $request->setBody(
+'<?xml version="1.0"?>
+<c:addressbook-query xmlns:d="DAV:" xmlns:c="urn:ietf:params:xml:ns:carddav">
+ <d:prop>
+ <c:address-data content-type="text/vcard" version="4.0" />
+ <d:getetag />
+ </d:prop>
+</c:addressbook-query>'
+ );
+
+ $response = new HTTP\ResponseMock();
+
+ $this->server->httpRequest = $request;
+ $this->server->httpResponse = $response;
+
+ $this->server->exec();
+
+ $this->assertEquals(207, $response->status, 'Incorrect status code. Full response body:' . $response->body);
+
+ // using the client for parsing
+ $client = new DAV\Client(array('baseUri'=>'/'));
+
+ $result = $client->parseMultiStatus($response->body);
+
+ $vobjVersion = \Sabre\VObject\Version::VERSION;
+
+ $this->assertEquals(array(
+ '/addressbooks/user1/book1/card1' => array(
+ 200 => array(
+ '{DAV:}getetag' => '"' . md5("BEGIN:VCARD\nVERSION:3.0\nUID:12345\nEND:VCARD"). '"',
+ '{urn:ietf:params:xml:ns:carddav}address-data' => "BEGIN:VCARD\r\nVERSION:4.0\r\nPRODID:-//Sabre//Sabre VObject $vobjVersion//EN\r\nUID:12345\r\nEND:VCARD\r\n",
+ ),
+ ),
+ ), $result);
+
+ }
+
+ function testAddressBookDepth0() {
+
+ $request = new HTTP\Request(
+ 'REPORT',
+ '/addressbooks/user1/book1',
+ ['Depth' => '0']
+ );
+
+ $request->setBody(
+'<?xml version="1.0"?>
+<c:addressbook-query xmlns:d="DAV:" xmlns:c="urn:ietf:params:xml:ns:carddav">
+ <d:prop>
+ <c:address-data content-type="application/vcard+json" />
+ <d:getetag />
+ </d:prop>
+</c:addressbook-query>'
+ );
+
+ $response = new HTTP\ResponseMock();
+
+ $this->server->httpRequest = $request;
+ $this->server->httpResponse = $response;
+
+ $this->server->exec();
+
+ $this->assertEquals(415, $response->status, 'Incorrect status code. Full response body:' . $response->body);
+
+ }
}
diff --git a/vendor/sabre/dav/tests/Sabre/CardDAV/AddressBookRootTest.php b/vendor/sabre/dav/tests/Sabre/CardDAV/AddressBookRootTest.php
index 6eaff5db0..fc20480f2 100644
--- a/vendor/sabre/dav/tests/Sabre/CardDAV/AddressBookRootTest.php
+++ b/vendor/sabre/dav/tests/Sabre/CardDAV/AddressBookRootTest.php
@@ -24,7 +24,7 @@ class AddressBookRootTest extends \PHPUnit_Framework_TestCase {
$children = $root->getChildren();
$this->assertEquals(3, count($children));
- $this->assertInstanceOf('Sabre\\CardDAV\\UserAddressBooks', $children[0]);
+ $this->assertInstanceOf('Sabre\\CardDAV\\AddressBookHome', $children[0]);
$this->assertEquals('user1', $children[0]->getName());
}
diff --git a/vendor/sabre/dav/tests/Sabre/CardDAV/AddressBookTest.php b/vendor/sabre/dav/tests/Sabre/CardDAV/AddressBookTest.php
index aac749b37..fe8ba9025 100644
--- a/vendor/sabre/dav/tests/Sabre/CardDAV/AddressBookTest.php
+++ b/vendor/sabre/dav/tests/Sabre/CardDAV/AddressBookTest.php
@@ -2,6 +2,7 @@
namespace Sabre\CardDAV;
+use Sabre\DAV\PropPatch;
require_once 'Sabre/CardDAV/Backend/Mock.php';
@@ -105,9 +106,11 @@ class AddressBookTest extends \PHPUnit_Framework_TestCase {
function testUpdateProperties() {
- $this->assertTrue(
- $this->ab->updateProperties(array('{DAV:}displayname' => 'barrr'))
- );
+ $propPatch = new PropPatch([
+ '{DAV:}displayname' => 'barrr',
+ ]);
+ $this->ab->propPatch($propPatch);
+ $this->assertTrue($propPatch->commit());
$this->assertEquals('barrr', $this->backend->addressBooks[0]['{DAV:}displayname']);
@@ -158,5 +161,52 @@ class AddressBookTest extends \PHPUnit_Framework_TestCase {
}
+ function testGetSyncTokenNoSyncSupport() {
+
+ $this->assertNull($this->ab->getSyncToken());
+
+ }
+ function testGetChangesNoSyncSupport() {
+
+ $this->assertNull($this->ab->getChanges(1,null));
+
+ }
+
+ function testGetSyncToken() {
+
+ if (!SABRE_HASSQLITE) {
+ $this->markTestSkipped('Sqlite is required for this test to run');
+ }
+ $ab = new AddressBook(TestUtil::getBackend(), [ 'id' => 1, '{DAV:}sync-token' => 2]);
+ $this->assertEquals(2, $ab->getSyncToken());
+ TestUtil::deleteSQLiteDB();
+ }
+
+ function testGetSyncToken2() {
+
+ if (!SABRE_HASSQLITE) {
+ $this->markTestSkipped('Sqlite is required for this test to run');
+ }
+ $ab = new AddressBook(TestUtil::getBackend(), [ 'id' => 1, '{http://sabredav.org/ns}sync-token' => 2]);
+ $this->assertEquals(2, $ab->getSyncToken());
+ TestUtil::deleteSQLiteDB();
+ }
+
+ function testGetChanges() {
+
+ if (!SABRE_HASSQLITE) {
+ $this->markTestSkipped('Sqlite is required for this test to run');
+ }
+ $ab = new AddressBook(TestUtil::getBackend(), [ 'id' => 1, '{DAV:}sync-token' => 2]);
+ $this->assertEquals([
+ 'syncToken' => 2,
+ 'modified' => [],
+ 'deleted' => [],
+ 'added' => ['UUID-2345'],
+ ], $ab->getChanges(1, 1));
+ TestUtil::deleteSQLiteDB();
+
+ }
+
}
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);
+
+ }
}
diff --git a/vendor/sabre/dav/tests/Sabre/CardDAV/Backend/Mock.php b/vendor/sabre/dav/tests/Sabre/CardDAV/Backend/Mock.php
index ab7ac4e6a..3f96d3c5d 100644
--- a/vendor/sabre/dav/tests/Sabre/CardDAV/Backend/Mock.php
+++ b/vendor/sabre/dav/tests/Sabre/CardDAV/Backend/Mock.php
@@ -48,18 +48,36 @@ class Mock extends AbstractBackend {
}
- function updateAddressBook($addressBookId, array $mutations) {
+ /**
+ * Updates properties for an address book.
+ *
+ * The list of mutations is stored in a Sabre\DAV\PropPatch object.
+ * To do the actual updates, you must tell this object which properties
+ * you're going to process with the handle() method.
+ *
+ * Calling the handle method is like telling the PropPatch object "I
+ * promise I can handle updating this property".
+ *
+ * Read the PropPatch documenation for more info and examples.
+ *
+ * @param string $addressBookId
+ * @param \Sabre\DAV\PropPatch $propPatch
+ * @return void
+ */
+ public function updateAddressBook($addressBookId, \Sabre\DAV\PropPatch $propPatch) {
foreach($this->addressBooks as &$book) {
if ($book['id'] !== $addressBookId)
continue;
- foreach($mutations as $key=>$value) {
- $book[$key] = $value;
- }
- return true;
+ $propPatch->handleRemaining(function($mutations) use (&$book) {
+ foreach($mutations as $key=>$value) {
+ $book[$key] = $value;
+ }
+ return true;
+ });
+
}
- return false;
}
diff --git a/vendor/sabre/dav/tests/Sabre/CardDAV/Backend/PDOMySQLTest.php b/vendor/sabre/dav/tests/Sabre/CardDAV/Backend/PDOMySQLTest.php
index b2f871f6e..38cb655d0 100644
--- a/vendor/sabre/dav/tests/Sabre/CardDAV/Backend/PDOMySQLTest.php
+++ b/vendor/sabre/dav/tests/Sabre/CardDAV/Backend/PDOMySQLTest.php
@@ -16,42 +16,18 @@ class PDOMySQLTest extends AbstractPDOTest {
$pdo = \Sabre\TestUtil::getMySQLDB();
if (!$pdo) $this->markTestSkipped('Could not connect to MySQL database');
- $pdo->query("DROP TABLE IF EXISTS addressbooks");
- $pdo->query("DROP TABLE IF EXISTS cards");
- $pdo->query("
-CREATE TABLE addressbooks (
- id INT(11) UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,
- principaluri VARCHAR(255),
- displayname VARCHAR(255),
- uri VARCHAR(100),
- description TEXT,
- ctag INT(11) UNSIGNED NOT NULL DEFAULT '1'
-);
-");
-
- $pdo->query("
-INSERT INTO addressbooks
- (principaluri, displayname, uri, description, ctag)
-VALUES
- ('principals/user1', 'book1', 'book1', 'addressbook 1', 1);
-");
-
- $pdo->query("
-CREATE TABLE cards (
- id INT(11) UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,
- addressbookid INT(11) UNSIGNED NOT NULL,
- carddata TEXT,
- uri VARCHAR(100),
- lastmodified INT(11) UNSIGNED
-);
-");
-
- $pdo->query("
-INSERT INTO cards
- (addressbookid, carddata, uri, lastmodified)
-VALUES
- (1, 'card1', 'card1', 0);
-");
+ $pdo->query("DROP TABLE IF EXISTS addressbooks, cards, addressbookchanges");
+
+ $queries = explode(
+ ';',
+ file_get_contents(__DIR__ . '/../../../../examples/sql/mysql.addressbook.sql')
+ );
+
+ foreach($queries as $query) {
+ $query = trim($query," \r\n\t");
+ if ($query)
+ $pdo->exec($query);
+ }
return $pdo;
}
diff --git a/vendor/sabre/dav/tests/Sabre/CardDAV/Backend/PDOSqliteTest.php b/vendor/sabre/dav/tests/Sabre/CardDAV/Backend/PDOSqliteTest.php
index a9bbb0bd1..5a4a7a327 100644
--- a/vendor/sabre/dav/tests/Sabre/CardDAV/Backend/PDOSqliteTest.php
+++ b/vendor/sabre/dav/tests/Sabre/CardDAV/Backend/PDOSqliteTest.php
@@ -18,48 +18,33 @@ class PDOSqliteTest extends AbstractPDOTest {
*/
function getPDO() {
+ return self::getSQLite();
+
+ }
+
+ /**
+ * @return PDO
+ */
+ static function getSQLite() {
+
if (!SABRE_HASSQLITE) $this->markTestSkipped('SQLite driver is not available');
$pdo = new \PDO('sqlite:'.SABRE_TEMPDIR.'/pdobackend');
$pdo->setAttribute(\PDO::ATTR_ERRMODE,\PDO::ERRMODE_EXCEPTION);
$pdo->query("DROP TABLE IF EXISTS addressbooks");
+ $pdo->query("DROP TABLE IF EXISTS addressbookchanges");
$pdo->query("DROP TABLE IF EXISTS cards");
- $pdo->query("
-CREATE TABLE addressbooks (
- id integer primary key asc,
- principaluri text,
- displayname text,
- uri text,
- description text,
- ctag integer
-);
-
-");
-
- $pdo->query("
-INSERT INTO addressbooks
- (principaluri, displayname, uri, description, ctag)
-VALUES
- ('principals/user1', 'book1', 'book1', 'addressbook 1', 1);
-");
-
- $pdo->query("
-
-CREATE TABLE cards (
- id integer primary key asc,
- addressbookid integer,
- carddata text,
- uri text,
- lastmodified integer
-);
-
-");
- $pdo->query("
-INSERT INTO cards
- (addressbookid, carddata, uri, lastmodified)
-VALUES
- (1, 'card1', 'card1', 0);
-");
+
+ $queries = explode(
+ ';',
+ file_get_contents(__DIR__ . '/../../../../examples/sql/sqlite.addressbooks.sql')
+ );
+
+ foreach($queries as $query) {
+ $query = trim($query," \r\n\t");
+ if ($query)
+ $pdo->exec($query);
+ }
return $pdo;
diff --git a/vendor/sabre/dav/tests/Sabre/CardDAV/CardTest.php b/vendor/sabre/dav/tests/Sabre/CardDAV/CardTest.php
index 438bd2ea5..cf8dbab0c 100644
--- a/vendor/sabre/dav/tests/Sabre/CardDAV/CardTest.php
+++ b/vendor/sabre/dav/tests/Sabre/CardDAV/CardTest.php
@@ -82,7 +82,7 @@ class CardTest extends \PHPUnit_Framework_TestCase {
function testGetContentType() {
- $this->assertEquals('text/x-vcard; charset=utf-8', $this->card->getContentType());
+ $this->assertEquals('text/vcard; charset=utf-8', $this->card->getContentType());
}
@@ -163,6 +163,37 @@ class CardTest extends \PHPUnit_Framework_TestCase {
), $this->card->getACL());
}
+ function testOverrideACL() {
+
+ $card = new Card(
+ $this->backend,
+ array(
+ 'uri' => 'book1',
+ 'id' => 'foo',
+ 'principaluri' => 'principals/user1',
+ ),
+ array(
+ 'uri' => 'card1',
+ 'addressbookid' => 'foo',
+ 'carddata' => 'card',
+ 'acl' => array(
+ array(
+ 'privilege' => '{DAV:}read',
+ 'principal' => 'principals/user1',
+ 'protected' => true,
+ ),
+ ),
+ )
+ );
+ $this->assertEquals(array(
+ array(
+ 'privilege' => '{DAV:}read',
+ 'principal' => 'principals/user1',
+ 'protected' => true,
+ ),
+ ), $card->getACL());
+
+ }
/**
* @expectedException Sabre\DAV\Exception\MethodNotAllowed
diff --git a/vendor/sabre/dav/tests/Sabre/CardDAV/MultiGetTest.php b/vendor/sabre/dav/tests/Sabre/CardDAV/MultiGetTest.php
index 12922c6fd..b0ee45880 100644
--- a/vendor/sabre/dav/tests/Sabre/CardDAV/MultiGetTest.php
+++ b/vendor/sabre/dav/tests/Sabre/CardDAV/MultiGetTest.php
@@ -11,7 +11,7 @@ class MultiGetTest extends AbstractPluginTest {
function testMultiGet() {
- $request = new HTTP\Request(array(
+ $request = HTTP\Sapi::createFromServerArray(array(
'REQUEST_METHOD' => 'REPORT',
'REQUEST_URI' => '/addressbooks/user1/book1',
));
@@ -34,7 +34,7 @@ class MultiGetTest extends AbstractPluginTest {
$this->server->exec();
- $this->assertEquals('HTTP/1.1 207 Multi-Status', $response->status, 'Incorrect status code. Full response body:' . $response->body);
+ $this->assertEquals(207, $response->status, 'Incorrect status code. Full response body:' . $response->body);
// using the client for parsing
$client = new DAV\Client(array('baseUri'=>'/'));
@@ -45,11 +45,55 @@ class MultiGetTest extends AbstractPluginTest {
'/addressbooks/user1/book1/card1' => array(
200 => array(
'{DAV:}getetag' => '"' . md5("BEGIN:VCARD\nVERSION:3.0\nUID:12345\nEND:VCARD") . '"',
- '{urn:ietf:params:xml:ns:carddav}address-data' => "BEGIN:VCARD\nVERSION:3.0\nUID:12345\nEND:VCARD",
+ '{urn:ietf:params:xml:ns:carddav}address-data' => "BEGIN:VCARD\r\nVERSION:3.0\r\nUID:12345\r\nEND:VCARD\r\n",
)
)
), $result);
}
+ function testMultiGetVCard4() {
+
+ $request = HTTP\Sapi::createFromServerArray(array(
+ 'REQUEST_METHOD' => 'REPORT',
+ 'REQUEST_URI' => '/addressbooks/user1/book1',
+ ));
+
+ $request->setBody(
+'<?xml version="1.0"?>
+<c:addressbook-multiget xmlns:d="DAV:" xmlns:c="urn:ietf:params:xml:ns:carddav">
+ <d:prop>
+ <d:getetag />
+ <c:address-data content-type="text/vcard" version="4.0" />
+ </d:prop>
+ <d:href>/addressbooks/user1/book1/card1</d:href>
+</c:addressbook-multiget>'
+ );
+
+ $response = new HTTP\ResponseMock();
+
+ $this->server->httpRequest = $request;
+ $this->server->httpResponse = $response;
+
+ $this->server->exec();
+
+ $this->assertEquals(207, $response->status, 'Incorrect status code. Full response body:' . $response->body);
+
+ // using the client for parsing
+ $client = new DAV\Client(array('baseUri'=>'/'));
+
+ $result = $client->parseMultiStatus($response->body);
+
+ $prodId = "PRODID:-//Sabre//Sabre VObject " . \Sabre\VObject\Version::VERSION . "//EN";
+
+ $this->assertEquals(array(
+ '/addressbooks/user1/book1/card1' => array(
+ 200 => array(
+ '{DAV:}getetag' => '"' . md5("BEGIN:VCARD\nVERSION:3.0\nUID:12345\nEND:VCARD") . '"',
+ '{urn:ietf:params:xml:ns:carddav}address-data' => "BEGIN:VCARD\r\nVERSION:4.0\r\n$prodId\r\nUID:12345\r\nEND:VCARD\r\n",
+ )
+ )
+ ), $result);
+
+ }
}
diff --git a/vendor/sabre/dav/tests/Sabre/CardDAV/PluginTest.php b/vendor/sabre/dav/tests/Sabre/CardDAV/PluginTest.php
index 297ebf496..9c916350e 100644
--- a/vendor/sabre/dav/tests/Sabre/CardDAV/PluginTest.php
+++ b/vendor/sabre/dav/tests/Sabre/CardDAV/PluginTest.php
@@ -3,17 +3,16 @@
namespace Sabre\CardDAV;
use Sabre\DAV;
-
-require_once 'Sabre/CardDAV/AbstractPluginTest.php';
+use Sabre\DAV\Xml\Property\Href;
class PluginTest extends AbstractPluginTest {
function testConstruct() {
- $this->assertEquals('card', $this->server->xmlNamespaces[Plugin::NS_CARDDAV]);
$this->assertEquals('{' . Plugin::NS_CARDDAV . '}addressbook', $this->server->resourceTypeMapping['Sabre\\CardDAV\\IAddressBook']);
$this->assertTrue(in_array('addressbook', $this->plugin->getFeatures()));
+ $this->assertEquals('carddav', $this->plugin->getPluginInfo()['name']);
}
@@ -43,25 +42,6 @@ class PluginTest extends AbstractPluginTest {
}
- function testMeCardTest() {
-
- $result = $this->server->getProperties(
- 'addressbooks/user1',
- array(
- '{http://calendarserver.org/ns/}me-card',
- )
- );
-
- $this->assertEquals(
- array(
- '{http://calendarserver.org/ns/}me-card' =>
- new DAV\Property\Href('addressbooks/user1/book1/vcard1.vcf')
- ),
- $result
- );
-
- }
-
function testDirectoryGateway() {
$result = $this->server->getProperties('principals/user1', array('{' . Plugin::NS_CARDDAV . '}directory-gateway'));
@@ -74,76 +54,50 @@ class PluginTest extends AbstractPluginTest {
function testReportPassThrough() {
- $this->assertNull($this->plugin->report('{DAV:}foo', new \DomDocument()));
+ $this->assertNull($this->plugin->report('{DAV:}foo', new \DomDocument(), ''));
}
function testHTMLActionsPanel() {
$output = '';
- $r = $this->server->broadcastEvent('onHTMLActionsPanel', array($this->server->tree->getNodeForPath('addressbooks/user1'), &$output));
+ $r = $this->server->emit('onHTMLActionsPanel', [$this->server->tree->getNodeForPath('addressbooks/user1'), &$output]);
$this->assertFalse($r);
$this->assertTrue(!!strpos($output,'Display name'));
}
- function testBrowserPostAction() {
+ function testAddressbookPluginProperties() {
- $r = $this->server->broadcastEvent('onBrowserPostAction', array('addressbooks/user1', 'mkaddressbook', array(
- 'name' => 'NEWADDRESSBOOK',
- '{DAV:}displayname' => 'foo',
- )));
- $this->assertFalse($r);
+ $ns = '{' . Plugin::NS_CARDDAV . '}';
+ $propFind = new DAV\PropFind('addressbooks/user1/book1', [
+ $ns . 'supported-address-data',
+ $ns . 'supported-collation-set',
+ ]);
+ $node = $this->server->tree->getNodeForPath('addressbooks/user1/book1');
+ $this->plugin->propFindEarly($propFind, $node);
- $addressbooks = $this->backend->getAddressBooksforUser('principals/user1');
- $this->assertEquals(2, count($addressbooks));
+ $this->assertInstanceOf(
+ 'Sabre\\CardDAV\\Xml\\Property\\SupportedAddressData',
+ $propFind->get($ns . 'supported-address-data')
+ );
+ $this->assertInstanceOf(
+ 'Sabre\\CardDAV\\Xml\\Property\\SupportedCollationSet',
+ $propFind->get($ns . 'supported-collation-set')
+ );
- $newAddressBook = null;
- foreach($addressbooks as $addressbook) {
- if ($addressbook['uri'] === 'NEWADDRESSBOOK') {
- $newAddressBook = $addressbook;
- break;
- }
- }
- if (!$newAddressBook)
- $this->fail('Could not find newly created addressbook');
}
- function testUpdatePropertiesMeCard() {
+ function testGetTransform() {
- $result = $this->server->updateProperties('addressbooks/user1', array(
- '{http://calendarserver.org/ns/}me-card' => new DAV\Property\Href('/addressbooks/user1/book1/vcard2',true),
- ));
+ $request = new \Sabre\HTTP\Request('GET', '/addressbooks/user1/book1/card1', ['Accept: application/vcard+json']);
+ $response = new \Sabre\HTTP\ResponseMock();
+ $this->server->invokeMethod($request, $response);
- $this->assertEquals(
- array(
- 'href' => 'addressbooks/user1',
- 200 => array(
- '{http://calendarserver.org/ns/}me-card' => null,
- ),
- ),
- $result
- );
+ $this->assertEquals(200, $response->getStatus());
}
- function testUpdatePropertiesMeCardBadValue() {
-
- $result = $this->server->updateProperties('addressbooks/user1', array(
- '{http://calendarserver.org/ns/}me-card' => new DAV\Property\HrefList(array()),
- ));
-
- $this->assertEquals(
- array(
- 'href' => 'addressbooks/user1',
- 400 => array(
- '{http://calendarserver.org/ns/}me-card' => null,
- ),
- ),
- $result
- );
-
- }
}
diff --git a/vendor/sabre/dav/tests/Sabre/CardDAV/Property/SupportedAddressDataTest.php b/vendor/sabre/dav/tests/Sabre/CardDAV/Property/SupportedAddressDataTest.php
deleted file mode 100644
index a0e4130d5..000000000
--- a/vendor/sabre/dav/tests/Sabre/CardDAV/Property/SupportedAddressDataTest.php
+++ /dev/null
@@ -1,44 +0,0 @@
-<?php
-
-namespace Sabre\CardDAV\Property;
-
-use Sabre\CardDAV;
-use Sabre\DAV;
-
-class SupportedAddressDataDataTest extends \PHPUnit_Framework_TestCase {
-
- function testSimple() {
-
- $property = new SupportedAddressData();
-
- }
-
- /**
- * @depends testSimple
- */
- function testSerialize() {
-
- $property = new SupportedAddressData();
-
- $doc = new \DOMDocument();
- $root = $doc->createElementNS(CardDAV\Plugin::NS_CARDDAV, 'card:root');
- $root->setAttribute('xmlns:d','DAV:');
-
- $doc->appendChild($root);
- $server = new DAV\Server();
-
- $property->serialize($server, $root);
-
- $xml = $doc->saveXML();
-
- $this->assertEquals(
-'<?xml version="1.0"?>
-<card:root xmlns:card="' . CardDAV\Plugin::NS_CARDDAV . '" xmlns:d="DAV:">' .
-'<card:address-data-type content-type="text/vcard" version="3.0"/>' .
-//'<card:address-data-type content-type="text/vcard" version="4.0"/>' .
-'</card:root>
-', $xml);
-
- }
-
-}
diff --git a/vendor/sabre/dav/tests/Sabre/CardDAV/SogoStripContentTypeTest.php b/vendor/sabre/dav/tests/Sabre/CardDAV/SogoStripContentTypeTest.php
index 2a62bd2f9..f828cc25b 100644
--- a/vendor/sabre/dav/tests/Sabre/CardDAV/SogoStripContentTypeTest.php
+++ b/vendor/sabre/dav/tests/Sabre/CardDAV/SogoStripContentTypeTest.php
@@ -3,6 +3,7 @@
namespace Sabre\CardDAV;
use Sabre\HTTP;
+use Sabre\DAV\PropFind;
class SogoStripContentType extends \Sabre\DAVServerTest {
@@ -24,13 +25,13 @@ class SogoStripContentType extends \Sabre\DAVServerTest {
$result = $this->server->getProperties('addressbooks/user1/book1/card1.vcf',array('{DAV:}getcontenttype'));
$this->assertEquals(array(
- '{DAV:}getcontenttype' => 'text/x-vcard; charset=utf-8'
+ '{DAV:}getcontenttype' => 'text/vcard; charset=utf-8'
), $result);
}
function testStrip() {
- $this->server->httpRequest = new HTTP\Request(array(
+ $this->server->httpRequest = HTTP\Sapi::createFromServerArray(array(
'HTTP_USER_AGENT' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:10.0.2) Gecko/20120216 Thunderbird/10.0.2 Lightning/1.2.1',
));
$result = $this->server->getProperties('addressbooks/user1/book1/card1.vcf',array('{DAV:}getcontenttype'));
@@ -39,5 +40,17 @@ class SogoStripContentType extends \Sabre\DAVServerTest {
), $result);
}
+ function testDontTouchOtherMimeTypes() {
+
+ $this->server->httpRequest = new HTTP\Request('GET','/addressbooks/user1/book1/card1.vcf', [
+ 'User-Agent' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:10.0.2) Gecko/20120216 Thunderbird/10.0.2 Lightning/1.2.1',
+ ]);
+
+ $propFind = new PropFind('hello', ['{DAV:}getcontenttype']);
+ $propFind->set('{DAV:}getcontenttype', 'text/plain');
+ $this->carddavPlugin->propFindLate($propFind, new \Sabre\DAV\SimpleCollection('foo'));
+ $this->assertEquals('text/plain', $propFind->get('{DAV:}getcontenttype'));
+
+ }
}
diff --git a/vendor/sabre/dav/tests/Sabre/CardDAV/TestUtil.php b/vendor/sabre/dav/tests/Sabre/CardDAV/TestUtil.php
index 9f84566af..c9cc10d35 100644
--- a/vendor/sabre/dav/tests/Sabre/CardDAV/TestUtil.php
+++ b/vendor/sabre/dav/tests/Sabre/CardDAV/TestUtil.php
@@ -15,17 +15,8 @@ class TestUtil {
static function getSQLiteDB() {
- if (file_exists(SABRE_TEMPDIR . '/testdb.sqlite'))
- unlink(SABRE_TEMPDIR . '/testdb.sqlite');
+ $pdo = Backend\PDOSqliteTest::getSQLite();
- $pdo = new PDO('sqlite:' . SABRE_TEMPDIR . '/testdb.sqlite');
- $pdo->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION);
-
- // Yup this is definitely not 'fool proof', but good enough for now.
- $queries = explode(';', file_get_contents(__DIR__ . '/../../../examples/sql/sqlite.addressbooks.sql'));
- foreach($queries as $query) {
- $pdo->exec($query);
- }
// Inserting events through a backend class.
$backend = new Backend\PDO($pdo);
$addressbookId = $backend->createAddressBook(
@@ -49,7 +40,12 @@ class TestUtil {
}
- static function getTestCardData($type = 1) {
+ static function deleteSQLiteDB() {
+ $sqliteTest = new Backend\PDOSqliteTest();
+ $pdo = $sqliteTest->tearDown();
+ }
+
+ static function getTestCardData() {
$addressbookData = 'BEGIN:VCARD
VERSION:3.0
diff --git a/vendor/sabre/dav/tests/Sabre/CardDAV/UserAddressBooksTest.php b/vendor/sabre/dav/tests/Sabre/CardDAV/UserAddressBooksTest.php
deleted file mode 100644
index a6ecf3e47..000000000
--- a/vendor/sabre/dav/tests/Sabre/CardDAV/UserAddressBooksTest.php
+++ /dev/null
@@ -1,162 +0,0 @@
-<?php
-
-namespace Sabre\CardDAV;
-
-class UserAddressBooksTest extends \PHPUnit_Framework_TestCase {
-
- /**
- * @var Sabre\CardDAV\UserAddressBooks
- */
- protected $s;
- protected $backend;
-
- function setUp() {
-
- $this->backend = new Backend\Mock();
- $this->s = new UserAddressBooks(
- $this->backend,
- 'principals/user1'
- );
-
- }
-
- function testGetName() {
-
- $this->assertEquals('user1', $this->s->getName());
-
- }
-
- /**
- * @expectedException Sabre\DAV\Exception\MethodNotAllowed
- */
- function testSetName() {
-
- $this->s->setName('user2');
-
- }
-
- /**
- * @expectedException Sabre\DAV\Exception\MethodNotAllowed
- */
- function testDelete() {
-
- $this->s->delete();
-
- }
-
- function testGetLastModified() {
-
- $this->assertNull($this->s->getLastModified());
-
- }
-
- /**
- * @expectedException Sabre\DAV\Exception\MethodNotAllowed
- */
- function testCreateFile() {
-
- $this->s->createFile('bla');
-
- }
-
- /**
- * @expectedException Sabre\DAV\Exception\MethodNotAllowed
- */
- function testCreateDirectory() {
-
- $this->s->createDirectory('bla');
-
- }
-
- function testGetChild() {
-
- $child = $this->s->getChild('book1');
- $this->assertInstanceOf('Sabre\\CardDAV\\AddressBook', $child);
- $this->assertEquals('book1', $child->getName());
-
- }
-
- /**
- * @expectedException Sabre\DAV\Exception\NotFound
- */
- function testGetChild404() {
-
- $this->s->getChild('book2');
-
- }
-
- function testGetChildren() {
-
- $children = $this->s->getChildren();
- $this->assertEquals(1, count($children));
- $this->assertInstanceOf('Sabre\\CardDAV\\AddressBook', $children[0]);
- $this->assertEquals('book1', $children[0]->getName());
-
- }
-
- function testCreateExtendedCollection() {
-
- $resourceType = array(
- '{' . Plugin::NS_CARDDAV . '}addressbook',
- '{DAV:}collection',
- );
- $this->s->createExtendedCollection('book2', $resourceType, array('{DAV:}displayname' => 'a-book 2'));
-
- $this->assertEquals(array(
- 'id' => 'book2',
- 'uri' => 'book2',
- '{DAV:}displayname' => 'a-book 2',
- 'principaluri' => 'principals/user1',
- ), $this->backend->addressBooks[1]);
-
- }
-
- /**
- * @expectedException Sabre\DAV\Exception\InvalidResourceType
- */
- function testCreateExtendedCollectionInvalid() {
-
- $resourceType = array(
- '{DAV:}collection',
- );
- $this->s->createExtendedCollection('book2', $resourceType, array('{DAV:}displayname' => 'a-book 2'));
-
- }
-
-
- function testACLMethods() {
-
- $this->assertEquals('principals/user1', $this->s->getOwner());
- $this->assertNull($this->s->getGroup());
- $this->assertEquals(array(
- array(
- 'privilege' => '{DAV:}read',
- 'principal' => 'principals/user1',
- 'protected' => true,
- ),
- array(
- 'privilege' => '{DAV:}write',
- 'principal' => 'principals/user1',
- 'protected' => true,
- ),
- ), $this->s->getACL());
-
- }
-
- /**
- * @expectedException Sabre\DAV\Exception\MethodNotAllowed
- */
- function testSetACL() {
-
- $this->s->setACL(array());
-
- }
-
- function testGetSupportedPrivilegeSet() {
-
- $this->assertNull(
- $this->s->getSupportedPrivilegeSet()
- );
-
- }
-}
diff --git a/vendor/sabre/dav/tests/Sabre/CardDAV/VCFExportTest.php b/vendor/sabre/dav/tests/Sabre/CardDAV/VCFExportTest.php
index 84da59311..71fde719d 100644
--- a/vendor/sabre/dav/tests/Sabre/CardDAV/VCFExportTest.php
+++ b/vendor/sabre/dav/tests/Sabre/CardDAV/VCFExportTest.php
@@ -29,28 +29,35 @@ class VCFExportTest extends \Sabre\DAVServerTest {
function setUp() {
parent::setUp();
+ $plugin = new VCFExportPlugin();
$this->server->addPlugin(
- new VCFExportPlugin()
+ $plugin
);
}
function testSimple() {
- $this->assertInstanceOf('Sabre\\CardDAV\\VCFExportPlugin', $this->server->getPlugin('Sabre\\CardDAV\\VCFExportPlugin'));
+ $plugin = $this->server->getPlugin('vcf-export');
+ $this->assertInstanceOf('Sabre\\CardDAV\\VCFExportPlugin', $plugin);
+
+ $this->assertEquals(
+ 'vcf-export',
+ $plugin->getPluginInfo()['name']
+ );
}
function testExport() {
- $request = new HTTP\Request(array(
+ $request = HTTP\Sapi::createFromServerArray(array(
'REQUEST_URI' => '/addressbooks/user1/book1?export',
'QUERY_STRING' => 'export',
'REQUEST_METHOD' => 'GET',
));
$response = $this->request($request);
- $this->assertEquals('HTTP/1.1 200 OK', $response->status, $response->body);
+ $this->assertEquals(200, $response->status, $response->body);
$expected = "BEGIN:VCARD
FN:Person1
@@ -72,4 +79,14 @@ END:VCARD
}
+ function testBrowserIntegration() {
+
+ $plugin = $this->server->getPlugin('vcf-export');
+ $actions = '';
+ $addressbook = new AddressBook($this->carddavBackend, []);
+ $this->server->emit('browserButtonActions', ['/foo', $addressbook, &$actions]);
+ $this->assertContains('/foo?export', $actions);
+
+ }
+
}
diff --git a/vendor/sabre/dav/tests/Sabre/CardDAV/ValidateVCardTest.php b/vendor/sabre/dav/tests/Sabre/CardDAV/ValidateVCardTest.php
index 1f52f30a7..ad8495c13 100644
--- a/vendor/sabre/dav/tests/Sabre/CardDAV/ValidateVCardTest.php
+++ b/vendor/sabre/dav/tests/Sabre/CardDAV/ValidateVCardTest.php
@@ -31,6 +31,7 @@ class ValidateVCardTest extends \PHPUnit_Framework_TestCase {
);
$this->server = new DAV\Server($tree);
+ $this->server->sapi = new HTTP\SapiMock();
$this->server->debugExceptions = true;
$plugin = new Plugin();
@@ -52,20 +53,20 @@ class ValidateVCardTest extends \PHPUnit_Framework_TestCase {
function testCreateFile() {
- $request = new HTTP\Request(array(
+ $request = HTTP\Sapi::createFromServerArray(array(
'REQUEST_METHOD' => 'PUT',
'REQUEST_URI' => '/addressbooks/admin/addressbook1/blabla.vcf',
));
$response = $this->request($request);
- $this->assertEquals('HTTP/1.1 415 Unsupported Media Type', $response->status);
+ $this->assertEquals(415, $response->status);
}
function testCreateFileValid() {
- $request = new HTTP\Request(array(
+ $request = HTTP\Sapi::createFromServerArray(array(
'REQUEST_METHOD' => 'PUT',
'REQUEST_URI' => '/addressbooks/admin/addressbook1/blabla.vcf',
));
@@ -73,7 +74,7 @@ class ValidateVCardTest extends \PHPUnit_Framework_TestCase {
$response = $this->request($request);
- $this->assertEquals('HTTP/1.1 201 Created', $response->status, 'Incorrect status returned! Full response body: ' . $response->body);
+ $this->assertEquals(201, $response->status, 'Incorrect status returned! Full response body: ' . $response->body);
$expected = array(
'uri' => 'blabla.vcf',
'carddata' => "BEGIN:VCARD\r\nUID:foo\r\nEND:VCARD\r\n",
@@ -85,24 +86,40 @@ class ValidateVCardTest extends \PHPUnit_Framework_TestCase {
function testCreateFileNoUID() {
- $request = new HTTP\Request(array(
- 'REQUEST_METHOD' => 'PUT',
- 'REQUEST_URI' => '/addressbooks/admin/addressbook1/blabla.vcf',
- ));
+ $request = new HTTP\Request(
+ 'PUT',
+ '/addressbooks/admin/addressbook1/blabla.vcf'
+ );
$request->setBody("BEGIN:VCARD\r\nEND:VCARD\r\n");
$response = $this->request($request);
- $this->assertEquals('HTTP/1.1 201 Created', $response->status, 'Incorrect status returned! Full response body: ' . $response->body);
+ $this->assertEquals(201, $response->status, 'Incorrect status returned! Full response body: ' . $response->body);
$foo = $this->cardBackend->getCard('addressbook1','blabla.vcf');
$this->assertTrue(strpos($foo['carddata'],'UID')!==false);
}
+ function testCreateFileJson() {
+
+ $request = new HTTP\Request(
+ 'PUT',
+ '/addressbooks/admin/addressbook1/blabla.vcf'
+ );
+ $request->setBody('[ "vcard" , [ [ "UID" , {}, "text", "foo" ] ] ]');
+
+ $response = $this->request($request);
+
+ $this->assertEquals(201, $response->status, 'Incorrect status returned! Full response body: ' . $response->body);
+
+ $foo = $this->cardBackend->getCard('addressbook1','blabla.vcf');
+ $this->assertEquals("BEGIN:VCARD\r\nUID:foo\r\nEND:VCARD\r\n", $foo['carddata']);
+
+ }
function testCreateFileVCalendar() {
- $request = new HTTP\Request(array(
+ $request = HTTP\Sapi::createFromServerArray(array(
'REQUEST_METHOD' => 'PUT',
'REQUEST_URI' => '/addressbooks/admin/addressbook1/blabla.vcf',
));
@@ -110,28 +127,28 @@ class ValidateVCardTest extends \PHPUnit_Framework_TestCase {
$response = $this->request($request);
- $this->assertEquals('HTTP/1.1 415 Unsupported Media Type', $response->status, 'Incorrect status returned! Full response body: ' . $response->body);
+ $this->assertEquals(415, $response->status, 'Incorrect status returned! Full response body: ' . $response->body);
}
function testUpdateFile() {
$this->cardBackend->createCard('addressbook1','blabla.vcf','foo');
- $request = new HTTP\Request(array(
+ $request = HTTP\Sapi::createFromServerArray(array(
'REQUEST_METHOD' => 'PUT',
'REQUEST_URI' => '/addressbooks/admin/addressbook1/blabla.vcf',
));
$response = $this->request($request);
- $this->assertEquals('HTTP/1.1 415 Unsupported Media Type', $response->status);
+ $this->assertEquals(415, $response->status);
}
function testUpdateFileParsableBody() {
$this->cardBackend->createCard('addressbook1','blabla.vcf','foo');
- $request = new HTTP\Request(array(
+ $request = HTTP\Sapi::createFromServerArray(array(
'REQUEST_METHOD' => 'PUT',
'REQUEST_URI' => '/addressbooks/admin/addressbook1/blabla.vcf',
));
@@ -140,7 +157,7 @@ class ValidateVCardTest extends \PHPUnit_Framework_TestCase {
$response = $this->request($request);
- $this->assertEquals('HTTP/1.1 204 No Content', $response->status);
+ $this->assertEquals(204, $response->status);
$expected = array(
'uri' => 'blabla.vcf',
diff --git a/vendor/sabre/dav/tests/Sabre/CardDAV/VersionTest.php b/vendor/sabre/dav/tests/Sabre/CardDAV/VersionTest.php
deleted file mode 100644
index 02943b2d3..000000000
--- a/vendor/sabre/dav/tests/Sabre/CardDAV/VersionTest.php
+++ /dev/null
@@ -1,17 +0,0 @@
-<?php
-
-namespace Sabre\CardDAV;
-
-class VersionTest extends \PHPUnit_Framework_TestCase {
-
- function testString() {
-
- $v = Version::VERSION;
- $this->assertEquals(-1, version_compare('0.1',$v));
-
- $s = Version::STABILITY;
- $this->assertTrue($s == 'alpha' || $s == 'beta' || $s =='stable');
-
- }
-
-}