From 3ebaf6e161f2ef0b92201a82dbf016307334a4a3 Mon Sep 17 00:00:00 2001 From: Michael Crumm Date: Wed, 9 Mar 2016 14:48:15 -0800 Subject: [PATCH 1/2] Fix array to string conversion in REST::sendRequest() --- src/Storage/Connection/REST.php | 4 +-- tests/Storage/Connection/RESTTest.php | 39 +++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 tests/Storage/Connection/RESTTest.php diff --git a/src/Storage/Connection/REST.php b/src/Storage/Connection/REST.php index ce3ba96ae8c9..fcb47cb58f64 100644 --- a/src/Storage/Connection/REST.php +++ b/src/Storage/Connection/REST.php @@ -240,7 +240,7 @@ private function sendRequest($resource, $method, $options) { // @todo quick POC. need to tighten this up $action = $this->service[$resource]['methods'][$method]; - $template = new UriTemplate(); + $template = new UriTemplate(self::BASE_URI); $path = []; $query = []; $body = []; @@ -260,7 +260,7 @@ private function sendRequest($resource, $method, $options) } $uri = $this->buildUri( - $template->expand($action['path'], self::BASE_URI . $path), + $template->expand($action['path'], $path), $query ); diff --git a/tests/Storage/Connection/RESTTest.php b/tests/Storage/Connection/RESTTest.php new file mode 100644 index 000000000000..018d5f0786f5 --- /dev/null +++ b/tests/Storage/Connection/RESTTest.php @@ -0,0 +1,39 @@ +getMock(ResponseInterface::class); + $response->method('getBody')->willReturn('{"name": "foo.txt"}'); + + $wrapper = $this->getMock(HttpRequestWrapper::class); + $wrapper->method('send')->willReturn($response); + + $object = (new REST($wrapper))->getObject(); + + $this->assertEquals(['name' => 'foo.txt'], $object); + } +} From b38d4402140d471991b4f47fdc4143dfab70c744 Mon Sep 17 00:00:00 2001 From: Michael Crumm Date: Wed, 9 Mar 2016 15:33:06 -0800 Subject: [PATCH 2/2] Fix ServiceDefinition path (hhvm issue) --- src/Storage/Connection/REST.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Storage/Connection/REST.php b/src/Storage/Connection/REST.php index fcb47cb58f64..26f8e99ea7fe 100644 --- a/src/Storage/Connection/REST.php +++ b/src/Storage/Connection/REST.php @@ -225,7 +225,7 @@ public function uploadObject(array $options = []) private function loadServiceDefinition() { return json_decode( - file_get_contents('ServiceDefinition/storage-v1.json', true), + file_get_contents(__DIR__ . '/ServiceDefinition/storage-v1.json', true), true ); }