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

Commit bab2c85

Browse files
committed
Merge branch 'hotfix/337' into develop
Forward port #337
2 parents 059c226 + 2a1761c commit bab2c85

File tree

4 files changed

+37
-2
lines changed

4 files changed

+37
-2
lines changed

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@ All notable changes to this project will be documented in this file, in reverse
4444

4545
### Fixed
4646

47-
- Nothing.
47+
- [#337](https://github.com/zendframework/zend-diactoros/pull/337) ensures that the `ServerRequestFactory::createServerRequest()` method
48+
creates a `php://temp` stream instead of a `php::input` stream, in compliance
49+
with the PSR-17 specification.
4850

4951
## 2.0.0 - 2018-09-27
5052

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)