Passed
Push — main ( f3cfb1...17781b )
by Emil
04:34
created

PlayerTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 59
Duplicated Lines 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
eloc 18
dl 0
loc 59
rs 10
c 1
b 1
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testBooleans() 0 16 1
A testCreateObject() 0 4 1
A testGet() 0 11 1
1
<?php
2
3
namespace App\Tests\Game\BlackJack;
4
5
use App\Cards\Card;
6
use App\Game\BlackJack\Player;
7
use PHPUnit\Framework\TestCase;
8
9
/**
10
 * Test cases for class Player.
11
 */
12
class PlayerTest extends TestCase
13
{
14
    /**
15
     * testCreateObject
16
     *
17
     * Construct object and verify that the object has the expected
18
     * properties, use no arguments.
19
     *
20
     * @return void
21
     */
22
    public function testCreateObject(): void
23
    {
24
        $player = new Player();
25
        $this->assertInstanceOf(Player::class, $player);
26
    }
27
28
    /**
29
     * testBooleans
30
     *
31
     * Test the boolean values
32
     *
33
     * @return void
34
     */
35
    public function testBooleans(): void
36
    {
37
        $player = new Player();
38
39
        $card = new Card('K', 'Spades');
40
41
        $player->addCard($card);
42
        $player->addCard($card);
43
44
        $bust = $player->isBust();
45
        $this->assertFalse($bust);
46
47
        $player->addCard($card);
48
49
        $bust = $player->isBust();
50
        $this->assertTrue($bust);
51
    }
52
53
    /**
54
     * testGet
55
     *
56
     * Test the get function
57
     *
58
     * @return void
59
     */
60
    public function testGet(): void
61
    {
62
        $player = new Player();
63
64
        $card = new Card('K', 'Spades');
65
66
        $player->addCard($card);
67
        $player->addCard($card);
68
69
        $handValue = $player->getHandValue();
70
        $this->assertEquals(20, $handValue);
71
    }
72
}
73