BetManagerTest::testGetPot()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 4
nc 1
nop 0
dl 0
loc 6
c 1
b 0
f 1
cc 1
rs 10
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