From e62cbb7109a1ffc54f66251b1eb0adb6c26f1e56 Mon Sep 17 00:00:00 2001 From: Johnson Page Date: Sun, 9 Mar 2014 10:18:18 +1100 Subject: [PATCH 1/3] Change guzzle version constraint to 3.* Guzzle will be moving the backwards-incompatible Guzzle 4 to dev-master soon, so we'll constrain this to 3.* to prevent issues in the future. --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 48e21cd..06ea71e 100644 --- a/composer.json +++ b/composer.json @@ -13,7 +13,7 @@ ], "require": { "php": ">=5.3.0", - "guzzle/guzzle": "*" + "guzzle/guzzle": "3.*" }, "require-dev": { "phpunit/phpunit": "3.7.*" From 6043b2ae0e535c591d2fe0f0d54324378ac7bcbc Mon Sep 17 00:00:00 2001 From: Johnson Page Date: Sun, 9 Mar 2014 10:21:43 +1100 Subject: [PATCH 2/3] Add failing test for Pockpack::send --- tests/PockpackTest.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tests/PockpackTest.php b/tests/PockpackTest.php index 79d3639..612219e 100644 --- a/tests/PockpackTest.php +++ b/tests/PockpackTest.php @@ -12,6 +12,26 @@ public function setUp() $this->pockpack = new Duellsy\Pockpack\Pockpack('fake_consumer_key', 'fake_access_token'); } + public function testSending() + { + $response = new Response(200); + $response->setBody(json_encode(array( + 'action_results' => array(true), + 'status' => 1, + ))); + $this->setPocketResponse($response); + + $pockpack_q = new Duellsy\Pockpack\PockpackQueue(); + $pockpack_q->add(array( + 'url' => 'http://www.example.com' + )); + + $response = $this->pockpack->send($pockpack_q); + $this->assertEquals(1, $response->status); + $this->assertCount(1, $response->action_results); + $this->assertTrue($response->action_results[0]); + } + public function testRetrieving() { $response = new Response(200); From 5413d8eab65dd254e47db2e4e523a15172fb2683 Mon Sep 17 00:00:00 2001 From: Johnson Page Date: Sun, 9 Mar 2014 10:32:21 +1100 Subject: [PATCH 3/3] Set request details in query string. Guzzle doesn't support setBody on GET requests. Instead we'll send the details in the query string, as specified in the [Pocket API docs](http://getpocket.com/developer/docs/v3/modify). --- src/Duellsy/Pockpack/Pockpack.php | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/Duellsy/Pockpack/Pockpack.php b/src/Duellsy/Pockpack/Pockpack.php index 9ca0519..33864a1 100644 --- a/src/Duellsy/Pockpack/Pockpack.php +++ b/src/Duellsy/Pockpack/Pockpack.php @@ -39,17 +39,14 @@ public function send(PockpackQueue $queue = null) throw new NoPockpackQueueException(); } - $actions = json_encode($queue->getActions()); - $actions = urlencode($actions); - $params = array( - 'actions' => $actions, + 'actions' => json_encode($queue->getActions()), 'consumer_key' => $this->consumer_key, 'access_token' => $this->access_token ); $request = $this->getClient()->get('/v3/send'); - $request->setBody(json_encode($params)); + $request->getQuery()->merge($params); $response = $request->send();