Test Failed
Push — main ( 49ffe2...63a966 )
by Vedrana
07:24 queued 02:15
created

DiceHandTest::testAddAndGetNumberDices()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 4
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 7
rs 10
1
<?php
2
3
namespace App\Tests\Dice;
4
5
use PHPUnit\Framework\TestCase;
6
7
use App\Dice\Dice;
8
use App\Dice\DiceHand;
9
10
/**
11
 * Test cases for class DiceHand.
12
 */
13
class DiceHandTest extends TestCase
14
{
15
     /**
16
     * Test adding dice to the hand and counting them.
17
     */
18
    public function testAddAndGetNumberDices(): void
19
    {
20
        $hand = new DiceHand();
21
        $hand->add(new Dice());
22
        $hand->add(new Dice());
23
24
        $this->assertEquals(2, $hand->getNumberDices());
25
    }
26
27
    /**
28
     * Test dice roll and get values.
29
     */
30
    public function testRollAndGetValues(): void
31
    {
32
        $hand = new DiceHand();
33
        $die1 = new Dice();
34
        $die2 = new Dice();
35
36
        $hand->add($die1);
37
        $hand->add($die2);
38
39
        $hand->roll();
40
        $values = $hand->getValues();
41
42
        $this->assertCount(2, $values);
43
        foreach ($values as $value) {
44
            $this->assertGreaterThanOrEqual(1, $value);
45
            $this->assertLessThanOrEqual(6, $value);
46
        }
47
    }
48
49
    /**
50
     * Test getString.
51
     */
52
    public function testGetString(): void
53
    {
54
        $hand = new DiceHand();
55
        $die1 = new Dice();
56
        $die2 = new Dice();
57
58
        $hand->add($die1);
59
        $hand->add($die2);
60
61
        $hand->roll();
62
        $strings = $hand->getString();
63
64
        $this->assertCount(2, $strings);
65
        foreach ($strings as $str) {
66
            $this->assertNotEmpty($str);
67
        }
68
    }
69
}
70