Skip to content

Commit

Permalink
Fixed curl mock in jackalope unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Vincent Jousse committed Sep 18, 2010
1 parent 589a19d commit 8f41604
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/jackalope/transport/DavexClient.php
Expand Up @@ -412,11 +412,11 @@ protected function getDomFromBackend($type, $uri, $body='', $depth=0) {
protected function getJsonFromBackend($type, $uri, $body='', $depth=0) {
//OPTIMIZE: re-use connection. JACK-7
$this->prepareRequest($type, $uri, $body, $depth);

$jsonstring = $this->getRawFromBackend();
$json = json_decode($jsonstring);
if (! is_object($json)) {
$status = $this->curl->getinfo();
$status = $status['http_code'];
$status = $this->curl->getinfo(CURLINFO_HTTP_CODE);
if (404 === $status) {
throw new PHPCR_ItemNotFoundException('Path not found: ' . $uri);
} elseif (500 <= $status) {
Expand All @@ -433,7 +433,7 @@ protected function getJsonFromBackend($type, $uri, $body='', $depth=0) {
</D:error>
*/

throw new PHPCR_RepositoryException("Not a valid json object. '$jsonstring' ('$type' '$uri')");
throw new PHPCR_RepositoryException("Not a valid json object. '$status' '$jsonstring' ('$type' '$uri')");
}
}
//TODO: are there error responses in json format? if so, handle them
Expand Down
3 changes: 2 additions & 1 deletion tests/transport/DavexClient.php
Expand Up @@ -261,7 +261,8 @@ public function testGetJsonFromBackendItemNotFound() {
$t->curl = $this->getCurlFixture('fixtures/empty.xml');
$t->curl->expects($this->any())
->method('getinfo')
->will($this->returnValue(array('http_code' => 404)));
->with(CURLINFO_HTTP_CODE)
->will($this->returnValue(404));
$t->expects($this->once())
->method('prepareRequest')
->with('POST', 'hulla', '', 0);
Expand Down

0 comments on commit 8f41604

Please sign in to comment.