fix tests
This commit is contained in:
parent
820186fcac
commit
0db65b5bbe
@ -31,14 +31,10 @@ class FileBagTest extends TestCase
|
||||
new FileBag(array('file' => 'foo'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
* @expectedDeprecation Passing a size as 4th argument to the constructor of "Symfony\Component\HttpFoundation\File\UploadedFile" is deprecated since Symfony 4.1 and will be unsupported in 5.0.
|
||||
*/
|
||||
public function testShouldConvertsUploadedFiles()
|
||||
{
|
||||
$tmpFile = $this->createTempFile();
|
||||
$file = new UploadedFile($tmpFile, basename($tmpFile), 'text/plain', 0);
|
||||
$file = new UploadedFile($tmpFile, basename($tmpFile), 'text/plain');
|
||||
|
||||
$bag = new FileBag(array('file' => array(
|
||||
'name' => basename($tmpFile),
|
||||
@ -64,26 +60,6 @@ class FileBagTest extends TestCase
|
||||
$this->assertNull($bag->get('file'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
* @expectedDeprecation Passing a size as 4th argument to the constructor of "Symfony\Component\HttpFoundation\File\UploadedFile" is deprecated since Symfony 4.1 and will be unsupported in 5.0.
|
||||
*/
|
||||
public function testShouldNotTriggerDeprecationWhenPassingSize()
|
||||
{
|
||||
$tmpFile = $this->createTempFile();
|
||||
$file = new UploadedFile($tmpFile, basename($tmpFile), 'text/plain', 0);
|
||||
|
||||
$bag = new FileBag(array('file' => array(
|
||||
'name' => basename($tmpFile),
|
||||
'type' => 'text/plain',
|
||||
'tmp_name' => $tmpFile,
|
||||
'error' => 0,
|
||||
'size' => 123456,
|
||||
)));
|
||||
|
||||
$this->assertEquals($file, $bag->get('file'));
|
||||
}
|
||||
|
||||
public function testShouldRemoveEmptyUploadedFilesForMultiUpload()
|
||||
{
|
||||
$bag = new FileBag(array('files' => array(
|
||||
@ -110,14 +86,10 @@ class FileBagTest extends TestCase
|
||||
$this->assertSame(array('file1' => null), $bag->get('files'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
* @expectedDeprecation Passing a size as 4th argument to the constructor of "Symfony\Component\HttpFoundation\File\UploadedFile" is deprecated since Symfony 4.1 and will be unsupported in 5.0.
|
||||
*/
|
||||
public function testShouldConvertUploadedFilesWithPhpBug()
|
||||
{
|
||||
$tmpFile = $this->createTempFile();
|
||||
$file = new UploadedFile($tmpFile, basename($tmpFile), 'text/plain', 0);
|
||||
$file = new UploadedFile($tmpFile, basename($tmpFile), 'text/plain');
|
||||
|
||||
$bag = new FileBag(array(
|
||||
'child' => array(
|
||||
@ -143,14 +115,10 @@ class FileBagTest extends TestCase
|
||||
$this->assertEquals($file, $files['child']['file']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
* @expectedDeprecation Passing a size as 4th argument to the constructor of "Symfony\Component\HttpFoundation\File\UploadedFile" is deprecated since Symfony 4.1 and will be unsupported in 5.0.
|
||||
*/
|
||||
public function testShouldConvertNestedUploadedFilesWithPhpBug()
|
||||
{
|
||||
$tmpFile = $this->createTempFile();
|
||||
$file = new UploadedFile($tmpFile, basename($tmpFile), 'text/plain', 0);
|
||||
$file = new UploadedFile($tmpFile, basename($tmpFile), 'text/plain');
|
||||
|
||||
$bag = new FileBag(array(
|
||||
'child' => array(
|
||||
@ -176,14 +144,10 @@ class FileBagTest extends TestCase
|
||||
$this->assertEquals($file, $files['child']['sub']['file']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
* @expectedDeprecation Passing a size as 4th argument to the constructor of "Symfony\Component\HttpFoundation\File\UploadedFile" is deprecated since Symfony 4.1 and will be unsupported in 5.0.
|
||||
*/
|
||||
public function testShouldNotConvertNestedUploadedFiles()
|
||||
{
|
||||
$tmpFile = $this->createTempFile();
|
||||
$file = new UploadedFile($tmpFile, basename($tmpFile), 'text/plain', 0);
|
||||
$file = new UploadedFile($tmpFile, basename($tmpFile), 'text/plain');
|
||||
$bag = new FileBag(array('image' => array('file' => $file)));
|
||||
|
||||
$files = $bag->all();
|
||||
@ -192,7 +156,10 @@ class FileBagTest extends TestCase
|
||||
|
||||
protected function createTempFile()
|
||||
{
|
||||
return tempnam(sys_get_temp_dir().'/form_test', 'FormTest');
|
||||
$tempFile = tempnam(sys_get_temp_dir().'/form_test', 'FormTest');
|
||||
file_put_contents($tempFile, '1');
|
||||
|
||||
return $tempFile;
|
||||
}
|
||||
|
||||
protected function setUp()
|
||||
|
@ -94,14 +94,10 @@ class ClientTest extends TestCase
|
||||
$this->assertEquals('foo', $domResponse->getContent());
|
||||
}
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
* @expectedDeprecation Passing a size as 4th argument to the constructor of "Symfony\Component\HttpFoundation\File\UploadedFile" is deprecated since Symfony 4.1 and will be unsupported in 5.0.
|
||||
*/
|
||||
public function testUploadedFile()
|
||||
{
|
||||
$source = tempnam(sys_get_temp_dir(), 'source');
|
||||
file_put_contents($source, '');
|
||||
file_put_contents($source, '1');
|
||||
$target = sys_get_temp_dir().'/sf.moved.file';
|
||||
@unlink($target);
|
||||
|
||||
@ -110,7 +106,7 @@ class ClientTest extends TestCase
|
||||
|
||||
$files = array(
|
||||
array('tmp_name' => $source, 'name' => 'original', 'type' => 'mime/original', 'size' => null, 'error' => UPLOAD_ERR_OK),
|
||||
new UploadedFile($source, 'original', 'mime/original', 0, UPLOAD_ERR_OK, true),
|
||||
new UploadedFile($source, 'original', 'mime/original', UPLOAD_ERR_OK, true),
|
||||
);
|
||||
|
||||
$file = null;
|
||||
@ -125,7 +121,7 @@ class ClientTest extends TestCase
|
||||
|
||||
$this->assertEquals('original', $file->getClientOriginalName());
|
||||
$this->assertEquals('mime/original', $file->getClientMimeType());
|
||||
$this->assertEquals($file->getSize(), 0);
|
||||
$this->assertEquals(1, $file->getSize());
|
||||
}
|
||||
|
||||
$file->move(dirname($target), basename($target));
|
||||
|
@ -18,7 +18,7 @@
|
||||
"require": {
|
||||
"php": "^7.1.3",
|
||||
"symfony/event-dispatcher": "~3.4|~4.0",
|
||||
"symfony/http-foundation": "~3.4.4|~4.0.4",
|
||||
"symfony/http-foundation": "~4.1",
|
||||
"symfony/debug": "~3.4|~4.0",
|
||||
"psr/log": "~1.0"
|
||||
},
|
||||
|
@ -412,8 +412,7 @@ abstract class FileValidatorTest extends ConstraintValidatorTestCase
|
||||
*/
|
||||
public function testUploadedFileError($error, $message, array $params = array(), $maxSize = null)
|
||||
{
|
||||
touch('/tmp/file');
|
||||
$file = new UploadedFile('/tmp/file', 'originalName', 'mime', $error);
|
||||
$file = new UploadedFile(tempnam(sys_get_temp_dir(), 'file-validator-test-'), 'originalName', 'mime', $error);
|
||||
|
||||
$constraint = new File(array(
|
||||
$message => 'myMessage',
|
||||
|
@ -21,7 +21,7 @@
|
||||
"symfony/translation": "~3.4|~4.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"symfony/http-foundation": "~3.4|~4.0",
|
||||
"symfony/http-foundation": "~4.1",
|
||||
"symfony/http-kernel": "~3.4|~4.0",
|
||||
"symfony/var-dumper": "~3.4|~4.0",
|
||||
"symfony/intl": "~3.4|~4.0",
|
||||
|
Reference in New Issue
Block a user