@@ 46-64 (lines=19) @@ | ||
43 | ); |
|
44 | } |
|
45 | ||
46 | function it_throws_a_mapping_exception_when_no_property_is_found(Step $step, PropertyAccessorInterface $propertyAccessor) |
|
47 | { |
|
48 | $next = function() {}; |
|
49 | // We cannot mock behavior by reference |
|
50 | $item = ['foo' => true, 'bar' => true]; |
|
51 | $item2 = ['bar' => true]; |
|
52 | $step->process($item2, $next)->shouldNotBeCalled(); |
|
53 | $propertyAccessor->getValue($item, 'foo')->willThrow('Symfony\Component\PropertyAccess\Exception\NoSuchPropertyException'); |
|
54 | $propertyAccessor->setValue($item, 'bar', true)->shouldNotBeCalled(); |
|
55 | ||
56 | $this->map('foo', 'bar')->shouldReturn($this); |
|
57 | ||
58 | $this->shouldThrow('Port\Exception\MappingException')->duringProcess( |
|
59 | $item, |
|
60 | function($item) use ($step, $next) { |
|
61 | return $step->process($item, $next); |
|
62 | } |
|
63 | ); |
|
64 | } |
|
65 | ||
66 | function it_throws_a_mapping_exception_when_the_type_is_unexpected(Step $step, PropertyAccessorInterface $propertyAccessor) |
|
67 | { |
|
@@ 66-84 (lines=19) @@ | ||
63 | ); |
|
64 | } |
|
65 | ||
66 | function it_throws_a_mapping_exception_when_the_type_is_unexpected(Step $step, PropertyAccessorInterface $propertyAccessor) |
|
67 | { |
|
68 | $next = function() {}; |
|
69 | // We cannot mock behavior by reference |
|
70 | $item = ['foo' => true, 'bar' => true]; |
|
71 | $item2 = ['bar' => true]; |
|
72 | $step->process($item2, $next)->shouldNotBeCalled(); |
|
73 | $propertyAccessor->getValue($item, 'foo')->willThrow('Symfony\Component\PropertyAccess\Exception\UnexpectedTypeException'); |
|
74 | $propertyAccessor->setValue($item, 'bar', true)->shouldNotBeCalled(); |
|
75 | ||
76 | $this->map('foo', 'bar')->shouldReturn($this); |
|
77 | ||
78 | $this->shouldThrow('Port\Exception\MappingException')->duringProcess( |
|
79 | $item, |
|
80 | function($item) use ($step, $next) { |
|
81 | return $step->process($item, $next); |
|
82 | } |
|
83 | ); |
|
84 | } |
|
85 | } |
|
86 |