Skip to content
Permalink
Browse files

check for file param order

  • Loading branch information...
antograssiot committed Sep 10, 2014
1 parent 5f6bb95 commit 60f60c7814cf2adb1237d43cb9e9d150d70e3b88
Showing with 20 additions and 1 deletion.
  1. +2 −1 src/Validation/Validation.php
  2. +18 −0 tests/TestCase/Validation/ValidationTest.php
@@ -983,7 +983,8 @@ public static function uploadedFile($file, $options = []) {
if (!is_array($file)) {
return false;
}
$keys = ['name', 'tmp_name', 'error', 'type', 'size'];
$keys = ['error', 'name', 'size', 'tmp_name', 'type'];
ksort($file);
if (array_keys($file) != $keys) {
return false;
}
@@ -2447,4 +2447,22 @@ public function testUploadedFileNoFile() {
$this->assertFalse(Validation::uploadedFile($file, $options), 'File is required.');
}
/**
* Test uploaded file validation.
*
* @return void
*/
public function testUploadedFileWithDifferentFileParametersOrder() {
$file = [
'name' => 'cake.power.gif',
'error' => UPLOAD_ERR_OK,
'tmp_name' => TEST_APP . 'webroot/img/cake.power.gif',
'type' => 'text/plain',
'size' => 201
];
$options = [];
$this->assertTrue(Validation::uploadedFile($file, $options), 'Wrong order');
}
}

0 comments on commit 60f60c7

Please sign in to comment.
You can’t perform that action at this time.