You are here

public function ClientTest::testUploadedFileWhenSizeExceedsUploadMaxFileSize in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony/http-kernel/Tests/ClientTest.php \Symfony\Component\HttpKernel\Tests\ClientTest::testUploadedFileWhenSizeExceedsUploadMaxFileSize()

File

vendor/symfony/http-kernel/Tests/ClientTest.php, line 144

Class

ClientTest

Namespace

Symfony\Component\HttpKernel\Tests

Code

public function testUploadedFileWhenSizeExceedsUploadMaxFileSize() {
  $source = tempnam(sys_get_temp_dir(), 'source');
  $kernel = new TestHttpKernel();
  $client = new Client($kernel);
  $file = $this
    ->getMockBuilder('Symfony\\Component\\HttpFoundation\\File\\UploadedFile')
    ->setConstructorArgs(array(
    $source,
    'original',
    'mime/original',
    123,
    UPLOAD_ERR_OK,
    true,
  ))
    ->setMethods(array(
    'getSize',
  ))
    ->getMock();
  $file
    ->expects($this
    ->once())
    ->method('getSize')
    ->will($this
    ->returnValue(INF));
  $client
    ->request('POST', '/', array(), array(
    $file,
  ));
  $files = $client
    ->getRequest()->files
    ->all();
  $this
    ->assertCount(1, $files);
  $file = $files[0];
  $this
    ->assertFalse($file
    ->isValid());
  $this
    ->assertEquals(UPLOAD_ERR_INI_SIZE, $file
    ->getError());
  $this
    ->assertEquals('mime/original', $file
    ->getClientMimeType());
  $this
    ->assertEquals('original', $file
    ->getClientOriginalName());
  $this
    ->assertEquals(0, $file
    ->getClientSize());
  unlink($source);
}