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

Commit 31ac8de

Browse files
committed
Merge pull request #337 from oscarotero/patch-1
Fixed serverRequest factory
2 parents f768c53 + 4570b57 commit 31ac8de

File tree

3 files changed

+34
-1
lines changed

3 files changed

+34
-1
lines changed

src/ServerRequestFactory.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,8 @@ public function createServerRequest(string $method, $uri, array $serverParams =
9292
$serverParams,
9393
$uploadedFiles,
9494
$uri,
95-
$method
95+
$method,
96+
'php://temp'
9697
);
9798
}
9899
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
/**
3+
* @see https://github.com/zendframework/zend-diactoros for the canonical source repository
4+
* @copyright Copyright (c) 2018 Zend Technologies USA Inc. (https://www.zend.com)
5+
* @license https://github.com/zendframework/zend-diactoros/blob/master/LICENSE.md New BSD License
6+
*/
7+
8+
declare(strict_types=1);
9+
10+
namespace ZendTest\Diactoros\Integration;
11+
12+
use Http\Psr7Test\ServerRequestIntegrationTest;
13+
use Zend\Diactoros\ServerRequestFactory;
14+
15+
class ServerRequestFactoryTest extends ServerRequestIntegrationTest
16+
{
17+
public function createSubject()
18+
{
19+
return (new ServerRequestFactory())->createServerRequest('GET', '/', $_SERVER);
20+
}
21+
}

test/ServerRequestFactoryTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -570,4 +570,15 @@ public function testMarshalRequestUriPrefersRequestUriServerParamWhenXOriginalUr
570570
$uri = marshalUriFromSapi($server, $headers);
571571
$this->assertSame('/requested/path', $uri->getPath());
572572
}
573+
574+
public function testServerRequestFactoryHasAWritableEmptyBody()
575+
{
576+
$factory = new ServerRequestFactory();
577+
$request = $factory->createServerRequest('GET', '/');
578+
$body = $request->getBody();
579+
580+
$this->assertTrue($body->isWritable());
581+
$this->assertTrue($body->isSeekable());
582+
$this->assertSame(0, $body->getSize());
583+
}
573584
}

0 commit comments

Comments
 (0)