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

DealerTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testCreateObject() 0 4 1
A testPlay() 0 17 2
1
<?php
2
3
namespace App\Tests\Game\BlackJack;
4
5
use App\Cards\Card;
6
use App\Game\BlackJack\Dealer;
7
use PHPUnit\Framework\TestCase;
8
9
/**
10
 * Test cases for class Dealer.
11
 */
12
class DealerTest 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
        $dealer = new Dealer();
25
        $this->assertInstanceOf(Dealer::class, $dealer);
26
    }
27
28
    /**
29
     * testPlay
30
     *
31
     * Test the Play function
32
     *
33
     * @return void
34
     */
35
    public function testPlay(): void
36
    {
37
        $dealer = new Dealer();
38
39
        $card = new Card('2', 'Spades');
40
41
        $dealer->addCard($card);
42
        $dealer->addCard($card);
43
44
        while (true === $dealer->Play()) {
45
            $handValue = $dealer->getHandValue();
46
            $this->assertLessThan(17, $handValue);
47
            $dealer->addCard($card);
48
        }
49
50
        $handValue = $dealer->getHandValue();
51
        $this->assertGreaterThan(16, $handValue);
52
    }
53
}
54