shouldReceive('create'); $accessTokenStorage->shouldReceive('associateScope'); $accessTokenStorage->shouldReceive('setServer'); $accessTokenStorage->shouldReceive('getScopes')->andReturn([ (new Scope($server))->setId('foo') ]); $sessionStorage = M::mock('League\OAuth2\Server\Storage\SessionInterface'); $sessionStorage->shouldReceive('getByAccessToken')->andReturn( (new Session($server)) ); $sessionStorage->shouldReceive('setServer'); $server->setAccessTokenStorage($accessTokenStorage); $server->setSessionStorage($sessionStorage); $entity = new AccessToken($server); $this->assertTrue($entity->save() instanceof AccessToken); } function testExpire() { $server = new Authorization(); $accessTokenStorage = M::mock('League\OAuth2\Server\Storage\AccessTokenInterface'); $accessTokenStorage->shouldReceive('delete'); $accessTokenStorage->shouldReceive('setServer'); $server->setAccessTokenStorage($accessTokenStorage); $entity = new AccessToken($server); $this->assertSame($entity->expire(), null); } }