9 require_once
'Sabre/HTTP/ResponseMock.php';
20 'id' =>
'addressbook1',
21 'principaluri' =>
'principals/admin',
22 'uri' =>
'addressbook1',
26 $this->cardBackend =
new Backend\Mock($addressbooks, []);
34 $this->server->sapi =
new HTTP\SapiMock();
35 $this->server->debugExceptions =
true;
38 $this->server->addPlugin($plugin);
47 $this->server->httpRequest =
$request;
48 $this->server->exec();
50 if ($expectedStatus) {
52 $realStatus = $this->server->httpResponse->getStatus();
55 if ($realStatus !== $expectedStatus) {
56 $msg =
'Response body: ' . $this->server->httpResponse->getBodyAsString();
65 return $this->server->httpResponse;
72 'REQUEST_METHOD' =>
'PUT',
73 'REQUEST_URI' =>
'/addressbooks/admin/addressbook1/blabla.vcf',
78 $this->assertEquals(415,
$response->status);
86 '/addressbooks/admin/addressbook1/blabla.vcf' 94 N:LastName;FirstName;;;
108 'We did not receive an etag' 113 'uri' =>
'blabla.vcf',
114 'carddata' => $vcard,
115 'size' => strlen($vcard),
116 'etag' =>
'"' . md5($vcard) .
'"',
119 $this->assertEquals($expected, $this->cardBackend->getCard(
'addressbook1',
'blabla.vcf'));
133 '/addressbooks/admin/addressbook1/blabla.vcf' 141 FN:Firstname LastName
142 N:LastName;FirstName;;
156 $this->assertNotNull(
160 $expectedVCard = <<<VCF
164 FN:Firstname LastName\r
165 N:LastName;FirstName;;;\r
171 'uri' =>
'blabla.vcf',
172 'carddata' => $expectedVCard,
173 'size' => strlen($expectedVCard),
174 'etag' =>
'"' . md5($expectedVCard) .
'"',
177 $this->assertEquals($expected, $this->cardBackend->getCard(
'addressbook1',
'blabla.vcf'));
194 '/addressbooks/admin/addressbook1/blabla.vcf',
196 'Prefer' =>
'handling=strict',
205 FN:Firstname LastName
206 N:LastName;FirstName;;
219 '/addressbooks/admin/addressbook1/blabla.vcf' 224 FN:Firstname LastName
225 N:LastName;FirstName;;;
232 $foo = $this->cardBackend->getCard(
'addressbook1',
'blabla.vcf');
234 strpos($foo[
'carddata'],
'UID') !==
false,
243 '/addressbooks/admin/addressbook1/blabla.vcf' 245 $request->setBody(
'[ "vcard" , [ [ "VERSION", {}, "text", "4.0"], [ "UID" , {}, "text", "foo" ], [ "FN", {}, "text", "FirstName LastName"] ] ]');
249 $this->assertEquals(201,
$response->status,
'Incorrect status returned! Full response body: ' .
$response->body);
251 $foo = $this->cardBackend->getCard(
'addressbook1',
'blabla.vcf');
252 $this->assertEquals(
"BEGIN:VCARD\r\nVERSION:4.0\r\nUID:foo\r\nFN:FirstName LastName\r\nEND:VCARD\r\n", $foo[
'carddata']);
259 'REQUEST_METHOD' =>
'PUT',
260 'REQUEST_URI' =>
'/addressbooks/admin/addressbook1/blabla.vcf',
262 $request->setBody(
"BEGIN:VCALENDAR\r\nEND:VCALENDAR\r\n");
266 $this->assertEquals(415,
$response->status,
'Incorrect status returned! Full response body: ' .
$response->body);
272 $this->cardBackend->createCard(
'addressbook1',
'blabla.vcf',
'foo');
275 '/addressbooks/admin/addressbook1/blabla.vcf' 284 $this->cardBackend->createCard(
'addressbook1',
'blabla.vcf',
'foo');
287 '/addressbooks/admin/addressbook1/blabla.vcf' 290 $body =
"BEGIN:VCARD\r\nVERSION:4.0\r\nUID:foo\r\nFN:FirstName LastName\r\nEND:VCARD\r\n";
296 'uri' =>
'blabla.vcf',
298 'size' => strlen($body),
299 'etag' =>
'"' . md5($body) .
'"',
302 $this->assertEquals($expected, $this->cardBackend->getCard(
'addressbook1',
'blabla.vcf'));
foreach($paths as $path) $request
The Request class represents a single HTTP request.
testCreateVCardStrictFail()
This test creates an intentionally broken vCard that vobject is able to automatically repair...
request(HTTP\Request $request, $expectedStatus=null)
testCreateVCardAutoFix()
This test creates an intentionally broken vCard that vobject is able to automatically repair...
testCreateFileVCalendar()
static createFromServerArray(array $serverArray)
This static method will create a new Request object, based on a PHP $_SERVER array.
testUpdateFileParsableBody()