tôi có mô hình uploadform sauYii - Mô hình Unittesting một hình thức upload
class TestUploadForm extends CFormModel
{
public $test;
public function rules()
{
return array(
array(test, 'file', 'types' => 'zip, rar'),
);
}
Câu hỏi của tôi là, làm thế nào tôi có thể kiểm tra đơn vị này? Tôi đã thử một số nội dung như:
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);
}
Tuy nhiên, điều đó vẫn cho tôi biết trường chưa được điền đầy đủ.
+1. trường 'tài liệu' là gì? và tại sao bạn chưa đặt trường $ test? –
là trường 'tài liệu' một chuỗi? –
woeps, dán sao chép xấu. test = document. – SnIpY