Completed
Push — master ( 552cf0...ff5a3f )
by Саша
02:06
created

TransformerChainSpec::it_is_initializable()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
dl 0
loc 4
rs 10
c 1
b 0
f 1
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace spec\Extraload\Transformer;
4
5
use PhpSpec\ObjectBehavior;
6
use Extraload\Transformer\TransformerInterface;
7
8
class TransformerChainSpec extends ObjectBehavior
9
{
10
    function let(TransformerInterface $reverseTransformer, TransformerInterface $capitalizeTransformer)
11
    {
12
        $this->beConstructedWith([$reverseTransformer, $capitalizeTransformer]);
13
    }
14
15
    function it_is_initializable()
16
    {
17
        $this->shouldHaveType('Extraload\Transformer\TransformerChain');
18
    }
19
20
    function it_implements_transformer_interface()
21
    {
22
        $this->shouldImplement('Extraload\Transformer\TransformerInterface');
23
    }
24
25
    function it_transforms_using_all_registered_transformers(TransformerInterface $reverseTransformer, TransformerInterface $capitalizeTransformer)
26
    {
27
        $reverseTransformer->transform(['foo', 'bar'])->shouldBeCalled()->willReturn(['bar', 'foo']);
28
        $capitalizeTransformer->transform(['bar', 'foo'])->shouldBeCalled()->willReturn(['Bar', 'Foo']);
29
30
        $this->transform(['foo', 'bar'])->shouldReturn(['Bar', 'Foo']);
31
    }
32
33
    function it_throws_exception_if_trying_to_register_non_transformer()
34
    {
35
        $this->shouldThrow(\InvalidArgumentException::class)->during('__construct', [['NonTransformer']]);
36
    }
37
}
38