$uploadedFile =
$this->
createUploadedFile('An uploaded file.', \UPLOAD_ERR_OK, 'myfile.txt', 'text/plain'
);
$symfonyUploadedFile =
$this->
callCreateUploadedFile($uploadedFile);
$size =
$symfonyUploadedFile->
getSize();
$uniqid =
uniqid();
$symfonyUploadedFile->
move($this->tmpDir,
$uniqid);
$this->
assertEquals($uploadedFile->
getSize(),
$size);
$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));
} public function testCreateUploadedFileWithError() { $this->
expectException(FileException::
class);
$this->
expectExceptionMessage('The file "e" could not be written on disk.'
);
$uploadedFile =
$this->
createUploadedFile('Error.', \UPLOAD_ERR_CANT_WRITE, 'e', 'text/plain'
);
$symfonyUploadedFile =
$this->
callCreateUploadedFile($uploadedFile);