Skip to content

Commit

Permalink
Merge pull request #33 from http-interop/patch-1
Browse files Browse the repository at this point in the history
Update to match latest version of the PSR17 interface
  • Loading branch information
Nyholm authored Jul 17, 2018
2 parents d98211a + 0388002 commit 268656e
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 7 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
],
"require": {
"http-interop/http-factory": "^0.4 || 1.0.x-dev",
"phpunit/phpunit": "^5.7 || ^6.0 || ^7.0"
"phpunit/phpunit": "^6.5 || ^7.0"
},
"autoload": {
"psr-4": {
Expand Down
4 changes: 2 additions & 2 deletions test/ServerRequestFactoryTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public function testCreateServerRequestFromArray(array $server)
$method = $server['REQUEST_METHOD'];
$uri = "http://{$server['HTTP_HOST']}{$server['REQUEST_URI']}?{$server['QUERY_STRING']}";

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

$this->assertServerRequest($request, $method, $uri);
}
Expand Down Expand Up @@ -121,7 +121,7 @@ public function testCreateServerRequestDoesNotReadServerSuperglobal()
'HTTP_HOST' => 'example.org',
];

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

$serverParams = $request->getServerParams();

Expand Down
12 changes: 12 additions & 0 deletions test/UploadedFileFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,16 @@ protected function createUploadedFileFactory()

return new $factoryClass();
}

protected function createStream($content)
{
if (!defined('STREAM_FACTORY')) {
$this->markTestSkipped('STREAM factory class name not provided');
}

$factoryClass = STREAM_FACTORY;
$uriFactory = new $factoryClass();

return $uriFactory->createStream($content);
}
}
12 changes: 8 additions & 4 deletions test/UploadedFileFactoryTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@

use Interop\Http\Factory\UploadedFileFactoryInterface;
use PHPUnit\Framework\TestCase;
use Psr\Http\Message\StreamInterface;
use Psr\Http\Message\UploadedFileInterface;

abstract class UploadedFileFactoryTestCase extends TestCase
{
use StreamHelper;

/**
* @var UploadedFileFactoryInterface
*/
Expand All @@ -20,6 +19,11 @@ abstract class UploadedFileFactoryTestCase extends TestCase
*/
abstract protected function createUploadedFileFactory();

/**
* @return StreamInterface
*/
abstract protected function createStream($content);

public function setUp()
{
$this->factory = $this->createUploadedFileFactory();
Expand All @@ -44,7 +48,7 @@ protected function assertUploadedFile(
public function testCreateUploadedFileWithClientFilenameAndMediaType()
{
$content = 'this is your capitan speaking';
$upload = $this->createTemporaryResource($content);
$upload = $this->createStream($content);
$error = UPLOAD_ERR_OK;
$clientFilename = 'test.txt';
$clientMediaType = 'text/plain';
Expand All @@ -56,7 +60,7 @@ public function testCreateUploadedFileWithClientFilenameAndMediaType()

public function testCreateUploadedFileWithError()
{
$upload = $this->createTemporaryResource();
$upload = $this->createStream('foobar');
$error = UPLOAD_ERR_NO_FILE;

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

0 comments on commit 268656e

Please sign in to comment.