Skip to content
This repository has been archived by the owner on Jan 29, 2020. It is now read-only.

Fixed serverRequest factory #337

Merged
merged 2 commits into from
Dec 3, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/ServerRequestFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ public function createServerRequest(string $method, $uri, array $serverParams =
$serverParams,
$uploadedFiles,
$uri,
$method
$method,
'php://temp'
);
}
}
21 changes: 21 additions & 0 deletions test/Integration/ServerRequestFactoryTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php
/**
* @see https://github.com/zendframework/zend-diactoros for the canonical source repository
* @copyright Copyright (c) 2018 Zend Technologies USA Inc. (https://www.zend.com)
* @license https://github.com/zendframework/zend-diactoros/blob/master/LICENSE.md New BSD License
*/

declare(strict_types=1);

namespace ZendTest\Diactoros\Integration;

use Http\Psr7Test\ServerRequestIntegrationTest;
use Zend\Diactoros\ServerRequestFactory;

class ServerRequestFactoryTest extends ServerRequestIntegrationTest
{
public function createSubject()
{
return (new ServerRequestFactory())->createServerRequest('GET', '/', $_SERVER);
}
}
11 changes: 11 additions & 0 deletions test/ServerRequestFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -570,4 +570,15 @@ public function testMarshalRequestUriPrefersRequestUriServerParamWhenXOriginalUr
$uri = marshalUriFromSapi($server, $headers);
$this->assertSame('/requested/path', $uri->getPath());
}

public function testServerRequestFactoryHasAWritableEmptyBody()
{
$factory = new ServerRequestFactory();
$request = $factory->createServerRequest('GET', '/');
$body = $request->getBody();

$this->assertTrue($body->isWritable());
Ocramius marked this conversation as resolved.
Show resolved Hide resolved
$this->assertTrue($body->isSeekable());
$this->assertSame(0, $body->getSize());
}
}