You are here

public function HttpFoundationFactoryTest::testCreateUploadedFile in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/symfony/psr-http-message-bridge/Tests/Factory/HttpFoundationFactoryTest.php \Symfony\Bridge\PsrHttpMessage\Tests\Factory\HttpFoundationFactoryTest::testCreateUploadedFile()

File

vendor/symfony/psr-http-message-bridge/Tests/Factory/HttpFoundationFactoryTest.php, line 119

Class

HttpFoundationFactoryTest
@author Kévin Dunglas <dunglas@gmail.com>

Namespace

Symfony\Bridge\PsrHttpMessage\Tests\Factory

Code

public function testCreateUploadedFile() {
  $uploadedFile = $this
    ->createUploadedFile('An uploaded file.', UPLOAD_ERR_OK, 'myfile.txt', 'text/plain');
  $symfonyUploadedFile = $this
    ->callCreateUploadedFile($uploadedFile);
  $uniqid = uniqid();
  $symfonyUploadedFile
    ->move($this->tmpDir, $uniqid);
  $this
    ->assertEquals($uploadedFile
    ->getSize(), $symfonyUploadedFile
    ->getClientSize());
  $this
    ->assertEquals(UPLOAD_ERR_OK, $symfonyUploadedFile
    ->getError());
  $this
    ->assertEquals('myfile.txt', $symfonyUploadedFile
    ->getClientOriginalName());
  $this
    ->assertEquals('txt', $symfonyUploadedFile
    ->getClientOriginalExtension());
  $this
    ->assertEquals('text/plain', $symfonyUploadedFile
    ->getClientMimeType());
  $this
    ->assertEquals('An uploaded file.', file_get_contents($this->tmpDir . '/' . $uniqid));
}