aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/sabre/dav/tests/Sabre/CardDAV/AddressBookQueryTest.php
diff options
context:
space:
mode:
authorAndrew Manning <tamanning@zoho.com>2016-05-11 05:54:20 -0400
committerAndrew Manning <tamanning@zoho.com>2016-05-11 05:54:20 -0400
commitd968fc51eab8b0fb259ecbeae517056b99554017 (patch)
tree10e551cff9fefbefbfd7e5031b57320116bb7fce /vendor/sabre/dav/tests/Sabre/CardDAV/AddressBookQueryTest.php
parentc7698e4dc388b7d9a9db368672cb057c1d4d3a01 (diff)
parent4dd3839c41e18d9724855e7955d8737b6f52dcd6 (diff)
downloadvolse-hubzilla-d968fc51eab8b0fb259ecbeae517056b99554017.tar.gz
volse-hubzilla-d968fc51eab8b0fb259ecbeae517056b99554017.tar.bz2
volse-hubzilla-d968fc51eab8b0fb259ecbeae517056b99554017.zip
Merge remote-tracking branch 'upstream/dev' into plugin-repo
Diffstat (limited to 'vendor/sabre/dav/tests/Sabre/CardDAV/AddressBookQueryTest.php')
-rw-r--r--vendor/sabre/dav/tests/Sabre/CardDAV/AddressBookQueryTest.php134
1 files changed, 126 insertions, 8 deletions
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);
+
+ }
}