Skip to content

Commit

Permalink
Add tests to User model
Browse files Browse the repository at this point in the history
  • Loading branch information
Nuno Rafael Rocha committed Jul 23, 2015
1 parent 64d4564 commit 1490bf5
Showing 1 changed file with 57 additions and 0 deletions.
57 changes: 57 additions & 0 deletions test/Bitreserve/Tests/Unit/Model/UserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,58 @@ public function shouldReturnTransactions()
}
}

/**
* @test
* @expectedException Bitreserve\Exception\AuthenticationRequiredException
* @expectedExceptionMessage Missing bearer authorization
*/
public function shouldThrowAuthenticationRequiredExceptionOnRevokeTokenWhenBearerTokenIsMissing()
{
$client = $this->getBitreserveClientMock();

$client->expects($this->once())
->method('getOption')
->with('bearer')
->will($this->returnValue(null))
;

$user = new User($client, array('username' => 'foobar'));

$user->revokeToken();
}

/**
* @test
*/
public function shouldRevokeToken()
{
$bearerToken = 'foobar';
$expectedResult = 'qux';

$client = $this->getBitreserveClientMock();

$client->expects($this->once())
->method('getOption')
->with('bearer')
->will($this->returnValue($bearerToken))
;

$client->expects($this->once())
->method('get')
->with(sprintf('/me/tokens/%s', $bearerToken))
->will($this->returnValue($expectedResult))
;

$user = new User($client, array('username' => 'foobar'));

$this->assertEquals($expectedResult, $user->revokeToken());
}

/**
* Get currencies provider.
*
* @return array
*/
public function getCurrenciesProvider()
{
return array(
Expand All @@ -532,6 +584,11 @@ public function getCurrenciesProvider()
);
}

/**
* Get model class.
*
* @return string
*/
protected function getModelClass()
{
return 'Bitreserve\Model\User';
Expand Down

0 comments on commit 1490bf5

Please sign in to comment.