我有以下上传表单模型
class TestUploadForm extends CFormModel
{
public $test;
public function rules()
{
return array(
array(test, 'file', 'types' => 'zip, rar'),
);
}
我的问题是,我该如何对此进行单元测试?我试过类似的东西:
public $testFile = 'fixtures/files/yii-1.1.0-validator-cheatsheet.pdf';
public function testValidators()
{
$testUpload = new TestUploadForm;
$testUpload->test = $this->testFile ;
assertTrue($testUpload ->validate());
$errors= $testUpload ->errors;
assertEmpty($errors);
}
但是,这一直告诉我该字段尚未填写。如何正确地对扩展规则进行单元测试?