Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit e5d62e6

Browse filesBrowse files
committed
Fixes based on code-review
1 parent 101b608 commit e5d62e6
Copy full SHA for e5d62e6

File tree

Expand file treeCollapse file tree

3 files changed

+13
-14
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+13
-14
lines changed

‎Factory/DiactorosFactory.php

Copy file name to clipboardExpand all lines: Factory/DiactorosFactory.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ private function getFiles(array $uploadedFiles)
8686
$files = array();
8787

8888
foreach ($uploadedFiles as $key => $value) {
89-
if ($value === null) {
89+
if (null === $value) {
9090
$files[$key] = new DiactorosUploadedFile(null, 0, UPLOAD_ERR_NO_FILE, null, null);
9191
continue;
9292
}

‎Factory/HttpFoundationFactory.php

Copy file name to clipboardExpand all lines: Factory/HttpFoundationFactory.php
+7-3Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,14 @@ private function getFiles(array $uploadedFiles)
8080
*/
8181
private function createUploadedFile(UploadedFileInterface $psrUploadedFile)
8282
{
83-
$temporaryPath = $this->getTemporaryPath();
84-
$psrUploadedFile->moveTo($temporaryPath);
83+
$temporaryPath = '';
84+
$clientFileName = '';
85+
if (UPLOAD_ERR_NO_FILE !== $psrUploadedFile->getError()) {
86+
$temporaryPath = $this->getTemporaryPath();
87+
$psrUploadedFile->moveTo($temporaryPath);
8588

86-
$clientFileName = $psrUploadedFile->getClientFilename();
89+
$clientFileName = $psrUploadedFile->getClientFilename();
90+
}
8791

8892
return new UploadedFile(
8993
$temporaryPath,

‎Tests/Factory/DiactorosFactoryTest.php

Copy file name to clipboardExpand all lines: Tests/Factory/DiactorosFactoryTest.php
+5-10Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -164,18 +164,13 @@ public function testCreateResponseFromBinaryFile()
164164

165165
public function testUploadErrNoFile()
166166
{
167-
$file = new UploadedFile(null, null, null, 0, UPLOAD_ERR_NO_FILE, true);
168-
$this->assertEquals(0,$file->getSize());
169-
$this->assertEquals(UPLOAD_ERR_NO_FILE,$file->getError());
170-
171-
// SplFile returns false on error
172-
$this->assertEquals('boolean',gettype(($file->getSize())));
167+
$file = new UploadedFile('', '', null, 0, UPLOAD_ERR_NO_FILE, true);
168+
$this->assertEquals(0, $file->getSize());
169+
$this->assertEquals(UPLOAD_ERR_NO_FILE, $file->getError());
173170
$this->assertFalse($file->getSize());
171+
$this->assertInternalType('integer', $file->getClientSize());
174172

175-
// This is an integer, oddly enough internally size is declared as a string
176-
$this->assertTrue(is_int($file->getClientSize()));
177-
178-
$request = new Request(array(),array(),array(),array(),
173+
$request = new Request(array(), array(), array(), array(),
179174
array(
180175
'f1' => $file,
181176
'f2' => array('name' => null, 'type' => null, 'tmp_name' => null, 'error' => UPLOAD_ERR_NO_FILE, 'size' => 0),

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.