Completed
Push — master ( bd4c23...b341c0 )
by Filipe
10:29
created

FlashMessagesSpec::let()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
namespace spec\Slick\Mvc\Service;
4
5
use PhpSpec\ObjectBehavior;
6
use Slick\Http\SessionDriverInterface;
7
use Slick\Mvc\Service\FlashMessages;
8
9
class FlashMessagesSpec extends ObjectBehavior
10
{
11
    function let(SessionDriverInterface $sessionDriver)
12
    {
13
        $this->beConstructedWith($sessionDriver);
14
    }
15
16
    function it_is_initializable()
17
    {
18
        $this->shouldHaveType(FlashMessages::class);
19
    }
20
21 View Code Duplication
    function it_registers_a_message_with_provided_type(
0 ignored issues
show
Duplication introduced by
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...
22
        SessionDriverInterface $sessionDriver
23
    )
24
    {
25
        $this->set(FlashMessages::TYPE_INFO, 'Test!')
26
            ->shouldBe($this->getWrappedObject());
27
        $sessionDriver->set('_messages_', [FlashMessages::TYPE_INFO => ['Test!']])
28
            ->shouldHaveBeenCalled();
29
    }
30
31 View Code Duplication
    function it_registers_an_info_message_when_an_unknown_type_is_given(
0 ignored issues
show
Duplication introduced by
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...
32
        SessionDriverInterface $sessionDriver
33
    )
34
    {
35
        $sessionDriver->set('_messages_', [FlashMessages::TYPE_INFO => ['Test!', 'Test!']])
36
            ->shouldBeCalled();
37
        $this->set('other', 'Test!')
38
            ->shouldBe($this->getWrappedObject());
39
    }
40
41
    function it_flushes_all_messages_when_they_are_retrieved(
42
        SessionDriverInterface $sessionDriver
43
    )
44
    {
45
        $messages = [1=>['test']];
46
        $sessionDriver->get('_messages_', [])->shouldBeCalled()
47
            ->willReturn($messages);
48
49
        $sessionDriver->erase('_messages_')->shouldBeCalled();
50
        $this->get()->shouldBe($messages);
51
    }
52
}
53