Skip to content
This repository has been archived by the owner on Jan 31, 2020. It is now read-only.

Commit

Permalink
Merge branch 'hotfix/5555'
Browse files Browse the repository at this point in the history
  • Loading branch information
weierophinney committed Mar 3, 2014
151 parents 4d6040d + 56df441 + 3ddc8fa + 274bd7f + c9e433d + 99f6515 + 8d1a271 + 2c2bc35 + 16359e3 + 10b9b3c + d05ac01 + 9628c66 + 66c8763 + 943d333 + 8342f70 + 4eb4184 + 4ea0bc2 + 860b725 + 7d29287 + 49a7844 + 3836aa0 + de1fe83 + 929eb12 + 6e6902f + f823467 + f3b3f76 + 93aff47 + 5f2adec + 7674ec8 + 2200ed2 + f033c86 + d43a2da + 4434323 + 88b21e1 + b02b602 + b692de7 + 7f833d2 + 2eaf4da + a7848de + 5bd9f85 + d7a26e8 + 173f53d + bd77e8e + 45f017e + 118612c + 3a09f79 + 47d92bc + dbf56ad + a753b61 + 6467186 + 5ac4124 + 2bf68ca + e7cd709 + 7a552db + f112e0c + cec42fc + 066eb37 + 3569d8b + 00def10 + ecae47b + 0e552a5 + 4f854c2 + 2b17650 + c1c0447 + 73b1f80 + dd4a335 + a40eb42 + 9262db1 + bdbd950 + 6d50117 + 10b08a7 + f692a0d + ebe63d3 + 528260b + 5f04a7f + c0dcd12 + 224f280 + 8785f25 + 866539b + d711927 + e280213 + 002f0d4 + 5ffcbbe + 8937705 + 5803840 + 3d7cd9a + 6b14f0e + 24bd169 + 0eba870 + 4e4acfe + 9e243bd + e156354 + 2a84563 + 3f1f758 + 4e425f4 + 7030f97 + ea08a0f + 213ebd9 + 5d80740 + 800c29c + be31ff1 + 8f989d6 + 8b02a8b + 4cfd82c + c411f06 + 4229561 + b321e3b + 2e660f9 + 3fff65f + a2eb7bf + 82469ff + 22fa741 + 99819cb + 8c16404 + a7c0820 + 7d277af + da0bec5 + 33f214a + a07f208 + 963d2fe + 1100f88 + 6713bf5 + 7421758 + b64a638 + 772a2a1 + dff3231 + 56bc4ca + 463e3d7 + 14bd316 + f8b9e58 + ef0268c + 3fe91ce + 130da19 + 6d4097d + 02fa5b3 + 927b7df + 2fbc2a0 + c772270 + 1cdc0cc + 852db9e + 047576f + 1b49389 + d7193b9 + 3fed016 + 082acdb + ecb5260 + 3ec34d8 + 838bdc9 + 3c0e07f + 6ac386b + 206e4c9 commit 4bd985a
Show file tree
Hide file tree
Showing 27 changed files with 281 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/File/Crc32.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public function isValid($value, $file = null)
$this->setValue($filename);

// Is file readable ?
if (false === stream_resolve_include_path($file)) {
if (empty($file) || false === stream_resolve_include_path($file)) {
$this->error(self::NOT_FOUND);
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion src/File/ExcludeExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function isValid($value, $file = null)
$this->setValue($filename);

// Is file readable ?
if (false === stream_resolve_include_path($file)) {
if (empty($file) || false === stream_resolve_include_path($file)) {
$this->error(self::NOT_FOUND);
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion src/File/ExcludeMimeType.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function isValid($value, $file = null)
$this->setValue($filename);

// Is file readable ?
if (false === stream_resolve_include_path($file)) {
if (empty($file) || false === stream_resolve_include_path($file)) {
$this->error(self::NOT_READABLE);
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion src/File/Extension.php
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ public function isValid($value, $file = null)
$this->setValue($filename);

// Is file readable ?
if (false === stream_resolve_include_path($file)) {
if (empty($file) || false === stream_resolve_include_path($file)) {
$this->error(self::NOT_FOUND);
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion src/File/FilesSize.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public function isValid($value, $file = null)
$size = $this->getSize();
foreach ($value as $files) {
// Is file readable ?
if (false === stream_resolve_include_path($files)) {
if (empty($files) || false === stream_resolve_include_path($files)) {
$this->throwError($file, self::NOT_READABLE);
continue;
}
Expand Down
2 changes: 1 addition & 1 deletion src/File/Hash.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ public function isValid($value, $file = null)
$this->setValue($filename);

// Is file readable ?
if (false === stream_resolve_include_path($file)) {
if (empty($file) || false === stream_resolve_include_path($file)) {
$this->error(self::NOT_FOUND);
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion src/File/ImageSize.php
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ public function isValid($value, $file = null)
$this->setValue($filename);

// Is file readable ?
if (false === stream_resolve_include_path($file)) {
if (empty($file) || false === stream_resolve_include_path($file)) {
$this->error(self::NOT_READABLE);
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion src/File/Md5.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public function isValid($value, $file = null)
$this->setValue($filename);

// Is file readable ?
if (false === stream_resolve_include_path($file)) {
if (empty($file) || false === stream_resolve_include_path($file)) {
$this->error(self::NOT_FOUND);
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion src/File/MimeType.php
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ public function isValid($value, $file = null)
$this->setValue($filename);

// Is file readable ?
if (false === stream_resolve_include_path($file)) {
if (empty($file) || false === stream_resolve_include_path($file)) {
$this->error(static::NOT_READABLE);
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion src/File/Sha1.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public function isValid($value, $file = null)
$this->setValue($filename);

// Is file readable ?
if (false === stream_resolve_include_path($file)) {
if (empty($file) || false === stream_resolve_include_path($file)) {
$this->error(self::NOT_FOUND);
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion src/File/Size.php
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ public function isValid($value, $file = null)
$this->setValue($filename);

// Is file readable ?
if (false === stream_resolve_include_path($file)) {
if (empty($file) || false === stream_resolve_include_path($file)) {
$this->error(self::NOT_FOUND);
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion src/File/UploadFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public function isValid($value)
}
$this->setValue($filename);

if (false === stream_resolve_include_path($file)) {
if (empty($file) || false === stream_resolve_include_path($file)) {
$this->error(self::FILE_NOT_FOUND);
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion src/File/WordCount.php
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ public function isValid($value, $file = null)
$this->setValue($filename);

// Is file readable ?
if (false === stream_resolve_include_path($file)) {
if (empty($file) || false === stream_resolve_include_path($file)) {
$this->error(self::NOT_FOUND);
return false;
}
Expand Down
19 changes: 19 additions & 0 deletions test/File/Crc32Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -185,4 +185,23 @@ public function testZF11258()
$this->assertTrue(array_key_exists('fileCrc32NotFound', $validator->getMessages()));
$this->assertContains("does not exist", current($validator->getMessages()));
}

public function testEmptyFileShouldReturnFalseAndDisplayNotFoundMessage()
{
$validator = new File\Crc32();

$this->assertFalse($validator->isValid(''));
$this->assertArrayHasKey(File\Crc32::NOT_FOUND, $validator->getMessages());

$filesArray = array(
'name' => '',
'size' => 0,
'tmp_name' => '',
'error' => UPLOAD_ERR_NO_FILE,
'type' => '',
);

$this->assertFalse($validator->isValid($filesArray));
$this->assertArrayHasKey(File\Crc32::NOT_FOUND, $validator->getMessages());
}
}
19 changes: 19 additions & 0 deletions test/File/ExcludeExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,4 +161,23 @@ public function testZF11258()
$this->assertTrue(array_key_exists('fileExcludeExtensionNotFound', $validator->getMessages()));
$this->assertContains("does not exist", current($validator->getMessages()));
}

public function testEmptyFileShouldReturnFalseAndDisplayNotFoundMessage()
{
$validator = new File\ExcludeExtension('12345');

$this->assertFalse($validator->isValid(''));
$this->assertArrayHasKey(File\ExcludeExtension::NOT_FOUND, $validator->getMessages());

$filesArray = array(
'name' => '',
'size' => 0,
'tmp_name' => '',
'error' => UPLOAD_ERR_NO_FILE,
'type' => '',
);

$this->assertFalse($validator->isValid($filesArray));
$this->assertArrayHasKey(File\ExcludeExtension::NOT_FOUND, $validator->getMessages());
}
}
19 changes: 19 additions & 0 deletions test/File/ExcludeMimeTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,4 +130,23 @@ public function testAddMimeType()
$this->assertEquals('image/gif,text,jpg,to,zip,ti', $validator->getMimeType());
$this->assertEquals(array('image/gif', 'text', 'jpg', 'to', 'zip', 'ti'), $validator->getMimeType(true));
}

public function testEmptyFileShouldReturnFalseAndDisplayNotFoundMessage()
{
$validator = new ExcludeMimeType();

$this->assertFalse($validator->isValid(''));
$this->assertArrayHasKey(ExcludeMimeType::NOT_READABLE, $validator->getMessages());

$filesArray = array(
'name' => '',
'size' => 0,
'tmp_name' => '',
'error' => UPLOAD_ERR_NO_FILE,
'type' => '',
);

$this->assertFalse($validator->isValid($filesArray));
$this->assertArrayHasKey(ExcludeMimeType::NOT_READABLE, $validator->getMessages());
}
}
19 changes: 19 additions & 0 deletions test/File/ExistsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,4 +137,23 @@ public function testZF11258()
$this->assertTrue(array_key_exists('fileExistsDoesNotExist', $validator->getMessages()));
$this->assertContains("does not exist", current($validator->getMessages()));
}

public function testEmptyFileArrayShouldReturnFalse()
{
$validator = new File\Exists();

$this->assertFalse($validator->isValid(''));
$this->assertArrayHasKey(File\Exists::DOES_NOT_EXIST, $validator->getMessages());

$filesArray = array(
'name' => '',
'size' => 0,
'tmp_name' => '',
'error' => UPLOAD_ERR_NO_FILE,
'type' => '',
);

$this->assertFalse($validator->isValid($filesArray));
$this->assertArrayHasKey(File\Exists::DOES_NOT_EXIST, $validator->getMessages());
}
}
19 changes: 19 additions & 0 deletions test/File/ExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,4 +164,23 @@ public function testZF11258()
$this->assertTrue(array_key_exists('fileExtensionNotFound', $validator->getMessages()));
$this->assertContains("does not exist", current($validator->getMessages()));
}

public function testEmptyFileShouldReturnFalseAndDisplayNotFoundMessage()
{
$validator = new File\Extension('foo');

$this->assertFalse($validator->isValid(''));
$this->assertArrayHasKey(File\Extension::NOT_FOUND, $validator->getMessages());

$filesArray = array(
'name' => '',
'size' => 0,
'tmp_name' => '',
'error' => UPLOAD_ERR_NO_FILE,
'type' => '',
);

$this->assertFalse($validator->isValid($filesArray));
$this->assertArrayHasKey(File\Extension::NOT_FOUND, $validator->getMessages());
}
}
19 changes: 19 additions & 0 deletions test/File/FilesSizeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,4 +183,23 @@ public function errorHandler($errno, $errstr)
$this->multipleOptionsDetected = true;
}
}

public function testEmptyFileShouldReturnFalseAndDisplayNotFoundMessage()
{
$validator = new File\FilesSize(0);

$this->assertFalse($validator->isValid(''));
$this->assertArrayHasKey(File\FilesSize::NOT_READABLE, $validator->getMessages());

$filesArray = array(
'name' => '',
'size' => 0,
'tmp_name' => '',
'error' => UPLOAD_ERR_NO_FILE,
'type' => '',
);

$this->assertFalse($validator->isValid($filesArray));
$this->assertArrayHasKey(File\FilesSize::NOT_READABLE, $validator->getMessages());
}
}
19 changes: 19 additions & 0 deletions test/File/HashTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,4 +159,23 @@ public function testZF11258()
$this->assertTrue(array_key_exists('fileHashNotFound', $validator->getMessages()));
$this->assertContains("does not exist", current($validator->getMessages()));
}

public function testEmptyFileShouldReturnFalseAndDisplayNotFoundMessage()
{
$validator = new File\Hash();

$this->assertFalse($validator->isValid(''));
$this->assertArrayHasKey(File\Hash::NOT_FOUND, $validator->getMessages());

$filesArray = array(
'name' => '',
'size' => 0,
'tmp_name' => '',
'error' => UPLOAD_ERR_NO_FILE,
'type' => '',
);

$this->assertFalse($validator->isValid($filesArray));
$this->assertArrayHasKey(File\Hash::NOT_FOUND, $validator->getMessages());
}
}
19 changes: 19 additions & 0 deletions test/File/ImageSizeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -263,4 +263,23 @@ public function testZF11258()
$this->assertTrue(array_key_exists('fileImageSizeNotReadable', $validator->getMessages()));
$this->assertContains("does not exist", current($validator->getMessages()));
}

public function testEmptyFileShouldReturnFalseAndDisplayNotFoundMessage()
{
$validator = new File\ImageSize();

$this->assertFalse($validator->isValid(''));
$this->assertArrayHasKey(File\ImageSize::NOT_READABLE, $validator->getMessages());

$filesArray = array(
'name' => '',
'size' => 0,
'tmp_name' => '',
'error' => UPLOAD_ERR_NO_FILE,
'type' => '',
);

$this->assertFalse($validator->isValid($filesArray));
$this->assertArrayHasKey(File\ImageSize::NOT_READABLE, $validator->getMessages());
}
}
19 changes: 19 additions & 0 deletions test/File/Md5Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,4 +199,23 @@ public function testZF11258()
$this->assertTrue(array_key_exists('fileMd5NotFound', $validator->getMessages()));
$this->assertContains("does not exist", current($validator->getMessages()));
}

public function testEmptyFileShouldReturnFalseAndDisplayNotFoundMessage()
{
$validator = new File\Md5();

$this->assertFalse($validator->isValid(''));
$this->assertArrayHasKey(File\Md5::NOT_FOUND, $validator->getMessages());

$filesArray = array(
'name' => '',
'size' => 0,
'tmp_name' => '',
'error' => UPLOAD_ERR_NO_FILE,
'type' => '',
);

$this->assertFalse($validator->isValid($filesArray));
$this->assertArrayHasKey(File\Md5::NOT_FOUND, $validator->getMessages());
}
}
21 changes: 21 additions & 0 deletions test/File/MimeTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -221,4 +221,25 @@ public function testDisablingMagicFileByConstructor()
$validator = new File\MimeType($files);
$this->assertFalse($validator->getMagicFile());
}

public function testEmptyFileShouldReturnFalseAndDisplayNotFoundMessage()
{
if (! extension_loaded('fileinfo')) {
$this->markTestSkipped('This PHP Version has no finfo installed');
}

$validator = new File\MimeType();

$this->assertFalse($validator->isValid(''));

$filesArray = array(
'name' => '',
'size' => 0,
'tmp_name' => '',
'error' => UPLOAD_ERR_NO_FILE,
'type' => '',
);

$this->assertFalse($validator->isValid($filesArray));
}
}
19 changes: 19 additions & 0 deletions test/File/Sha1Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -186,4 +186,23 @@ public function testZF11258()
$this->assertTrue(array_key_exists('fileSha1NotFound', $validator->getMessages()));
$this->assertContains("does not exist", current($validator->getMessages()));
}

public function testEmptyFileShouldReturnFalseAndDisplayNotFoundMessage()
{
$validator = new File\Sha1();

$this->assertFalse($validator->isValid(''));
$this->assertArrayHasKey(File\Sha1::NOT_FOUND, $validator->getMessages());

$filesArray = array(
'name' => '',
'size' => 0,
'tmp_name' => '',
'error' => UPLOAD_ERR_NO_FILE,
'type' => '',
);

$this->assertFalse($validator->isValid($filesArray));
$this->assertArrayHasKey(File\Sha1::NOT_FOUND, $validator->getMessages());
}
}
Loading

0 comments on commit 4bd985a

Please sign in to comment.