From d0619385b8852529e3a078513a192f7f021d39b3 Mon Sep 17 00:00:00 2001 From: Andrew Millington Date: Tue, 31 Oct 2017 21:00:14 +0000 Subject: [PATCH] Add a basic test to ensure we throw an exception when no scope is given --- tests/Grant/AbstractGrantTest.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/Grant/AbstractGrantTest.php b/tests/Grant/AbstractGrantTest.php index 542c78dc..11139bfb 100644 --- a/tests/Grant/AbstractGrantTest.php +++ b/tests/Grant/AbstractGrantTest.php @@ -459,6 +459,21 @@ class AbstractGrantTest extends \PHPUnit_Framework_TestCase $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() { $grantMock = $this->getMockForAbstractClass(AbstractGrant::class);