Conditions | 2 |
Paths | 2 |
Total Lines | 27 |
Code Lines | 18 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
17 | public function testErrors() |
||
18 | { |
||
19 | $data = [ |
||
20 | 'FirstName' => '', |
||
21 | 'LastName' => '', |
||
22 | 'DateOfBirth' => '2017-09-20' |
||
23 | ]; |
||
24 | |||
25 | $validator = new TestInputValidator(); |
||
26 | $validator->setMessages([ |
||
27 | 'notBlank' => 'Please enter a value' |
||
28 | ]); |
||
29 | |||
30 | try { |
||
31 | $validator->valid($data); |
||
32 | } catch (InputValidationException $e) { |
||
33 | $errors = $e->getMessages(); |
||
34 | } |
||
35 | |||
36 | $this->assertEquals(4, count($errors), 'There should be four errors'); |
||
37 | $this->assertNotEmpty($errors['FirstName'], 'FirstName should be in validation errors'); |
||
38 | $this->assertEquals( |
||
39 | $errors['FirstName'][0], |
||
40 | 'Please enter a value', |
||
41 | 'Not blank message should have been updated' |
||
42 | ); |
||
43 | } |
||
44 | } |
||
65 |