Passed
Push — main ( 7235e9...235833 )
by Peter
04:12
created

DeckTest::testDrawAllCards()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 5
nc 2
nop 0
dl 0
loc 10
rs 10
c 1
b 0
f 0
1
<?php
2
3
namespace App\Card;
4
5
use PHPUnit\Framework\TestCase;
6
7
/**
8
 * Test cases for class Deck.
9
 */
10
class DeckTest extends TestCase
11
{
12
    /**
13
     * Construct object and verify that the deck is created with correct number of cards.
14
     */
15
    public function testCreateDeck()
16
    {
17
        $deck = new Deck();
18
        $this->assertInstanceOf(Deck::class, $deck);
19
        $this->assertEquals(52, $deck->remainingCardsCount());
20
    }
21
22
    /**
23
     * Test DrawCard.
24
     */
25
    public function testDrawCard()
26
    {
27
        $deck = new Deck();
28
        $card = $deck->drawCard();
29
30
        $this->assertInstanceOf(CardGraphic::class, $card);
31
        $this->assertEquals(51, $deck->remainingCardsCount());
32
    }
33
34
    /**
35
     * Test GetCards.
36
     */
37
    public function testGetCards()
38
    {
39
        $deck = new Deck();
40
        $cards = $deck->getCards();
41
        
42
        // Check 4 suits
43
        $this->assertCount(4, $cards); 
44
        
45
        foreach ($cards as $suit => $cardsInSuit) {
46
            $this->assertCount(13, $cardsInSuit);
47
        }
48
    }
49
50
    /**
51
     * Test draw all cards.
52
     */
53
    public function testDrawAllCards()
54
    {
55
        $deck = new Deck();
56
        
57
        for ($i = 0; $i < 52; $i++) {
58
            $card = $deck->drawCard();
0 ignored issues
show
Unused Code introduced by
The assignment to $card is dead and can be removed.
Loading history...
59
        }
60
        
61
        $this->assertEquals(0, $deck->remainingCardsCount());
62
        $this->assertNull($deck->drawCard());
63
    }
64
}
65