NumericDiceFactorySpec   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 3
dl 0
loc 27
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A it_is_initializable() 0 4 1
A it_returns_a_single_d6() 0 4 1
A it_returns_multiple_dice() 0 4 1
A it_throws_an_exception_for_anything_over_a_d_9000() 0 4 1
A it_returns_a_special_singlepoint_dice_when_asked_for_a_d0() 0 4 1
1
<?php
2
3
namespace spec\MeadSteve\DiceApi\Dice\Factories;
4
5
use MeadSteve\DiceApi\Dice\BasicDice;
6
use MeadSteve\DiceApi\Dice;
7
use MeadSteve\DiceApi\Dice\Factories\NumericDiceFactory;
8
use MeadSteve\DiceApi\Dice\UncreatableDiceException;
9
use PhpSpec\ObjectBehavior;
10
use Prophecy\Argument;
11
12
class NumericDiceFactorySpec extends ObjectBehavior
13
{
14
    function it_is_initializable()
15
    {
16
        $this->shouldHaveType(NumericDiceFactory::class);
17
    }
18
19
    function it_returns_a_single_d6()
20
    {
21
        $this->buildDice("6", 1)->shouldBeLike([new BasicDice(6)]);
22
    }
23
24
    function it_returns_multiple_dice()
25
    {
26
        $this->buildDice("4", 2)->shouldBeLike([new BasicDice(4), new BasicDice(4)]);
27
    }
28
29
    function it_throws_an_exception_for_anything_over_a_d_9000()
30
    {
31
        $this->shouldThrow(UncreatableDiceException::class)->duringBuildDice("9001", 1);
32
    }
33
34
    function it_returns_a_special_singlepoint_dice_when_asked_for_a_d0()
35
    {
36
        $this->buildDice("0", 1)->shouldBeLike([new Dice\ZeropointDice()]);
37
    }
38
}
39