"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "tests/framework/validators/FileValidatorTest.php" between
yii2-2.0.35.tar.gz and yii2-2.0.36.tar.gz

About: Yii 2 is a high-performance component-based PHP framework for developing large-scale Web applications (source).

FileValidatorTest.php  (yii2-2.0.35):FileValidatorTest.php  (yii2-2.0.36)
skipping to change at line 455 skipping to change at line 455
'attr_exe' => $this->createTestFiles([['name' => 'bad.exe']]), 'attr_exe' => $this->createTestFiles([['name' => 'bad.exe']]),
] ]
); );
$val->validateAttribute($m, 'attr_jpg'); $val->validateAttribute($m, 'attr_jpg');
$this->assertFalse($m->hasErrors('attr_jpg')); $this->assertFalse($m->hasErrors('attr_jpg'));
$val->validateAttribute($m, 'attr_exe'); $val->validateAttribute($m, 'attr_exe');
$this->assertTrue($m->hasErrors('attr_exe')); $this->assertTrue($m->hasErrors('attr_exe'));
$this->assertNotFalse(stripos(current($m->getErrors('attr_exe')), 'Only files with these extensions ')); $this->assertNotFalse(stripos(current($m->getErrors('attr_exe')), 'Only files with these extensions '));
} }
public function testValidateAttributeDoubleType()
{
$val = new FileValidator([
'extensions' => 'tar.gz, tar.xz',
'checkExtensionByMimeType' => false,
]);
$m = FakedValidationModel::createWithAttributes(
[
'attr_tar' => $this->createTestFiles([['name' => 'one.tar.gz']])
,
'attr_bar' => $this->createTestFiles([['name' => 'bad.bar.xz']])
,
'attr_badtar' => $this->createTestFiles([['name' => 'badtar.xz']
]),
]
);
$val->validateAttribute($m, 'attr_tar');
$this->assertFalse($m->hasErrors('attr_tar'));
$val->validateAttribute($m, 'attr_bar');
$this->assertTrue($m->hasErrors('attr_bar'));
$this->assertNotFalse(stripos(current($m->getErrors('attr_bar')), 'Only
files with these extensions '));
$val->validateAttribute($m, 'attr_badtar');
$this->assertTrue($m->hasErrors('attr_badtar'));
$this->assertNotFalse(stripos(current($m->getErrors('attr_badtar')), 'On
ly files with these extensions '));
}
public function testIssue11012() public function testIssue11012()
{ {
$baseName = '飛兒樂團光茫'; $baseName = '飛兒樂團光茫';
/** @var UploadedFile $file */ /** @var UploadedFile $file */
$file = $this->createTestFiles([ $file = $this->createTestFiles([
['name' => $baseName . '.txt'], ['name' => $baseName . '.txt'],
]); ]);
$this->assertEquals($baseName, $file->getBaseName()); $this->assertEquals($baseName, $file->getBaseName());
} }
skipping to change at line 499 skipping to change at line 525
public function validMimeTypes() public function validMimeTypes()
{ {
return array_filter([ return array_filter([
['test.svg', 'image/*', 'svg'], ['test.svg', 'image/*', 'svg'],
['test.jpg', 'image/*', 'jpg'], ['test.jpg', 'image/*', 'jpg'],
['test.png', 'image/*', 'png'], ['test.png', 'image/*', 'png'],
['test.png', 'IMAGE/*', 'png'], ['test.png', 'IMAGE/*', 'png'],
['test.txt', 'text/*', 'txt'], ['test.txt', 'text/*', 'txt'],
['test.xml', '*/xml', 'xml'], ['test.xml', '*/xml', 'xml'],
['test.odt', 'application/vnd*', 'odt'], ['test.odt', 'application/vnd*', 'odt'],
['test.tar.xz', 'application/x-xz', 'tar.xz'],
]); ]);
} }
public function invalidMimeTypes() public function invalidMimeTypes()
{ {
return [ return [
['test.txt', 'image/*', 'png, jpg'], ['test.txt', 'image/*', 'png, jpg'],
['test.odt', 'text/*', 'txt'], ['test.odt', 'text/*', 'txt'],
['test.xml', '*/svg+xml', 'svg'], ['test.xml', '*/svg+xml', 'svg'],
['test.png', 'image/x-iso9660-image', 'bmp'], ['test.png', 'image/x-iso9660-image', 'bmp'],
 End of changes. 2 change blocks. 
0 lines changed or deleted 32 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)