public function ClientTest::testUploadedFile in Zircon Profile 8
Same name and namespace in other branches
- 8.0 vendor/symfony/http-kernel/Tests/ClientTest.php \Symfony\Component\HttpKernel\Tests\ClientTest::testUploadedFile()
File
- vendor/
symfony/ http-kernel/ Tests/ ClientTest.php, line 93
Class
Namespace
Symfony\Component\HttpKernel\TestsCode
public function testUploadedFile() {
$source = tempnam(sys_get_temp_dir(), 'source');
$target = sys_get_temp_dir() . '/sf.moved.file';
@unlink($target);
$kernel = new TestHttpKernel();
$client = new Client($kernel);
$files = array(
array(
'tmp_name' => $source,
'name' => 'original',
'type' => 'mime/original',
'size' => 123,
'error' => UPLOAD_ERR_OK,
),
new UploadedFile($source, 'original', 'mime/original', 123, UPLOAD_ERR_OK, true),
);
$file = null;
foreach ($files as $file) {
$client
->request('POST', '/', array(), array(
'foo' => $file,
));
$files = $client
->getRequest()->files
->all();
$this
->assertCount(1, $files);
$file = $files['foo'];
$this
->assertEquals('original', $file
->getClientOriginalName());
$this
->assertEquals('mime/original', $file
->getClientMimeType());
$this
->assertEquals('123', $file
->getClientSize());
$this
->assertTrue($file
->isValid());
}
$file
->move(dirname($target), basename($target));
$this
->assertFileExists($target);
unlink($target);
}