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

TransformerChainSpec   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 5
lcom 0
cbo 3
dl 0
loc 30
rs 10
c 1
b 0
f 1

5 Methods

Rating   Name   Duplication   Size   Complexity  
A let() 0 4 1
A it_is_initializable() 0 4 1
A it_implements_transformer_interface() 0 4 1
A it_transforms_using_all_registered_transformers() 0 7 1
A it_throws_exception_if_trying_to_register_non_transformer() 0 4 1
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