Skip to content

Commit 268656e

Browse files
authored
Merge pull request #33 from http-interop/patch-1
Update to match latest version of the PSR17 interface
2 parents d98211a + 0388002 commit 268656e

4 files changed

+23
-7
lines changed

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
],
1818
"require": {
1919
"http-interop/http-factory": "^0.4 || 1.0.x-dev",
20-
"phpunit/phpunit": "^5.7 || ^6.0 || ^7.0"
20+
"phpunit/phpunit": "^6.5 || ^7.0"
2121
},
2222
"autoload": {
2323
"psr-4": {

test/ServerRequestFactoryTestCase.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public function testCreateServerRequestFromArray(array $server)
8989
$method = $server['REQUEST_METHOD'];
9090
$uri = "http://{$server['HTTP_HOST']}{$server['REQUEST_URI']}?{$server['QUERY_STRING']}";
9191

92-
$request = $this->factory->createServerRequestFromArray($server);
92+
$request = $this->factory->createServerRequest($method, $uri, $server);
9393

9494
$this->assertServerRequest($request, $method, $uri);
9595
}
@@ -121,7 +121,7 @@ public function testCreateServerRequestDoesNotReadServerSuperglobal()
121121
'HTTP_HOST' => 'example.org',
122122
];
123123

124-
$request = $this->factory->createServerRequestFromArray($server);
124+
$request = $this->factory->createServerRequest('PUT', '/test', $server);
125125

126126
$serverParams = $request->getServerParams();
127127

test/UploadedFileFactoryTest.php

+12
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,16 @@ protected function createUploadedFileFactory()
1717

1818
return new $factoryClass();
1919
}
20+
21+
protected function createStream($content)
22+
{
23+
if (!defined('STREAM_FACTORY')) {
24+
$this->markTestSkipped('STREAM factory class name not provided');
25+
}
26+
27+
$factoryClass = STREAM_FACTORY;
28+
$uriFactory = new $factoryClass();
29+
30+
return $uriFactory->createStream($content);
31+
}
2032
}

test/UploadedFileFactoryTestCase.php

+8-4
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,11 @@
44

55
use Interop\Http\Factory\UploadedFileFactoryInterface;
66
use PHPUnit\Framework\TestCase;
7+
use Psr\Http\Message\StreamInterface;
78
use Psr\Http\Message\UploadedFileInterface;
89

910
abstract class UploadedFileFactoryTestCase extends TestCase
1011
{
11-
use StreamHelper;
12-
1312
/**
1413
* @var UploadedFileFactoryInterface
1514
*/
@@ -20,6 +19,11 @@ abstract class UploadedFileFactoryTestCase extends TestCase
2019
*/
2120
abstract protected function createUploadedFileFactory();
2221

22+
/**
23+
* @return StreamInterface
24+
*/
25+
abstract protected function createStream($content);
26+
2327
public function setUp()
2428
{
2529
$this->factory = $this->createUploadedFileFactory();
@@ -44,7 +48,7 @@ protected function assertUploadedFile(
4448
public function testCreateUploadedFileWithClientFilenameAndMediaType()
4549
{
4650
$content = 'this is your capitan speaking';
47-
$upload = $this->createTemporaryResource($content);
51+
$upload = $this->createStream($content);
4852
$error = UPLOAD_ERR_OK;
4953
$clientFilename = 'test.txt';
5054
$clientMediaType = 'text/plain';
@@ -56,7 +60,7 @@ public function testCreateUploadedFileWithClientFilenameAndMediaType()
5660

5761
public function testCreateUploadedFileWithError()
5862
{
59-
$upload = $this->createTemporaryResource();
63+
$upload = $this->createStream('foobar');
6064
$error = UPLOAD_ERR_NO_FILE;
6165

6266
$file = $this->factory->createUploadedFile($upload, null, $error);

0 commit comments

Comments
 (0)