| 1 | <?php |
||
| 10 | */ |
||
| 11 | class InTest extends \PHPUnit_Framework_TestCase { |
||
| 12 | |||
| 13 | |||
| 14 | public function testIn() { |
||
| 15 | $inValidator = new \Fiv\Form\Validator\In(); |
||
| 16 | $inValidator->setValues(['a', 'b', 'c']); |
||
| 17 | |||
| 18 | $form = new Form(); |
||
| 19 | $form->input('inputName') |
||
| 20 | ->addValidator($inValidator); |
||
| 21 | |||
| 22 | $form->handle(new FormData('post', [ |
||
| 23 | $form->getUid() => 1, |
||
| 24 | 'inputName' => 'a', |
||
| 25 | ])); |
||
| 26 | $this->assertTrue($form->isValid()); |
||
| 27 | |||
| 28 | $form->handle(new FormData('post', [ |
||
| 29 | $form->getUid() => 1, |
||
| 30 | 'inputName' => 'd', |
||
| 31 | ])); |
||
| 32 | $this->assertFalse($form->isValid()); |
||
| 33 | } |
||
| 34 | |||
| 35 | } |
||
| 36 |