示例#1
0
 /**
  * Tests \OAuth2\Server\Server->verifyAccessToken() with different scopes
  *
  * @dataProvider generateScopes
  * @group scopes
  */
 public function testVerifyAccessTokenCheckScope($scopeRequired, $token, $expectedToPass)
 {
     // Set up the mock storage to say this token does not exist
     $mockStorage = $this->getMock('\\OAuth2\\Storage\\StorageInterface');
     $mockStorage->expects($this->once())->method('getAccessToken')->will($this->returnValue($token));
     $this->fixture = new \OAuth2\Server\Server($mockStorage);
     // When valid, we just want any sort of token
     if ($expectedToPass) {
         $actual = $this->fixture->verifyAccessToken($this->tokenId, $scopeRequired);
         $this->assertNotEmpty($actual, "verifyAccessToken() was expected to PASS, but it failed");
         $this->assertInternalType('array', $actual);
     } else {
         $this->setExpectedException('OAuth2\\Exception\\AuthenticateException');
         $this->fixture->verifyAccessToken($this->tokenId, $scopeRequired);
     }
 }