Ver código fonte

[HttpFoundation] added a missing exception

Fabien Potencier 13 anos atrás
pai
commit
1c7694ff30

+ 2 - 0
src/Symfony/Component/HttpFoundation/FileBag.php

@@ -59,6 +59,8 @@ class FileBag extends ParameterBag
     {
         if (is_array($value) || $value instanceof UploadedFile) {
             parent::set($key, $this->convertFileInformation($value));
+        } else {
+            throw new \LogicException('An uploaded file must be an array or an instance of UploadedFile.');
         }
     }
 

+ 7 - 0
tests/Symfony/Tests/Component/HttpFoundation/FileBagTest.php

@@ -22,6 +22,13 @@ use Symfony\Component\HttpFoundation\FileBag;
  */
 class FileBagTest extends \PHPUnit_Framework_TestCase
 {
+    /**
+     * @expectedException \LogicException
+     */
+    public function testFileMustBeAnArrayOrUploadedFile()
+    {
+        new FileBag(array('file' => 'foo'));
+    }
 
     public function testShouldConvertsUploadedFiles()
     {