diff --git a/tests/framework/validators/CFileValidatorTest.php b/tests/framework/validators/CFileValidatorTest.php index 197feb3a1..518761899 100644 --- a/tests/framework/validators/CFileValidatorTest.php +++ b/tests/framework/validators/CFileValidatorTest.php @@ -35,4 +35,14 @@ class CFileValidatorTest extends CTestCase $fileValidator=new CFileValidator(); $this->assertEquals($assertion, $fileValidator->sizeToBytes($sizeString)); } + + public function testValidate() + { + $model = new ValidatorTestModel(__CLASS__); + + $uploadedFile = new CUploadedFile('test.txt', __FILE__, 'text/plain', 40, UPLOAD_ERR_OK); + $model->uploaded_file = $uploadedFile; + + $this->assertTrue($model->validate(), 'Valid file validation failed!'); + } } diff --git a/tests/framework/validators/ValidatorTestModel.php b/tests/framework/validators/ValidatorTestModel.php index db5c613f9..7ee92bc7b 100644 --- a/tests/framework/validators/ValidatorTestModel.php +++ b/tests/framework/validators/ValidatorTestModel.php @@ -14,6 +14,8 @@ class ValidatorTestModel extends CFormModel public $username; public $address; + public $uploaded_file; + public function rules() { return array( @@ -35,6 +37,8 @@ class ValidatorTestModel extends CFormModel array('string1', 'in', 'allowEmpty' => false, 'range' => array(0,1,7,13), 'on' => 'CRangeValidatorTest'), array('string2', 'in', 'allowEmpty' => false, 'range' => array('',1,7,13), 'on' => 'CRangeValidatorTest'), + + array('uploaded_file', 'file', 'on' => 'CFileValidatorTest'), ); } }