DiceHandTest   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A testAddStubbedDices() 0 17 1
1
<?php
2
3
namespace App\Dice;
4
5
use PHPUnit\Framework\TestCase;
6
7
/**
8
 * Test cases for class DiceHand.
9
 */
10
class DiceHandTest extends TestCase
11
{
12
    /**
13
     * Stub the dices to assure the value can be asserted.
14
     */
15
    public function testAddStubbedDices()
16
    {
17
        // Create a stub for the Dice class.
18
        $stub = $this->createMock(Dice::class);
19
20
        // Configure the stub.
21
        $stub->method('roll')
22
            ->willReturn(6);
23
        $stub->method('getValue')
24
            ->willReturn(6);
25
26
        $dicehand = new DiceHand();
27
        $dicehand->add(clone $stub);
28
        $dicehand->add(clone $stub);
29
        $dicehand->roll();
30
        $res = $dicehand->sum();
31
        $this->assertEquals(12, $res);
32
    }
33
}