diff --git a/test/Bitreserve/Tests/Unit/Model/UserTest.php b/test/Bitreserve/Tests/Unit/Model/UserTest.php index eb55fb7..6b0de8c 100644 --- a/test/Bitreserve/Tests/Unit/Model/UserTest.php +++ b/test/Bitreserve/Tests/Unit/Model/UserTest.php @@ -523,6 +523,54 @@ 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()); + } + + public function getCurrenciesProvider() { return array(