예제 #1
0
 /**
  * @test
  */
 function closure_with_error()
 {
     /**
      * @param ValueTO $v
      */
     $filter = function ($v) {
         $val = $v->getValue();
         $val .= ':bad';
         $v->setValue($val);
         $v->setError(__METHOD__);
         $v->setMessage('Closure with Error');
     };
     $found = $this->verify->is('test', $this->factory->rules()->withType('text')->custom($filter));
     $this->assertEquals(false, $found);
     /** @var ValueTO $valTo */
     $valTo = $this->verify->apply('test', $this->factory->rules()->withType('text')->custom($filter));
     $this->assertTrue($valTo->fails());
     $this->assertTrue($valTo->getBreak());
     $this->assertEquals('test:bad', $valTo->getValue());
     $this->assertEquals('Closure with Error', $valTo->message());
 }
예제 #2
0
 /**
  * @test
  */
 function datetime_filter_removes_value_for_invalid_datetime_string()
 {
     $bad = '1234567890123456789012345678901234567890';
     $value = $this->validate->is($bad, array('datetime' => true));
     $this->assertEquals('', (string) $value);
 }