Esempio n. 1
0
 public function testInputValidation()
 {
     $f = new Form\Element\Text();
     $f->setRequired(true);
     $this->assertFalse($f->validate());
     $f->setRequired(false);
     $f->setPattern('input\\-value');
     $this->assertFalse($f->validate());
     $f->setValue('input-value');
     $this->assertTrue($f->validate());
     $f->setValidator(function ($item) {
         if ($item != 'input-value') {
             throw new \Exception('Invalid input value.');
         }
     });
     $this->assertTrue($f->validate());
     $f->setValue('fail');
     $f->setPattern(null);
     $this->assertFalse($f->validate());
 }