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

CardGraphicTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 62
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 23
dl 0
loc 62
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testGetFunctions() 0 12 1
A testSetFunctions() 0 15 1
A testCreateObject() 0 7 1
1
<?php
2
3
namespace App\Tests\Cards;
4
5
use PHPUnit\Framework\TestCase;
6
use App\Cards\CardGraphic;
7
8
/**
9
 * Test cases for class CardGraphic.
10
 */
11
class CardGraphicTest 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
        $cardGraphic = new CardGraphic(CardGraphic::NO_RANK, CardGraphic::NO_SUIT);
24
        $this->assertInstanceOf(CardGraphic::class, $cardGraphic);
25
26
        $res = $cardGraphic->getString();
27
        $this->assertNotEmpty($res);
28
    }
29
30
    /**
31
     * testGetFunctions
32
     *
33
     * Test the get functions of the class
34
     *
35
     * @return void
36
     */
37
    public function testGetFunctions(): void
38
    {
39
        $cardGraphic = new CardGraphic("a", "Heart");
40
41
        $rank = $cardGraphic->getRank();
42
        $this->assertEquals("A", $rank);
43
44
        $suit = $cardGraphic->getSuit();
45
        $this->assertEquals('♥', $suit);
46
47
        $res = $cardGraphic->getString();
48
        $this->assertEquals('🂱', $res);
49
    }
50
51
    /**
52
     * testSetFunctions
53
     *
54
     * Test the set functions of the class
55
     *
56
     * @return void
57
     */
58
    public function testSetFunctions(): void
59
    {
60
        $cardGraphic = new CardGraphic("a", "Heart");
61
62
        $cardGraphic->setRank('k');
63
        $rank = $cardGraphic->getRank();
64
        $this->assertEquals("K", $rank);
65
        $res = $cardGraphic->getString();
66
        $this->assertEquals('🂾', $res);
67
68
        $cardGraphic->setSuit('Wrong input');
69
        $suit = $cardGraphic->getSuit();
70
        $this->assertEquals(CardGraphic::NO_SUIT, $suit);
71
        $res = $cardGraphic->getString();
72
        $this->assertEquals(CardGraphic::BLANK_CARD, $res);
73
    }
74
}
75