CardTest::testGetFunctions()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 7
nc 1
nop 0
dl 0
loc 12
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace App\Tests\Cards;
4
5
use PHPUnit\Framework\TestCase;
6
use App\Cards\Card;
7
8
/**
9
 * Test cases for class Card.
10
 */
11
class CardTest extends TestCase
12
{
13
    /**
14
     * testCreateObject
15
     *
16
     * Construct object and verify that the object has the expected
17
     * properties, use no arguments.
18
     *
19
     * @return void
20
     */
21
    public function testCreateObject(): void
22
    {
23
        $card = new Card(Card::NO_RANK, Card::NO_SUIT);
24
        $this->assertInstanceOf(Card::class, $card);
25
26
        $res = $card->getString();
27
        $this->assertNotEmpty($res);
28
    }
29
30
31
    /**
32
     * testGetFunctions
33
     *
34
     * Test the get functions of the class
35
     *
36
     * @return void
37
     */
38
    public function testGetFunctions(): void
39
    {
40
        $card = new Card("a", "Heart");
41
42
        $rank = $card->getRank();
43
        $this->assertEquals("A", $rank);
44
45
        $suit = $card->getSuit();
46
        $this->assertEquals('♥', $suit);
47
48
        $value = $card->getValue();
49
        $this->assertEquals(1, $value);
50
    }
51
52
    /**
53
     * testSetFunctions
54
     *
55
     * Test the set functions of the class
56
     *
57
     * @return void
58
     */
59
    public function testSetFunctions(): void
60
    {
61
        $card = new Card("a", "Heart");
62
63
        $card->setRank('k');
64
        $rank = $card->getRank();
65
        $this->assertEquals("K", $rank);
66
        $value = $card->getValue();
67
        $this->assertEquals(13, $value);
68
69
        $card->setSuit('Wrong input');
70
        $suit = $card->getSuit();
71
        $this->assertEquals(Card::NO_SUIT, $suit);
72
        $value = $card->getValue();
73
        $this->assertEquals(0, $value);
74
    }
75
}
76