Skip to content

Commit 0db65b5

Browse files
committed
fix tests
1 parent 820186f commit 0db65b5

File tree

5 files changed

+14
-52
lines changed

5 files changed

+14
-52
lines changed

src/Symfony/Component/HttpFoundation/Tests/FileBagTest.php

Lines changed: 8 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,10 @@ public function testFileMustBeAnArrayOrUploadedFile()
3131
new FileBag(array('file' => 'foo'));
3232
}
3333

34-
/**
35-
* @group legacy
36-
* @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.
37-
*/
3834
public function testShouldConvertsUploadedFiles()
3935
{
4036
$tmpFile = $this->createTempFile();
41-
$file = new UploadedFile($tmpFile, basename($tmpFile), 'text/plain', 0);
37+
$file = new UploadedFile($tmpFile, basename($tmpFile), 'text/plain');
4238

4339
$bag = new FileBag(array('file' => array(
4440
'name' => basename($tmpFile),
@@ -64,26 +60,6 @@ public function testShouldSetEmptyUploadedFilesToNull()
6460
$this->assertNull($bag->get('file'));
6561
}
6662

67-
/**
68-
* @group legacy
69-
* @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.
70-
*/
71-
public function testShouldNotTriggerDeprecationWhenPassingSize()
72-
{
73-
$tmpFile = $this->createTempFile();
74-
$file = new UploadedFile($tmpFile, basename($tmpFile), 'text/plain', 0);
75-
76-
$bag = new FileBag(array('file' => array(
77-
'name' => basename($tmpFile),
78-
'type' => 'text/plain',
79-
'tmp_name' => $tmpFile,
80-
'error' => 0,
81-
'size' => 123456,
82-
)));
83-
84-
$this->assertEquals($file, $bag->get('file'));
85-
}
86-
8763
public function testShouldRemoveEmptyUploadedFilesForMultiUpload()
8864
{
8965
$bag = new FileBag(array('files' => array(
@@ -110,14 +86,10 @@ public function testShouldNotRemoveEmptyUploadedFilesForAssociativeArray()
11086
$this->assertSame(array('file1' => null), $bag->get('files'));
11187
}
11288

113-
/**
114-
* @group legacy
115-
* @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.
116-
*/
11789
public function testShouldConvertUploadedFilesWithPhpBug()
11890
{
11991
$tmpFile = $this->createTempFile();
120-
$file = new UploadedFile($tmpFile, basename($tmpFile), 'text/plain', 0);
92+
$file = new UploadedFile($tmpFile, basename($tmpFile), 'text/plain');
12193

12294
$bag = new FileBag(array(
12395
'child' => array(
@@ -143,14 +115,10 @@ public function testShouldConvertUploadedFilesWithPhpBug()
143115
$this->assertEquals($file, $files['child']['file']);
144116
}
145117

146-
/**
147-
* @group legacy
148-
* @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.
149-
*/
150118
public function testShouldConvertNestedUploadedFilesWithPhpBug()
151119
{
152120
$tmpFile = $this->createTempFile();
153-
$file = new UploadedFile($tmpFile, basename($tmpFile), 'text/plain', 0);
121+
$file = new UploadedFile($tmpFile, basename($tmpFile), 'text/plain');
154122

155123
$bag = new FileBag(array(
156124
'child' => array(
@@ -176,14 +144,10 @@ public function testShouldConvertNestedUploadedFilesWithPhpBug()
176144
$this->assertEquals($file, $files['child']['sub']['file']);
177145
}
178146

179-
/**
180-
* @group legacy
181-
* @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.
182-
*/
183147
public function testShouldNotConvertNestedUploadedFiles()
184148
{
185149
$tmpFile = $this->createTempFile();
186-
$file = new UploadedFile($tmpFile, basename($tmpFile), 'text/plain', 0);
150+
$file = new UploadedFile($tmpFile, basename($tmpFile), 'text/plain');
187151
$bag = new FileBag(array('image' => array('file' => $file)));
188152

189153
$files = $bag->all();
@@ -192,7 +156,10 @@ public function testShouldNotConvertNestedUploadedFiles()
192156

193157
protected function createTempFile()
194158
{
195-
return tempnam(sys_get_temp_dir().'/form_test', 'FormTest');
159+
$tempFile = tempnam(sys_get_temp_dir().'/form_test', 'FormTest');
160+
file_put_contents($tempFile, '1');
161+
162+
return $tempFile;
196163
}
197164

198165
protected function setUp()

src/Symfony/Component/HttpKernel/Tests/ClientTest.php

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -94,14 +94,10 @@ public function testFilterResponseSupportsStreamedResponses()
9494
$this->assertEquals('foo', $domResponse->getContent());
9595
}
9696

97-
/**
98-
* @group legacy
99-
* @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.
100-
*/
10197
public function testUploadedFile()
10298
{
10399
$source = tempnam(sys_get_temp_dir(), 'source');
104-
file_put_contents($source, '');
100+
file_put_contents($source, '1');
105101
$target = sys_get_temp_dir().'/sf.moved.file';
106102
@unlink($target);
107103

@@ -110,7 +106,7 @@ public function testUploadedFile()
110106

111107
$files = array(
112108
array('tmp_name' => $source, 'name' => 'original', 'type' => 'mime/original', 'size' => null, 'error' => UPLOAD_ERR_OK),
113-
new UploadedFile($source, 'original', 'mime/original', 0, UPLOAD_ERR_OK, true),
109+
new UploadedFile($source, 'original', 'mime/original', UPLOAD_ERR_OK, true),
114110
);
115111

116112
$file = null;
@@ -125,7 +121,7 @@ public function testUploadedFile()
125121

126122
$this->assertEquals('original', $file->getClientOriginalName());
127123
$this->assertEquals('mime/original', $file->getClientMimeType());
128-
$this->assertEquals($file->getSize(), 0);
124+
$this->assertEquals(1, $file->getSize());
129125
}
130126

131127
$file->move(dirname($target), basename($target));

src/Symfony/Component/HttpKernel/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"require": {
1919
"php": "^7.1.3",
2020
"symfony/event-dispatcher": "~3.4|~4.0",
21-
"symfony/http-foundation": "~3.4.4|~4.0.4",
21+
"symfony/http-foundation": "~4.1",
2222
"symfony/debug": "~3.4|~4.0",
2323
"psr/log": "~1.0"
2424
},

src/Symfony/Component/Validator/Tests/Constraints/FileValidatorTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -412,8 +412,7 @@ public function testDisallowEmpty()
412412
*/
413413
public function testUploadedFileError($error, $message, array $params = array(), $maxSize = null)
414414
{
415-
touch('/tmp/file');
416-
$file = new UploadedFile('/tmp/file', 'originalName', 'mime', $error);
415+
$file = new UploadedFile(tempnam(sys_get_temp_dir(), 'file-validator-test-'), 'originalName', 'mime', $error);
417416

418417
$constraint = new File(array(
419418
$message => 'myMessage',

src/Symfony/Component/Validator/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"symfony/translation": "~3.4|~4.0"
2222
},
2323
"require-dev": {
24-
"symfony/http-foundation": "~3.4|~4.0",
24+
"symfony/http-foundation": "~4.1",
2525
"symfony/http-kernel": "~3.4|~4.0",
2626
"symfony/var-dumper": "~3.4|~4.0",
2727
"symfony/intl": "~3.4|~4.0",

0 commit comments

Comments
 (0)