Skip to content

Commit

Permalink
Merge pull request #28 from RiteKit/refresh-token
Browse files Browse the repository at this point in the history
Fix getRefreshToken()
  • Loading branch information
kbariotis committed Aug 2, 2017
2 parents de35dd3 + 867e58f commit c2326b3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
4 changes: 3 additions & 1 deletion src/feedly/Feedly.php
Expand Up @@ -117,6 +117,7 @@ public function getTokens($clientId, $clientSecret, $authCode, $redirectUrl)

public function getRefreshAccessToken($client_id, $client_secret, $refresh_token)
{
$this->client = new HTTPClient();

$this->client->setCustomHeader(array(
"Authorization: Basic " . base64_encode($client_id . ":" .
Expand All @@ -125,8 +126,9 @@ public function getRefreshAccessToken($client_id, $client_secret, $refresh_token

$this->client->setPostParams(array(
"refresh_token" => urlencode($refresh_token),
"client_id" => urlencode($client_id),
"client_secret" => urlencode($client_secret),
"grant_type" => $refresh_token
"grant_type" => "refresh_token"
)
, false);

Expand Down
19 changes: 10 additions & 9 deletions tests/FeedlyAPIWrapperTest.php
Expand Up @@ -5,6 +5,7 @@
use feedly\Feedly;
use feedly\Mode\SandBoxMode;
use feedly\AccessTokenStorage\AccessTokenBlackholeStorage;
use feedly\Response\AccessTokenResponse;

class FeedlyAPIWrapperTest extends PHPUnit_Framework_TestCase
{
Expand All @@ -25,36 +26,36 @@ public function testValidReturnedUrlForAuthorization()
public function testGetTokens()
{

$response = array(
$response = new AccessTokenResponse([
'access_token' => 'dsa5da76d76sa5d67sad567a',
'expires_in' => '1234',
'refresh_token' => 'absa5da76d76sa5d87sad597a'
);
]);

$feedly = $this->getMock('Feedly', array('getToken'));
$feedly = $this->getMock('Feedly', array('getTokens'));

$feedly->expects($this->any())
->method('getToken')
->method('getTokens')
->will($this->returnValue($response));

$this->assertEquals($response, $feedly->getToken());
$this->assertEquals($response, $feedly->getTokens('client_id', 'client_secret', 'authCode', 'redirectUrl'));
}

public function testGetRefreshAccessToken()
{

$response = array(
$response = new AccessTokenResponse([
'access_token' => 'dsa5da76d76sa5d67sad567a',
'expires_in' => '1234',
);
'expires_in' => '1234'
]);

$feedly = $this->getMock('Feedly', array('getRefreshAccessToken'));

$feedly->expects($this->any())
->method('getRefreshAccessToken')
->will($this->returnValue($response));

$this->assertEquals($response, $feedly->getRefreshAccessToken());
$this->assertEquals($response, $feedly->getRefreshAccessToken('client_id', 'secret_id', 'refresh_token'));
}

}

0 comments on commit c2326b3

Please sign in to comment.