public function add(IClient $client) { $this->clients[$client->getId()] = $client; }
function it_throws_exception_if_grant_request_authorization_code_was_issued_to_another_client(IRequest $request, IAuthorizationCodeStorage $authorizationCodeStorage, IAuthorizationCode $authorizationCode, IClientAuthenticator $clientAuthenticator, IClient $client1, IClient $client2) { $request->request('code')->willReturn('a')->shouldBeCalled(); $clientAuthenticator->authenticate($request)->willReturn($client1)->shouldBeCalled(); $client1->isAllowedToUse($this)->willReturn(true)->shouldBeCalled(); $authorizationCodeStorage->get('a')->willReturn($authorizationCode)->shouldBeCalled(); $authorizationCode->getExpiresAt()->willReturn(time() + 100)->shouldBeCalled(); $client1->getId()->willReturn('b')->shouldBeCalled(); $client2->getId()->willReturn('c')->shouldBeCalled(); $authorizationCode->getClient()->willReturn($client2)->shouldBeCalled(); $this->shouldThrow(new InvalidGrantException('Authorization code is invalid.'))->during('grant', [$request]); }