1 | <?php |
||
11 | class ValidatorStepTest extends \PHPUnit_Framework_TestCase |
||
12 | { |
||
13 | protected function setUp() |
||
19 | |||
20 | public function testProcess() |
||
21 | { |
||
22 | $data = ['title' => null]; |
||
23 | |||
24 | $this->filter->add('title', $constraint = new Constraints\NotNull()); |
||
25 | |||
26 | $list = new ConstraintViolationList(); |
||
27 | $list->add($this->buildConstraintViolation()); |
||
28 | |||
29 | $this->validator->expects($this->once()) |
||
30 | ->method('validate') |
||
31 | ->willReturn($list); |
||
32 | |||
33 | $this->assertFalse($this->filter->process($data)); |
||
34 | |||
35 | $this->assertEquals([1 => $list], $this->filter->getViolations()); |
||
36 | } |
||
37 | |||
38 | /** |
||
39 | * @expectedException Ddeboer\DataImport\Exception\ValidationException |
||
40 | */ |
||
41 | public function testProcessWithExceptions() |
||
42 | { |
||
43 | $data = ['title' => null]; |
||
44 | |||
45 | $this->filter->add('title', $constraint = new Constraints\NotNull()); |
||
46 | $this->filter->throwExceptions(); |
||
47 | |||
48 | $list = new ConstraintViolationList(); |
||
49 | $list->add($this->buildConstraintViolation()); |
||
50 | |||
51 | $this->validator->expects($this->once()) |
||
52 | ->method('validate') |
||
53 | ->willReturn($list); |
||
54 | |||
55 | $this->assertFalse($this->filter->process($data)); |
||
56 | } |
||
57 | |||
58 | public function testPriority() |
||
62 | |||
63 | private function buildConstraintViolation() |
||
69 | } |
||
70 |