Add a basic test to ensure we throw an exception when no scope is given

This commit is contained in:
Andrew Millington 2017-10-31 21:00:14 +00:00
parent 3828f87b19
commit d0619385b8

View File

@ -459,6 +459,21 @@ class AbstractGrantTest extends \PHPUnit_Framework_TestCase
$grantMock->validateScopes('basic '); $grantMock->validateScopes('basic ');
} }
/**
* @expectedException \League\OAuth2\Server\Exception\OAuthServerException
* @expectedExceptionCode 11
*/
public function testValidateScopesMissingScope()
{
$scopeRepositoryMock = $this->getMockBuilder(ScopeRepositoryInterface::class)->getMock();
$scopeRepositoryMock->method('getScopeEntityByIdentifier')->willReturn(null);
$grantMock = $this->getMockForAbstractClass(AbstractGrant::class);
$grantMock->setScopeRepository($scopeRepositoryMock);
$grantMock->validateScopes('');
}
public function testGenerateUniqueIdentifier() public function testGenerateUniqueIdentifier()
{ {
$grantMock = $this->getMockForAbstractClass(AbstractGrant::class); $grantMock = $this->getMockForAbstractClass(AbstractGrant::class);