/**
  * (non-PHPdoc)
  * @see lib/form/phFormDataItem::bind()
  */
 public function bind($file)
 {
     if (!$this->isValidFilePost($file)) {
         throw new phFileDataException('bound data is not a valid file', phFileDataException::INVALID_FILE_DATA);
     }
     return parent::bind($file);
 }
 public function testCompareValidator()
 {
     $password = new phFormDataItem('password');
     $confirmPassword = new phFormDataItem('confirmPassword');
     $confirmPassword->bind('password');
     $compareVal = new phCompareValidator($confirmPassword, phCompareValidator::EQUAL, array(phCompareValidator::INVALID => "The passwords are not the same"));
     $this->assertFalse($compareVal->validate('notequal', $password), 'The validator is correctly not valid');
     $messages = $this->extractErrorMessages($password->getErrors());
     $this->assertTrue(in_array('The passwords are not the same', $messages), 'error message set properly');
     $this->assertTrue($compareVal->validate('password', $password), 'The validator is correctly valid');
     $compareVal = new phCompareValidator($confirmPassword, phCompareValidator::NOT_EQUAL);
     $this->assertFalse($compareVal->validate('password', $password), 'The validator is correctly not valid');
     $this->assertTrue($compareVal->validate('notequal', $password), 'The validator is correctly valid');
     $confirmPassword->bind(5);
     $compareVal = new phCompareValidator($confirmPassword, phCompareValidator::LESS_THAN);
     $this->assertFalse($compareVal->validate(10, $password), 'The validator is correctly not valid');
     $this->assertTrue($compareVal->validate(1, $password), 'The validator is correctly valid');
     $compareVal = new phCompareValidator($confirmPassword, phCompareValidator::LESS_EQUAL);
     $this->assertFalse($compareVal->validate(10, $password), 'The validator is correctly not valid');
     $this->assertTrue($compareVal->validate(5, $password), 'The validator is correctly valid');
     $compareVal = new phCompareValidator($confirmPassword, phCompareValidator::GREATER_THAN);
     $this->assertFalse($compareVal->validate(1, $password), 'The validator is correctly not valid');
     $this->assertTrue($compareVal->validate(10, $password), 'The validator is correctly valid');
     $compareVal = new phCompareValidator($confirmPassword, phCompareValidator::GREATER_EQUAL);
     $this->assertFalse($compareVal->validate(1, $password), 'The validator is correctly not valid');
     $this->assertTrue($compareVal->validate(5, $password), 'The validator is correctly valid');
     /*
      * test scalar values can be used
      */
     $compareVal = new phCompareValidator(1, phCompareValidator::EQUAL);
     $this->assertFalse($compareVal->validate(2, $password), 'The validator is correctly not valid');
     $this->assertTrue($compareVal->validate(1, $password), 'The validator is correctly valid');
 }
 public function testFormDataItemToString()
 {
     $i = new phFormDataItem('test');
     $i->bind('hello world');
     $this->assertEquals('hello world', (string) $i, 'phFormDataItem __toString works');
     $i->bind(null);
     $this->assertEquals('', (string) $i, 'phFormDataItem __toString works with nulls');
 }
 public function bind($value)
 {
     $this->wasBound = true;
     parent::bind($value);
 }