Skip to content

Commit

Permalink
Merge pull request #11 from iamsalnikov/set-access-token-test
Browse files Browse the repository at this point in the history
Tests for \LinkedIn\Client::setAccessToken() method
  • Loading branch information
zoonman authored Oct 31, 2017
2 parents 3883d92 + 9cc7ebf commit a681806
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions tests/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,57 @@ public function testGetLoginUrl()
$actual = $this->client->getLoginUrl();
$this->assertNotEmpty($actual);
}

/**
* Make sure that method LinkedIn\Client::setAccessToken() works correctly
*
* @param $token
* @param AccessToken|null $expectedToken
* @param \Exception|null $expectedException
*
* @dataProvider getSetAccessTokenTestTable
*/
public function testSetAccessToken($token, $expectedToken, $expectedException)
{
$client = new Client();

if ($expectedException !== null) {
$this->setExpectedException(get_class($expectedException), $expectedException->getMessage());
}

$client->setAccessToken($token);

if ($expectedToken !== null) {
$this->assertEquals($expectedToken->getToken(), $client->getAccessToken()->getToken());
}
}

public function getSetAccessTokenTestTable()
{
return [
[
'token' => null,
'expectedToken' => null,
'expectedException' => new \InvalidArgumentException('$accessToken must be instance of \LinkedIn\AccessToken class'),
],

[
'token' => 'test token',
'expectedToken' => new AccessToken('test token'),
'expectedException' => null,
],

[
'token' => new AccessToken('hello world'),
'expectedToken' => new AccessToken('hello world'),
'expectedException' => null,
],

[
'token' => new \StdClass(),
'expectedToken' => null,
'expectedException' => new \InvalidArgumentException('$accessToken must be instance of \LinkedIn\AccessToken class'),
],
];
}
}

0 comments on commit a681806

Please sign in to comment.