DiceTest::testCreateDice()   A
last analyzed

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\Dice;
4
5
use PHPUnit\Framework\TestCase;
6
7
/**
8
 * Test cases for class Dice.
9
 */
10
class DiceTest extends TestCase
11
{
12
    /**
13
     * Construct object and verify that the object has the expected
14
     * properties, use no arguments.
15
     */
16
    public function testCreateDice()
17
    {
18
        $die = new Dice();
19
        $this->assertInstanceOf("\App\Dice\Dice", $die);
20
21
        $res = $die->getAsString();
22
        $this->assertNotEmpty($res);
23
    }
24
25
    /**
26
     * Create a mocked object that always returns 6.
27
     */
28
    public function testStubRollDiceLastRoll()
29
    {
30
        // Create a stub for the Dice class.
31
        $stub = $this->createMock(Dice::class);
32
33
        // Configure the stub.
34
        $stub->method('roll')
35
            ->willReturn(6);
36
37
        $res = $stub->roll();
38
        $exp = 6;
39
        $this->assertEquals($exp, $res);
40
    }
41
}