CardHandTest   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 12
c 1
b 0
f 1
dl 0
loc 36
rs 10
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 8 2
A testGetCardCount() 0 4 1
A testCreateCardHand() 0 5 1
1
<?php
2
3
namespace App\Card;
4
5
use PHPUnit\Framework\TestCase;
6
7
/**
8
 * Test cases for class CardHand.
9
 */
10
class CardHandTest extends TestCase
11
{
12
    private CardHand $hand;
13
14
    /**
15
     * Setup method creates the input values needed to test CardHand-methods.
16
     */
17
    protected function setUp(): void
18
    {
19
        $values = [["S", "J"], ["D", "A"], ["C", "Q"], ["H", "K"]];
20
        $this->hand = new CardHand();
21
22
        foreach ($values as $value) {
23
            $card = new Card($value);
24
            $this->hand->add($card);
25
        }
26
    }
27
28
    /**
29
     * Construct object without input arguments and verify that the object has the expected
30
     * properties.
31
     */
32
    public function testCreateCardHand(): void
33
    {
34
        $values = [["S", "J"], ["D", "A"], ["C", "Q"], ["H", "K"]];
35
        $res = $this->hand->getValues();
36
        $this->assertEquals($values, $res);
37
    }
38
39
    /**
40
     * Test number of cards, compared with cards used in setup-section.
41
     */
42
    public function testGetCardCount(): void
43
    {
44
        $res = $this->hand->getNumberCards();
45
        $this->assertEquals(4, $res);
46
    }
47
}
48