'REPORT', 'REQUEST_URI' => '/addressbooks/user1/book1', 'HTTP_DEPTH' => '1', )); $request->setBody( ' ' ); $response = new Sabre_HTTP_ResponseMock(); $this->server->httpRequest = $request; $this->server->httpResponse = $response; $this->server->exec(); $this->assertEquals('HTTP/1.1 207 Multi-Status', $response->status, 'Incorrect status code. Full response body:' . $response->body); // using the client for parsing $client = new Sabre_DAV_Client(array('baseUri'=>'/')); $result = $client->parseMultiStatus($response->body); $this->assertEquals(array( '/addressbooks/user1/book1/card1' => array( 200 => array( '{DAV:}getetag' => '"' . md5("BEGIN:VCARD\nVERSION:3.0\nUID:12345\nEND:VCARD") . '"', ), ), '/addressbooks/user1/book1/card2' => array( 200 => array( '{DAV:}getetag' => '"' . md5("BEGIN:VCARD\nVERSION:3.0\nUID:45678\nEND:VCARD") . '"', ), ) ), $result); } function testQueryDepth0() { $request = new Sabre_HTTP_Request(array( 'REQUEST_METHOD' => 'REPORT', 'REQUEST_URI' => '/addressbooks/user1/book1/card1', 'HTTP_DEPTH' => '0', )); $request->setBody( ' ' ); $response = new Sabre_HTTP_ResponseMock(); $this->server->httpRequest = $request; $this->server->httpResponse = $response; $this->server->exec(); $this->assertEquals('HTTP/1.1 207 Multi-Status', $response->status, 'Incorrect status code. Full response body:' . $response->body); // using the client for parsing $client = new Sabre_DAV_Client(array('baseUri'=>'/')); $result = $client->parseMultiStatus($response->body); $this->assertEquals(array( '/addressbooks/user1/book1/card1' => array( 200 => array( '{DAV:}getetag' => '"' . md5("BEGIN:VCARD\nVERSION:3.0\nUID:12345\nEND:VCARD") . '"', ), ), ), $result); } function testQueryNoMatch() { $request = new Sabre_HTTP_Request(array( 'REQUEST_METHOD' => 'REPORT', 'REQUEST_URI' => '/addressbooks/user1/book1', 'HTTP_DEPTH' => '1', )); $request->setBody( ' ' ); $response = new Sabre_HTTP_ResponseMock(); $this->server->httpRequest = $request; $this->server->httpResponse = $response; $this->server->exec(); $this->assertEquals('HTTP/1.1 207 Multi-Status', $response->status, 'Incorrect status code. Full response body:' . $response->body); // using the client for parsing $client = new Sabre_DAV_Client(array('baseUri'=>'/')); $result = $client->parseMultiStatus($response->body); $this->assertEquals(array(), $result); } function testQueryLimit() { $request = new Sabre_HTTP_Request(array( 'REQUEST_METHOD' => 'REPORT', 'REQUEST_URI' => '/addressbooks/user1/book1', 'HTTP_DEPTH' => '1', )); $request->setBody( ' 1 ' ); $response = new Sabre_HTTP_ResponseMock(); $this->server->httpRequest = $request; $this->server->httpResponse = $response; $this->server->exec(); $this->assertEquals('HTTP/1.1 207 Multi-Status', $response->status, 'Incorrect status code. Full response body:' . $response->body); // using the client for parsing $client = new Sabre_DAV_Client(array('baseUri'=>'/')); $result = $client->parseMultiStatus($response->body); $this->assertEquals(array( '/addressbooks/user1/book1/card1' => array( 200 => array( '{DAV:}getetag' => '"' . md5("BEGIN:VCARD\nVERSION:3.0\nUID:12345\nEND:VCARD"). '"', ), ), ), $result); } }