HtmlSpec::it_is_initializable()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace spec\MeadSteve\DiceApi\Renderer;
4
5
use MeadSteve\DiceApi\Dice;
6
use MeadSteve\DiceApi\Renderer\UnrenderableDiceException;
7
use PhpSpec\ObjectBehavior;
8
use Prophecy\Argument;
9
10
class HtmlSpec extends ObjectBehavior
11
{
12
    function let()
13
    {
14
        $this->beConstructedWith("URL");
15
    }
16
17
    function it_is_initializable()
18
    {
19
        $this->shouldHaveType(\MeadSteve\DiceApi\Renderer\Html::class);
20
    }
21
22 View Code Duplication
    function it_returns_image_html_for_a_single_d6(Dice $dice)
0 ignored issues
show
Duplication introduced by bachmac
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
23
    {
24
        $dice->roll()->willReturn(2);
25
        $dice->name()->willReturn("d6");
26
27
        $this->renderDice([$dice])->shouldReturn('<img src="URL/images/poorly-drawn/d6/2.png" />');
28
    }
29
30 View Code Duplication
    function it_returns_image_html_for_a_single_d20(Dice $dice)
0 ignored issues
show
Duplication introduced by bachmac
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
31
    {
32
        $dice->roll()->willReturn(14);
33
        $dice->name()->willReturn("d20");
34
35
        $this->renderDice([$dice])->shouldReturn('<img src="URL/images/poorly-drawn/d20/14.png" />');
36
    }
37
38 View Code Duplication
    function it_returns_many_images_for_many_d6(Dice $diceOne, Dice $diceTwo)
0 ignored issues
show
Duplication introduced by bachmac
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
39
    {
40
        $diceOne->roll()->willReturn(2);
41
        $diceOne->name()->willReturn("d6");
42
43
44
        $diceTwo->roll()->willReturn(5);
45
        $diceTwo->name()->willReturn("d6");
46
47
        $this->renderDice([$diceOne, $diceTwo])->shouldReturn('<img src="URL/images/poorly-drawn/d6/2.png" /><img src="URL/images/poorly-drawn/d6/5.png" />');
48
    }
49
50 View Code Duplication
    function it_returns_many_images_for_many_d20(Dice $diceOne, Dice $diceTwo)
0 ignored issues
show
Duplication introduced by bachmac
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
51
    {
52
        $diceOne->roll()->willReturn(7);
53
        $diceOne->name()->willReturn("d20");
54
55
56
        $diceTwo->roll()->willReturn(12);
57
        $diceTwo->name()->willReturn("d20");
58
59
        $this->renderDice([$diceOne, $diceTwo])->shouldReturn('<img src="URL/images/poorly-drawn/d20/7.png" /><img src="URL/images/poorly-drawn/d20/12.png" />');
60
    }
61
62 View Code Duplication
    function it_returns_many_images_for_d6_and_d20(Dice $diceOne, Dice $diceTwo)
0 ignored issues
show
Duplication introduced by bachmac
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
63
    {
64
        $diceOne->roll()->willReturn(3);
65
        $diceOne->name()->willReturn("d6");
66
67
        $diceTwo->roll()->willReturn(11);
68
        $diceTwo->name()->willReturn("d20");
69
70
        $this->renderDice([$diceOne, $diceTwo])->shouldReturn('<img src="URL/images/poorly-drawn/d6/3.png" /><img src="URL/images/poorly-drawn/d20/11.png" />');
71
    }
72
73
    function it_throws_an_exception_if_it_tries_to_render_a_non_d6_or_non_d20(Dice $wrongSizedDice)
74
    {
75
        $wrongSizedDice->roll()->willReturn(3);
76
        $wrongSizedDice->name()->willReturn("d5");
77
78
        $this->shouldThrow(UnrenderableDiceException::class)->duringRenderDice([$wrongSizedDice]);
79
    }
80
}
81