From 8f41604014820fe61e4143aba9a027db5e263419 Mon Sep 17 00:00:00 2001 From: Vincent Jousse Date: Sat, 18 Sep 2010 17:02:55 +0200 Subject: [PATCH] Fixed curl mock in jackalope unit tests --- src/jackalope/transport/DavexClient.php | 6 +++--- tests/transport/DavexClient.php | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/jackalope/transport/DavexClient.php b/src/jackalope/transport/DavexClient.php index b62f14b1..e8f35337 100644 --- a/src/jackalope/transport/DavexClient.php +++ b/src/jackalope/transport/DavexClient.php @@ -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) { @@ -433,7 +433,7 @@ protected function getJsonFromBackend($type, $uri, $body='', $depth=0) { */ - 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 diff --git a/tests/transport/DavexClient.php b/tests/transport/DavexClient.php index 90769560..80ebf83e 100644 --- a/tests/transport/DavexClient.php +++ b/tests/transport/DavexClient.php @@ -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);