| Conditions | 2 |
| Paths | 1 |
| Total Lines | 33 |
| Code Lines | 20 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 13 | public function testLen() { |
||
| 14 | $lengthValidator = new CallBackValidator(function ($value) { |
||
| 15 | return strlen($value) > 3 and strlen($value) < 10; |
||
| 16 | }); |
||
| 17 | |||
| 18 | $form = new Form(); |
||
| 19 | $form->input('login') |
||
| 20 | ->addValidator($lengthValidator); |
||
| 21 | |||
| 22 | $form->setData([ |
||
| 23 | $form->getUid() => 1, |
||
| 24 | 'login' => 'testLogin', |
||
| 25 | ]); |
||
| 26 | |||
| 27 | $this->assertTrue($form->isValid()); |
||
| 28 | $this->assertFalse($lengthValidator->hasErrors()); |
||
| 29 | |||
| 30 | |||
| 31 | $form->setData([ |
||
| 32 | $form->getUid() => 1, |
||
| 33 | 'login' => 'tes', |
||
| 34 | ]); |
||
| 35 | |||
| 36 | $this->assertFalse($form->isValid()); |
||
| 37 | $this->assertTrue($lengthValidator->hasErrors()); |
||
| 38 | |||
| 39 | $form->setData([ |
||
| 40 | $form->getUid() => 1, |
||
| 41 | 'login' => 'testtesttesttesttesttesttesttest', |
||
| 42 | ]); |
||
| 43 | |||
| 44 | $this->assertFalse($form->isValid()); |
||
| 45 | } |
||
| 46 | |||
| 85 |