UploadedFileTest.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien.potencier@symfony-project.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Tests\Component\HttpFoundation\File;
  11. use Symfony\Component\HttpFoundation\File\UploadedFile;
  12. class UploadedFileTest extends \PHPUnit_Framework_TestCase
  13. {
  14. public function testFileUploadsMustBeEnabled()
  15. {
  16. // we can't change this setting without modifying php.ini :(
  17. if (!ini_get('file_uploads')) {
  18. $this->setExpectedException('Symfony\Component\HttpFoundation\File\Exception\FileException');
  19. new UploadedFile(
  20. __DIR__.'/Fixtures/test.gif',
  21. 'original.gif',
  22. 'image/gif',
  23. filesize(__DIR__.'/Fixtures/test.gif'),
  24. UPLOAD_ERR_OK
  25. );
  26. }
  27. }
  28. public function testErrorIsOkByDefault()
  29. {
  30. // we can't change this setting without modifying php.ini :(
  31. if (ini_get('file_uploads')) {
  32. $file = new UploadedFile(
  33. __DIR__.'/Fixtures/test.gif',
  34. 'original.gif',
  35. 'image/gif',
  36. filesize(__DIR__.'/Fixtures/test.gif'),
  37. null
  38. );
  39. $this->assertEquals(UPLOAD_ERR_OK, $file->getError());
  40. }
  41. }
  42. }