1 | <?php |
||
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 |