public function testGettersAndSetters() { $owner = $this->getMock(TokenOwnerInterface::class); $client = new Client(); $expiresAt = new DateTime(); $authorizationCode = new AuthorizationCode(); $authorizationCode->setToken('token'); $authorizationCode->setScopes(['scope1', 'scope2']); $authorizationCode->setClient($client); $authorizationCode->setExpiresAt($expiresAt); $authorizationCode->setOwner($owner); $authorizationCode->setRedirectUri('http://www.example.com'); $this->assertEquals('token', $authorizationCode->getToken()); $this->assertCount(2, $authorizationCode->getScopes()); $this->assertTrue($authorizationCode->matchScopes('scope1')); $this->assertFalse($authorizationCode->matchScopes('scope3')); $this->assertSame($client, $authorizationCode->getClient()); $this->assertEquals($expiresAt, $authorizationCode->getExpiresAt()); $this->assertSame($owner, $authorizationCode->getOwner()); $this->assertEquals('http://www.example.com', $authorizationCode->getRedirectUri()); }
/** * @return AccessToken */ private function getValidAuthorizationCode() { $authorizationCode = new AuthorizationCode(); $authorizationCode->setToken('azerty_auth'); $authorizationCode->setScopes('read'); $validDate = new DateTime(); $validDate->add(new DateInterval('PT1H')); $authorizationCode->setExpiresAt($validDate); return $authorizationCode; }