Skip to content

Commit e5d62e6

Browse files
committed
Fixes based on code-review
1 parent 101b608 commit e5d62e6

File tree

3 files changed

+13
-14
lines changed

3 files changed

+13
-14
lines changed

Factory/DiactorosFactory.php

Lines 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

Lines 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

Lines 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)