Upgrade 1-11.38

This commit is contained in:
xesmyd
2026-03-30 14:10:30 +02:00
parent f2a7e6d1fc
commit ac648ef29d
24665 changed files with 69682 additions and 2205004 deletions
+59 -61
View File
@@ -23,12 +23,10 @@ use Symfony\Component\HttpFoundation\FileBag;
*/
class FileBagTest extends TestCase
{
/**
* @expectedException \InvalidArgumentException
*/
public function testFileMustBeAnArrayOrUploadedFile()
{
new FileBag(array('file' => 'foo'));
$this->expectException('InvalidArgumentException');
new FileBag(['file' => 'foo']);
}
public function testShouldConvertsUploadedFiles()
@@ -36,54 +34,54 @@ class FileBagTest extends TestCase
$tmpFile = $this->createTempFile();
$file = new UploadedFile($tmpFile, basename($tmpFile), 'text/plain', 100, 0);
$bag = new FileBag(array('file' => array(
$bag = new FileBag(['file' => [
'name' => basename($tmpFile),
'type' => 'text/plain',
'tmp_name' => $tmpFile,
'error' => 0,
'size' => 100,
)));
]]);
$this->assertEquals($file, $bag->get('file'));
}
public function testShouldSetEmptyUploadedFilesToNull()
{
$bag = new FileBag(array('file' => array(
$bag = new FileBag(['file' => [
'name' => '',
'type' => '',
'tmp_name' => '',
'error' => UPLOAD_ERR_NO_FILE,
'error' => \UPLOAD_ERR_NO_FILE,
'size' => 0,
)));
]]);
$this->assertNull($bag->get('file'));
}
public function testShouldRemoveEmptyUploadedFilesForMultiUpload()
{
$bag = new FileBag(array('files' => array(
'name' => array(''),
'type' => array(''),
'tmp_name' => array(''),
'error' => array(UPLOAD_ERR_NO_FILE),
'size' => array(0),
)));
$bag = new FileBag(['files' => [
'name' => [''],
'type' => [''],
'tmp_name' => [''],
'error' => [\UPLOAD_ERR_NO_FILE],
'size' => [0],
]]);
$this->assertSame(array(), $bag->get('files'));
$this->assertSame([], $bag->get('files'));
}
public function testShouldNotRemoveEmptyUploadedFilesForAssociativeArray()
{
$bag = new FileBag(array('files' => array(
'name' => array('file1' => ''),
'type' => array('file1' => ''),
'tmp_name' => array('file1' => ''),
'error' => array('file1' => UPLOAD_ERR_NO_FILE),
'size' => array('file1' => 0),
)));
$bag = new FileBag(['files' => [
'name' => ['file1' => ''],
'type' => ['file1' => ''],
'tmp_name' => ['file1' => ''],
'error' => ['file1' => \UPLOAD_ERR_NO_FILE],
'size' => ['file1' => 0],
]]);
$this->assertSame(array('file1' => null), $bag->get('files'));
$this->assertSame(['file1' => null], $bag->get('files'));
}
public function testShouldConvertUploadedFilesWithPhpBug()
@@ -91,25 +89,25 @@ class FileBagTest extends TestCase
$tmpFile = $this->createTempFile();
$file = new UploadedFile($tmpFile, basename($tmpFile), 'text/plain', 100, 0);
$bag = new FileBag(array(
'child' => array(
'name' => array(
$bag = new FileBag([
'child' => [
'name' => [
'file' => basename($tmpFile),
),
'type' => array(
],
'type' => [
'file' => 'text/plain',
),
'tmp_name' => array(
],
'tmp_name' => [
'file' => $tmpFile,
),
'error' => array(
],
'error' => [
'file' => 0,
),
'size' => array(
],
'size' => [
'file' => 100,
),
),
));
],
],
]);
$files = $bag->all();
$this->assertEquals($file, $files['child']['file']);
@@ -120,25 +118,25 @@ class FileBagTest extends TestCase
$tmpFile = $this->createTempFile();
$file = new UploadedFile($tmpFile, basename($tmpFile), 'text/plain', 100, 0);
$bag = new FileBag(array(
'child' => array(
'name' => array(
'sub' => array('file' => basename($tmpFile)),
),
'type' => array(
'sub' => array('file' => 'text/plain'),
),
'tmp_name' => array(
'sub' => array('file' => $tmpFile),
),
'error' => array(
'sub' => array('file' => 0),
),
'size' => array(
'sub' => array('file' => 100),
),
),
));
$bag = new FileBag([
'child' => [
'name' => [
'sub' => ['file' => basename($tmpFile)],
],
'type' => [
'sub' => ['file' => 'text/plain'],
],
'tmp_name' => [
'sub' => ['file' => $tmpFile],
],
'error' => [
'sub' => ['file' => 0],
],
'size' => [
'sub' => ['file' => 100],
],
],
]);
$files = $bag->all();
$this->assertEquals($file, $files['child']['sub']['file']);
@@ -148,7 +146,7 @@ class FileBagTest extends TestCase
{
$tmpFile = $this->createTempFile();
$file = new UploadedFile($tmpFile, basename($tmpFile), 'text/plain', 100, 0);
$bag = new FileBag(array('image' => array('file' => $file)));
$bag = new FileBag(['image' => ['file' => $file]]);
$files = $bag->all();
$this->assertEquals($file, $files['image']['file']);
@@ -167,9 +165,9 @@ class FileBagTest extends TestCase
protected function tearDown()
{
foreach (glob(sys_get_temp_dir().'/form_test/*') as $file) {
unlink($file);
@unlink($file);
}
rmdir(sys_get_temp_dir().'/form_test');
@rmdir(sys_get_temp_dir().'/form_test');
}
}