Пример #1
0
 /**
  * Idea here is that you can indicate that if validation for a particular input fails, we should not
  * attempt any further validation of any other inputs.
  */
 public function testInputBreakOnFailureFlagIsHonoredWhenValidating()
 {
     $filter = new InputFilter();
     $store = new stdClass();
     $foo = new Input();
     $foo->getValidatorChain()->addValidator(new Validator\Callback(function ($value, $context) use($store) {
         $store->value = $value;
         $store->context = $context;
         return true;
     }));
     $bar = new Input();
     $bar->getValidatorChain()->addValidator(new Validator\Digits());
     $bar->setBreakOnFailure(true);
     $filter->add($bar, 'bar')->add($foo, 'foo');
     $data = array('bar' => 'bar', 'foo' => 'foo');
     $filter->setData($data);
     $this->assertFalse($filter->isValid());
     $this->assertObjectNotHasAttribute('value', $store);
     $this->assertObjectNotHasAttribute('context', $store);
 }
Пример #2
0
 public function testBreakOnFailureFlagIsMutable()
 {
     $input = new Input('foo');
     $input->setBreakOnFailure(true);
     $this->assertTrue($input->breakOnFailure());
 }
Пример #3
0
 public function testBreakOnFailureFlagIsMutable()
 {
     $this->input->setBreakOnFailure(true);
     $this->assertTrue($this->input->breakOnFailure());
 }