Skip to content
This repository has been archived by the owner on Dec 31, 2022. It is now read-only.

Commit

Permalink
Merge pull request #13 from sunrise-php/release/v1.0.12
Browse files Browse the repository at this point in the history
v1.0.12
  • Loading branch information
fenric authored Mar 29, 2020
2 parents 70cc523 + 9957f57 commit c51ea9c
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 38 deletions.
3 changes: 1 addition & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@
"sunrise/uri": "^1.0"
},
"require-dev": {
"phpunit/phpunit": "7.5.6",
"php-http/psr7-integration-tests": "dev-master"
"phpunit/phpunit": "7.5.6"
},
"provide": {
"psr/http-message-implementation": "1.0"
Expand Down
9 changes: 9 additions & 0 deletions functions/request_files.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@
*/
use Sunrise\Stream\StreamFactory;

/**
* Import constants
*/
use const UPLOAD_ERR_NO_FILE;

/**
* Normalizes the given uploaded files
*
Expand Down Expand Up @@ -52,6 +57,10 @@ function request_files(array $files) : array

foreach ($files as $key => $file)
{
if (UPLOAD_ERR_NO_FILE === $file['error']) {
continue;
}

$result[$key] = $walker($file['tmp_name'], $file['size'], $file['error'], $file['name'], $file['type']);
}

Expand Down
17 changes: 17 additions & 0 deletions tests/ServerRequestFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,23 @@ public function testCreateServerRequestFromGlobalsWithFiles()
$this->assertEquals($files['bar']['type'][0], $uploadedFiles['bar'][0]->getClientMediaType());
}

public function testCreateServerRequestFromGlobalsWithUploadErrorNoFile()
{
$files = [
'foo' => [
'error' => \UPLOAD_ERR_NO_FILE,
'size' => 0,
'tmp_name' => '',
'name' => '',
'type' => '',
],
];

$request = ServerRequestFactory::fromGlobals([], [], [], [], $files);

$this->assertCount(0, $request->getUploadedFiles());
}

public function headersFromGlobalsProvider()
{
return [
Expand Down
19 changes: 0 additions & 19 deletions tests/ServerRequestIntegrationTest.php

This file was deleted.

17 changes: 0 additions & 17 deletions tests/UploadedFileIntegrationTest.php

This file was deleted.

0 comments on commit c51ea9c

Please sign in to comment.