1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace App\Controller; |
4
|
|
|
|
5
|
|
|
use App\Dice\DiceHand; |
6
|
|
|
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; |
7
|
|
|
use Symfony\Component\HttpFoundation\RequestStack; |
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* Test cases for class DiceGameController. |
11
|
|
|
*/ |
12
|
|
|
class Kmom02Test extends WebTestCase |
13
|
|
|
{ |
14
|
|
|
/** |
15
|
|
|
* Test instantiation of class |
16
|
|
|
*/ |
17
|
|
|
public function testInstantiateKmom02(): void |
18
|
|
|
{ |
19
|
|
|
$controller = new Kmom02(); |
20
|
|
|
$this->assertInstanceOf("\App\Controller\Kmom02", $controller); |
21
|
|
|
} |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* Test route /session |
25
|
|
|
*/ |
26
|
|
|
public function testControllerSession(): void |
27
|
|
|
{ |
28
|
|
|
$client = static::createClient(); |
29
|
|
|
$client->request('GET', '/session'); |
30
|
|
|
$this->assertResponseIsSuccessful(); |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* Test route /session/delete |
35
|
|
|
*/ |
36
|
|
|
public function testControllerSessionDelete(): void |
37
|
|
|
{ |
38
|
|
|
$client = static::createClient(); |
39
|
|
|
$client->request('POST', '/session/delete'); |
40
|
|
|
$this->assertResponseRedirects('/session'); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* Test route /card |
45
|
|
|
*/ |
46
|
|
|
public function testControllerCard(): void |
47
|
|
|
{ |
48
|
|
|
$client = static::createClient(); |
49
|
|
|
$client->request('GET', '/card'); |
50
|
|
|
$this->assertResponseIsSuccessful(); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* Test route /card/deck |
55
|
|
|
*/ |
56
|
|
|
public function testControllerCardDeck(): void |
57
|
|
|
{ |
58
|
|
|
$client = static::createClient(); |
59
|
|
|
|
60
|
|
|
$client->request('POST', '/card/deck', [ |
61
|
|
|
"header" => "All cards sorted", |
62
|
|
|
"cardValues" => null |
63
|
|
|
]); |
64
|
|
|
|
65
|
|
|
$this->assertResponseIsSuccessful(); |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* Test route /card/deck/shuffle |
70
|
|
|
*/ |
71
|
|
|
public function testControllerCardDeckShuffle(): void |
72
|
|
|
{ |
73
|
|
|
$client = static::createClient(); |
74
|
|
|
|
75
|
|
|
$client->request('POST', '/card/deck/shuffle', [ |
76
|
|
|
"header" => "All cards shuffled", |
77
|
|
|
"cardValues" => null |
78
|
|
|
]); |
79
|
|
|
|
80
|
|
|
$this->assertResponseIsSuccessful(); |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* Test route /card/deck/draw |
85
|
|
|
*/ |
86
|
|
|
public function testControllerCardDeckDraw(): void |
87
|
|
|
{ |
88
|
|
|
$client = static::createClient(); |
89
|
|
|
|
90
|
|
|
$client->request('POST', '/card/deck/draw', [ |
91
|
|
|
"header" => "Draw one card", |
92
|
|
|
"num_cards" => null, |
93
|
|
|
"value" => null, |
94
|
|
|
]); |
95
|
|
|
|
96
|
|
|
$this->assertResponseIsSuccessful(); |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
/** |
100
|
|
|
* Test route /card/deck/draw/{num<\d+>} |
101
|
|
|
*/ |
102
|
|
|
public function testControllerCardHand(): void |
103
|
|
|
{ |
104
|
|
|
$client = static::createClient(); |
105
|
|
|
|
106
|
|
|
$client->request('POST', '/card/deck/draw/3', [ |
107
|
|
|
"header" => "Draw multiple cards", |
108
|
|
|
"num_cards" => null, |
109
|
|
|
"values" => null, |
110
|
|
|
]); |
111
|
|
|
|
112
|
|
|
$this->assertResponseIsSuccessful(); |
113
|
|
|
} |
114
|
|
|
} |
115
|
|
|
|