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