QuoteControllerJsonTest   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
c 1
b 0
f 0
dl 0
loc 23
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A testJsonQuote() 0 16 1
1
<?php
2
3
namespace App\Tests\Controller;
4
5
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
6
7
/**
8
 * @group controller
9
 */
10
class QuoteControllerJsonTest extends WebTestCase
11
{
12
    /**
13
     * Test the /api/quote route returns a successful JSON response
14
     *
15
     * @return void
16
     */
17
    public function testJsonQuote(): void
18
    {
19
        $client = static::createClient();
20
        $client->request('GET', '/api/quote');
21
22
        // Assert that the response was successful
23
        $this->assertResponseIsSuccessful();
24
25
        $content = $client->getResponse()->getContent();
26
        $this->assertIsString($content, 'Response content is not a string.');
27
28
        // Decode the JSON response
29
        $data = json_decode($content, true);
30
        $this->assertIsArray($data, 'Decoded JSON is not an array.');
31
32
        $this->assertArrayHasKey('quote', $data);
33
    }
34
}
35