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