示例#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'));
 }
示例#2
0
文件: field.php 项目: photon/photon
 public function __construct($params = array())
 {
     $this->error_messages['invalid'] = __('No file was submitted. Check the encoding type on the form.');
     $this->error_messages['required'] = __('No file was submitted.');
     $this->error_messages['empty'] = __('The submitted file is empty.');
     $this->error_messages['big'] = __('The submitted file is too big, limit is %1$d octets.');
     $this->error_messages['max_length'] = __('Ensure this filename has at most %1$d characters (it has %2$d).');
     parent::__construct($params);
 }