Skip to content

Commit

Permalink
Merge pull request #28 from jwpage/fix_pockpack_send
Browse files Browse the repository at this point in the history
Fix pockpack send
  • Loading branch information
duellsy committed Mar 9, 2014
2 parents 5c763f0 + 5413d8e commit e50bcf7
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 6 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
],
"require": {
"php": ">=5.3.0",
"guzzle/guzzle": "*"
"guzzle/guzzle": "3.*"
},
"require-dev": {
"phpunit/phpunit": "3.7.*"
Expand Down
7 changes: 2 additions & 5 deletions src/Duellsy/Pockpack/Pockpack.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
20 changes: 20 additions & 0 deletions tests/PockpackTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit e50bcf7

Please sign in to comment.