1 | <?php |
||
34 | final class ClientRegistrationEndpointTest extends TestCase |
||
35 | { |
||
36 | /** |
||
37 | * @test |
||
38 | */ |
||
39 | public function theClientRegistrationEndpointCanReceiveRegistrationRequests() |
||
40 | { |
||
41 | $request = $this->buildRequest([]); |
||
42 | $request->getMethod()->willReturn('POST'); |
||
43 | $request->getAttribute('initial_access_token')->willReturn(null); |
||
44 | |||
45 | $response = $this->getClientRegistrationEndpoint()->process($request->reveal()); |
||
46 | |||
47 | self::assertEquals(201, $response->getStatusCode()); |
||
48 | $response->getBody()->rewind(); |
||
49 | self::assertEquals('{"client_id":"CLIENT_ID"}', $response->getBody()->getContents()); |
||
50 | } |
||
51 | |||
52 | /** |
||
53 | * @var null|ClientRegistrationEndpoint |
||
54 | */ |
||
55 | private $clientRegistrationEndpoint = null; |
||
56 | |||
57 | /** |
||
58 | * @return ClientRegistrationEndpoint |
||
59 | */ |
||
60 | private function getClientRegistrationEndpoint(): ClientRegistrationEndpoint |
||
61 | { |
||
62 | if (null === $this->clientRegistrationEndpoint) { |
||
63 | $client = Client::createEmpty(); |
||
64 | $client = $client->create( |
||
65 | ClientId::create('CLIENT_ID'), |
||
66 | DataBag::create([]), |
||
67 | null |
||
68 | ); |
||
69 | $clientIdGenerator = $this->prophesize(ClientIdGenerator::class); |
||
70 | $clientIdGenerator->createClientId()->willReturn( |
||
71 | ClientId::create('CLIENT_ID') |
||
72 | ); |
||
73 | |||
74 | $clientRepository = $this->prophesize(ClientRepository::class); |
||
75 | $clientRepository->find(Argument::type(ClientId::class))->willReturn($client); |
||
76 | $clientRepository->save(Argument::type(Client::class))->will(function (array $args) { |
||
|
|||
77 | }); |
||
78 | |||
79 | $this->clientRegistrationEndpoint = new ClientRegistrationEndpoint( |
||
80 | $clientIdGenerator->reveal(), |
||
81 | $clientRepository->reveal(), |
||
82 | $this->getResponseFactory(), |
||
83 | new RuleManager() |
||
84 | ); |
||
85 | } |
||
86 | |||
87 | return $this->clientRegistrationEndpoint; |
||
88 | } |
||
89 | |||
90 | /** |
||
91 | * @var ResponseFactory|null |
||
92 | */ |
||
93 | private $responseFactory = null; |
||
94 | |||
95 | /** |
||
96 | * @return ResponseFactory |
||
97 | */ |
||
98 | private function getResponseFactory(): ResponseFactory |
||
106 | |||
107 | private function buildRequest(array $data): ObjectProphecy |
||
108 | { |
||
119 | } |
||
120 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.