Esempio n. 1
0
 /**
  * @param GrantTypeInterface $grantTypeInterface
  *
  * @return TokenInterface
  */
 private function retrieveToken(GrantTypeInterface $grantTypeInterface)
 {
     $token = $grantTypeInterface->getToken();
     if (false === $token instanceof TokenInterface) {
         throw TokenGrantTypeException::notInstanceOfToken($grantTypeInterface, $token);
     }
     return $token;
 }
 /**
  * @depends testClass
  */
 public function testNotInstanceOfToken()
 {
     /** @var \PHPUnit_Framework_MockObject_MockObject|GrantTypeInterface $grantType */
     $grantType = $this->getMockBuilder(GrantTypeInterface::class)->getMock();
     $grantType->expects($this->once())->method('getGrantType')->willReturn('test_grant_type');
     $exception = TokenGrantTypeException::notInstanceOfToken($grantType, 'test');
     $this->assertInstanceOf(TokenGrantTypeException::class, $exception);
     $this->assertEquals('GrantType test_grant_type should return TokenInterface instance. "string" given', $exception->getMessage());
 }