|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace App\Model; |
|
4
|
|
|
|
|
5
|
|
|
use PHPUnit\Framework\TestCase; |
|
6
|
|
|
use Exception; |
|
7
|
|
|
|
|
8
|
|
|
/** |
|
9
|
|
|
* Test cases for class BetManager. |
|
10
|
|
|
*/ |
|
11
|
|
|
class BetManagerTest extends TestCase |
|
12
|
|
|
{ |
|
13
|
|
|
/** |
|
14
|
|
|
* Construct object and verify that the object is of the expected |
|
15
|
|
|
* type. |
|
16
|
|
|
*/ |
|
17
|
|
|
public function testCreateBetManagerWithNoArguments(): void |
|
18
|
|
|
{ |
|
19
|
|
|
$betManager = new BetManager(); |
|
20
|
|
|
$this->assertInstanceOf("\App\Model\BetManager", $betManager); |
|
21
|
|
|
} |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* Assert that an initiated Bet Manager has no pot. |
|
25
|
|
|
*/ |
|
26
|
|
|
|
|
27
|
|
|
public function testGetPot(): void |
|
28
|
|
|
{ |
|
29
|
|
|
$betManager = new BetManager(); |
|
30
|
|
|
$res = $betManager->getPot(); |
|
31
|
|
|
$exp = null; |
|
32
|
|
|
$this->assertEquals($exp, $res); |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* Assert that an initiated Bet Manager has no pot. |
|
37
|
|
|
*/ |
|
38
|
|
|
|
|
39
|
|
|
public function testHasPot(): void |
|
40
|
|
|
{ |
|
41
|
|
|
$betManager = new BetManager(); |
|
42
|
|
|
$res = $betManager->hasPot(); |
|
43
|
|
|
$this->assertFalse($res); |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* Assert that a payout of an empty pot doesn't impact player balance. |
|
48
|
|
|
*/ |
|
49
|
|
|
|
|
50
|
|
|
public function testPayoutEmptyPot(): void |
|
51
|
|
|
{ |
|
52
|
|
|
$betManager = new BetManager(); |
|
53
|
|
|
$player = new HumanPlayer("testPlayer", 0); |
|
54
|
|
|
$betManager->payout(new HumanPlayer()); |
|
55
|
|
|
$res = $player->getBalance(); |
|
56
|
|
|
$exp = 0; |
|
57
|
|
|
$this->assertEquals($exp, $res); |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
/** |
|
61
|
|
|
* Assert that adding a pot to a non empty pot throws an exception. |
|
62
|
|
|
* |
|
63
|
|
|
* @throws Exception |
|
64
|
|
|
*/ |
|
65
|
|
|
|
|
66
|
|
|
public function testSetPot(): void |
|
67
|
|
|
{ |
|
68
|
|
|
$betManager = new BetManager(); |
|
69
|
|
|
$betManager->setPot(100, [new HumanPlayer()]); |
|
70
|
|
|
$this->expectException(Exception::class); |
|
71
|
|
|
$betManager->setPot(100, [new HumanPlayer()]); |
|
72
|
|
|
} |
|
73
|
|
|
} |
|
74
|
|
|
|