ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
MultiGetTest.php
Go to the documentation of this file.
1<?php
2
3namespace Sabre\CardDAV;
4
5use Sabre\DAV;
6use Sabre\HTTP;
7
8require_once 'Sabre/HTTP/ResponseMock.php';
9
11
12 function testMultiGet() {
13
15 'REQUEST_METHOD' => 'REPORT',
16 'REQUEST_URI' => '/addressbooks/user1/book1',
17 ]);
18
19 $request->setBody(
20'<?xml version="1.0"?>
21<c:addressbook-multiget xmlns:d="DAV:" xmlns:c="urn:ietf:params:xml:ns:carddav">
22 <d:prop>
23 <d:getetag />
24 <c:address-data />
25 </d:prop>
26 <d:href>/addressbooks/user1/book1/card1</d:href>
27</c:addressbook-multiget>'
28 );
29
30 $response = new HTTP\ResponseMock();
31
32 $this->server->httpRequest = $request;
33 $this->server->httpResponse = $response;
34
35 $this->server->exec();
36
37 $this->assertEquals(207, $response->status, 'Incorrect status code. Full response body:' . $response->body);
38
39 // using the client for parsing
40 $client = new DAV\Client(['baseUri' => '/']);
41
42 $result = $client->parseMultiStatus($response->body);
43
44 $this->assertEquals([
45 '/addressbooks/user1/book1/card1' => [
46 200 => [
47 '{DAV:}getetag' => '"' . md5("BEGIN:VCARD\nVERSION:3.0\nUID:12345\nEND:VCARD") . '"',
48 '{urn:ietf:params:xml:ns:carddav}address-data' => "BEGIN:VCARD\nVERSION:3.0\nUID:12345\nEND:VCARD",
49 ]
50 ]
51 ], $result);
52
53 }
54
55 function testMultiGetVCard4() {
56
58 'REQUEST_METHOD' => 'REPORT',
59 'REQUEST_URI' => '/addressbooks/user1/book1',
60 ]);
61
62 $request->setBody(
63'<?xml version="1.0"?>
64<c:addressbook-multiget xmlns:d="DAV:" xmlns:c="urn:ietf:params:xml:ns:carddav">
65 <d:prop>
66 <d:getetag />
67 <c:address-data content-type="text/vcard" version="4.0" />
68 </d:prop>
69 <d:href>/addressbooks/user1/book1/card1</d:href>
70</c:addressbook-multiget>'
71 );
72
73 $response = new HTTP\ResponseMock();
74
75 $this->server->httpRequest = $request;
76 $this->server->httpResponse = $response;
77
78 $this->server->exec();
79
80 $this->assertEquals(207, $response->status, 'Incorrect status code. Full response body:' . $response->body);
81
82 // using the client for parsing
83 $client = new DAV\Client(['baseUri' => '/']);
84
85 $result = $client->parseMultiStatus($response->body);
86
87 $prodId = "PRODID:-//Sabre//Sabre VObject " . \Sabre\VObject\Version::VERSION . "//EN";
88
89 $this->assertEquals([
90 '/addressbooks/user1/book1/card1' => [
91 200 => [
92 '{DAV:}getetag' => '"' . md5("BEGIN:VCARD\nVERSION:3.0\nUID:12345\nEND:VCARD") . '"',
93 '{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",
94 ]
95 ]
96 ], $result);
97
98 }
99}
$result
foreach($paths as $path) $request
Definition: asyncclient.php:32
An exception for terminatinating execution or to throw for unit testing.
SabreDAV DAV client.
Definition: Client.php:20
static createFromServerArray(array $serverArray)
This static method will create a new Request object, based on a PHP $_SERVER array.
Definition: Sapi.php:107
const VERSION
Full version number.
Definition: Version.php:17
if($_SERVER['argc']< 4) $client
Definition: cron.php:12
$response