Commit 1a3c04e0 by Mark

fixed tests

parent 42643e37
...@@ -31,8 +31,8 @@ class FakedValidationModel extends Model ...@@ -31,8 +31,8 @@ class FakedValidationModel extends Model
return [ return [
[['val_attr_a', 'val_attr_b'], 'required', 'on' => 'reqTest'], [['val_attr_a', 'val_attr_b'], 'required', 'on' => 'reqTest'],
['val_attr_c', 'integer'], ['val_attr_c', 'integer'],
['attr_images', 'file', 'maxFiles' => 3, 'types' => ['png'], 'on' => 'validateMultipleFiles'], ['attr_images', 'file', 'maxFiles' => 3, 'types' => ['png'], 'on' => 'validateMultipleFiles', 'checkTypeAgainstMime' => false],
['attr_image', 'file', 'types' => ['png'], 'on' => 'validateFile'] ['attr_image', 'file', 'types' => ['png'], 'on' => 'validateFile', 'checkTypeAgainstMime' => false]
]; ];
} }
......
...@@ -102,7 +102,9 @@ class FileValidatorTest extends TestCase ...@@ -102,7 +102,9 @@ class FileValidatorTest extends TestCase
public function testValidateAttributeMultiple() public function testValidateAttributeMultiple()
{ {
$val = new FileValidator(['maxFiles' => 2]); $val = new FileValidator([
'maxFiles' => 2,
]);
$m = FakedValidationModel::createWithAttributes(['attr_files' => 'path']); $m = FakedValidationModel::createWithAttributes(['attr_files' => 'path']);
$val->validateAttribute($m, 'attr_files'); $val->validateAttribute($m, 'attr_files');
$this->assertTrue($m->hasErrors('attr_files')); $this->assertTrue($m->hasErrors('attr_files'));
...@@ -221,7 +223,7 @@ class FileValidatorTest extends TestCase ...@@ -221,7 +223,7 @@ class FileValidatorTest extends TestCase
continue; continue;
} }
$name = isset($param['name']) ? $param['name'] : $rndString(); $name = isset($param['name']) ? $param['name'] : $rndString();
$tempName = \Yii::getAlias('@yiiunit/runtime/validators/file/tmp') . $name; $tempName = \Yii::getAlias('@yiiunit/runtime/validators/file/tmp/') . $name;
if (is_readable($tempName)) { if (is_readable($tempName)) {
$size = filesize($tempName); $size = filesize($tempName);
} else { } else {
...@@ -303,7 +305,10 @@ class FileValidatorTest extends TestCase ...@@ -303,7 +305,10 @@ class FileValidatorTest extends TestCase
public function testValidateAttributeType() public function testValidateAttributeType()
{ {
$val = new FileValidator(['types' => 'jpeg, jpg']); $val = new FileValidator([
'types' => 'jpeg, jpg',
'checkTypeAgainstMime' => false,
]);
$m = FakedValidationModel::createWithAttributes( $m = FakedValidationModel::createWithAttributes(
[ [
'attr_jpg' => $this->createTestFiles([['name' => 'one.jpeg']]), 'attr_jpg' => $this->createTestFiles([['name' => 'one.jpeg']]),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment