UploadedFileTest.php 1.2 KB

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