Conditions | 1 |
Paths | 1 |
Total Lines | 18 |
Code Lines | 12 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
17 | public function testJsonLuckyNumber(): void |
||
18 | { |
||
19 | $client = static::createClient(); |
||
20 | $client->request('GET', '/api/lucky/number'); |
||
21 | |||
22 | $this->assertResponseIsSuccessful(); |
||
23 | $this->assertResponseFormatSame('json'); |
||
24 | |||
25 | $content = $client->getResponse()->getContent(); |
||
26 | $this->assertIsString($content, 'Response content is not a string.'); |
||
27 | |||
28 | $data = json_decode($content, true); |
||
29 | $this->assertIsArray($data, 'Decoded JSON is not an array.'); |
||
30 | |||
31 | $this->assertArrayHasKey('lucky-number', $data); |
||
32 | $this->assertArrayHasKey('lucky-message', $data); |
||
33 | $this->assertIsInt($data['lucky-number']); |
||
34 | $this->assertSame('Hi there!', $data['lucky-message']); |
||
35 | } |
||
37 |