1
0
Fork 0
mirror of synced 2024-06-29 03:30:34 +12:00

Updated file type tests

This commit is contained in:
Eldad Fux 2019-12-26 21:58:37 +02:00
parent 83a2f0bebe
commit 1107284a5d
4 changed files with 6 additions and 1 deletions

View file

@ -64,6 +64,10 @@ class FileType extends Validator
*/ */
public function isValid($path) public function isValid($path)
{ {
if(!\is_readable($path)) {
return false;
}
$handle = fopen($path, 'r'); $handle = fopen($path, 'r');
if (!$handle) { if (!$handle) {

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 674 KiB

View file

@ -25,6 +25,7 @@ class FileTypeTest extends TestCase
{ {
$this->assertEquals($this->object->isValid(__DIR__ . '/../../../resources/disk-a/kitten-1.jpg'), true); $this->assertEquals($this->object->isValid(__DIR__ . '/../../../resources/disk-a/kitten-1.jpg'), true);
$this->assertEquals($this->object->isValid(__DIR__ . '/../../../resources/disk-a/kitten-2.jpg'), true); $this->assertEquals($this->object->isValid(__DIR__ . '/../../../resources/disk-a/kitten-2.jpg'), true);
$this->assertEquals($this->object->isValid(__DIR__ . '/../../../resources/disk-a/kitten-2.jpg'), true); $this->assertEquals($this->object->isValid(__DIR__ . '/../../../resources/disk-b/kitten-1.png'), false);
$this->assertEquals($this->object->isValid(__DIR__ . '/../../../resources/disk-b/kitten-2.png'), false);
} }
} }