@@ 54-72 (lines=19) @@ | ||
51 | ); |
|
52 | } |
|
53 | ||
54 | function it_processes_and_validates_an_item(Step $step, ValidatorInterface $validator, Constraint $constraint, ConstraintViolationListInterface $list) |
|
55 | { |
|
56 | $next = function() {}; |
|
57 | $item = ['foo' => true]; |
|
58 | $step->process($item, $next)->shouldNotBeCalled(); |
|
59 | $list->count()->willReturn(1); |
|
60 | $validator->validate($item, Argument::type('Symfony\Component\Validator\Constraints\Collection'))->willReturn($list); |
|
61 | ||
62 | $this->add('foo', $constraint)->shouldReturn($this); |
|
63 | ||
64 | $this->process( |
|
65 | $item, |
|
66 | function($item) use ($step, $next) { |
|
67 | return $step->process($item, $next); |
|
68 | } |
|
69 | ); |
|
70 | ||
71 | $this->getViolations()->shouldReturn([1 => $list]); |
|
72 | } |
|
73 | ||
74 | function it_throws_an_exception_when_option_is_not_supported(Step $step, ValidatorInterface $validator, Constraint $constraint, ConstraintViolation $violation) |
|
75 | { |
|
@@ 91-112 (lines=22) @@ | ||
88 | ); |
|
89 | } |
|
90 | ||
91 | function it_throws_an_exception_during_process_when_validation_fails( |
|
92 | Step $step, |
|
93 | ValidatorInterface $validator, |
|
94 | Constraint $constraint, |
|
95 | ConstraintViolation $violation |
|
96 | ) { |
|
97 | $next = function() {}; |
|
98 | $item = ['foo' => true]; |
|
99 | $step->process($item, $next)->shouldNotBeCalled(); |
|
100 | $list = new ConstraintViolationList([$violation->getWrappedObject()]); |
|
101 | $validator->validate($item, Argument::type('Symfony\Component\Validator\Constraints\Collection'))->willReturn($list); |
|
102 | ||
103 | $this->add('foo', $constraint)->shouldReturn($this); |
|
104 | $this->throwExceptions(); |
|
105 | ||
106 | $this->shouldThrow('Port\Exception\ValidationException')->duringProcess( |
|
107 | $item, |
|
108 | function($item) use ($step, $next) { |
|
109 | return $step->process($item, $next); |
|
110 | } |
|
111 | ); |
|
112 | } |
|
113 | ||
114 | function it_validates_an_item_from_metadata( |
|
115 | ValidatorInterface $validator, |