UploadedFileTest.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. namespace Symfony\Tests\Components\File;
  3. require_once __DIR__ . '/../../../../bootstrap.php';
  4. use Symfony\Components\File\UploadedFile;
  5. class UploadedFileTest extends \PHPUnit_Framework_TestCase
  6. {
  7. public function testFileUploadsMustBeEnabled()
  8. {
  9. // we can't change this setting without modifying php.ini :(
  10. if (!ini_get('file_uploads')) {
  11. $this->setExpectedException('Symfony\Components\File\Exception\FileException');
  12. new UploadedFile(
  13. __DIR__.'/Fixtures/test.gif',
  14. 'original.gif',
  15. 'image/gif',
  16. filesize(__DIR__.'/Fixtures/test.gif'),
  17. UPLOAD_ERR_OK
  18. );
  19. }
  20. }
  21. public function testErrorIsOkByDefault()
  22. {
  23. // we can't change this setting without modifying php.ini :(
  24. if (ini_get('file_uploads')) {
  25. $file = new UploadedFile(
  26. __DIR__.'/Fixtures/test.gif',
  27. 'original.gif',
  28. 'image/gif',
  29. filesize(__DIR__.'/Fixtures/test.gif'),
  30. null
  31. );
  32. $this->assertEquals(UPLOAD_ERR_OK, $file->getError());
  33. }
  34. }
  35. }