Game21ControllerTest   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 54
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 19
c 1
b 0
f 0
dl 0
loc 54
rs 10
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A testLandingPage() 0 7 1
A testPlayGame() 0 5 1
A testDocumentationPage() 0 7 1
A testRestartGame() 0 13 1
1
<?php
2
3
namespace App\Tests\Controller;
4
5
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
6
use App\Card\Game21;
7
use App\Controller\Game21Controller;
8
9
/**
10
 * @group controller
11
 */
12
class Game21ControllerTest extends WebTestCase
13
{
14
    /**
15
     * Test the landing page for the game 21.
16
     */
17
    public function testLandingPage(): void
18
    {
19
        $client = static::createClient();
20
        $client->request('GET', '/game');
21
22
        $this->assertResponseIsSuccessful();
23
        $this->assertSelectorTextContains('h1', 'Game 21');
24
    }
25
26
    /**
27
     * Test the doc page loads.
28
     */
29
    public function testDocumentationPage(): void
30
    {
31
        $client = static::createClient();
32
        $client->request('GET', '/game/doc');
33
34
        $this->assertResponseIsSuccessful();
35
        $this->assertSelectorTextContains('h3', 'Klassbeskrivningar');
36
    }
37
38
    /**
39
     * Test that the main play page loads successfully
40
     * and contains a form for gameplay actions.
41
     */
42
    public function testPlayGame(): void
43
    {
44
        $client = static::createClient();
45
        $client->request('GET', '/game/play');
46
        $this->assertSelectorExists('form');
47
    }
48
49
    /**
50
     * Test restarting the game via the /game/restart route
51
     * redirects back to the play page and loads successfully.
52
     */
53
    public function testRestartGame(): void
54
    {
55
        $client = static::createClient();
56
57
        $client->request('GET', '/game/play');
58
        $this->assertResponseIsSuccessful();
59
60
        $client->request('GET', '/game/restart');
61
62
        $this->assertResponseRedirects('/game/play');
63
64
        $client->followRedirect();
65
        $this->assertResponseIsSuccessful();
66
    }
67
}
68