public function testFailedUploadIsNotEmpty() { $mockFailed = $this->getMock('HTML_QuickForm2_Element_InputFile', array('getValue')); $mockFailed->expects($this->once())->method('getValue')->will($this->returnValue(array('name' => 'badfile.php', 'type' => '', 'tmp_name' => '', 'error' => UPLOAD_ERR_FORM_SIZE, 'size' => 0))); $rule = new HTML_QuickForm2_Rule_Empty($mockFailed, 'an error'); $this->assertFalse($rule->validate()); $this->assertEquals('an error', $mockFailed->getError()); }
public function testValidateArray() { $mockElEmpty = $this->getMock('HTML_QuickForm2_Element', array('getType', 'getRawValue', 'setValue', '__toString')); $mockElEmpty->expects($this->once())->method('getRawValue')->will($this->returnValue(array())); $rule = new HTML_QuickForm2_Rule_Empty($mockElEmpty, 'an error'); $this->assertTrue($rule->validate()); $mockElNonEmpty = $this->getMock('HTML_QuickForm2_Element', array('getType', 'getRawValue', 'setValue', '__toString')); $mockElNonEmpty->expects($this->once())->method('getRawValue')->will($this->returnValue(array('foo', 'bar'))); $rule = new HTML_QuickForm2_Rule_Empty($mockElNonEmpty, 'an error'); $this->assertFalse($rule->validate()); }