示例#1
0
 public function testVarcharField()
 {
     $this->markTestIncomplete('Failed on travis, not on my laptop');
     $field = new field\Field();
     $this->assertEquals('abc', $field->clean('abc'));
     $params = array('required' => true, 'max_length' => 15, 'min_length' => 3, 'widget_attrs' => array('maxlength' => 15, 'size' => 10));
     $field = new field\Varchar($params);
     $wrong_values = array(array('', 'required'), array('ab', 0), array('1234567890123456', 0));
     // through validators
     foreach ($wrong_values as $v) {
         try {
             $nv = $field->clean($v[0]);
         } catch (Invalid $e) {
             $this->assertEquals($v[1], $e->getCode());
             continue;
         }
         $this->fail(sprintf('This value should be wrong: %s', $v));
     }
     $this->assertEquals('abc', $field->clean('abc'));
 }