UploadedFileTest.php 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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. {
  12. $this->setExpectedException('Symfony\Components\File\Exception\FileException');
  13. new UploadedFile(
  14. __DIR__.'/Fixtures/test.gif',
  15. 'original.gif',
  16. 'image/gif',
  17. filesize(__DIR__.'/Fixtures/test.gif'),
  18. UPLOAD_ERR_OK
  19. );
  20. }
  21. }
  22. public function testErrorIsOkByDefault()
  23. {
  24. // we can't change this setting without modifying php.ini :(
  25. if (ini_get('file_uploads'))
  26. {
  27. $file = new UploadedFile(
  28. __DIR__.'/Fixtures/test.gif',
  29. 'original.gif',
  30. 'image/gif',
  31. filesize(__DIR__.'/Fixtures/test.gif'),
  32. null
  33. );
  34. $this->assertEquals(UPLOAD_ERR_OK, $file->getError());
  35. }
  36. }
  37. }