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

Commit

Permalink
Merge branch 'hotfix/337' into develop
Browse files Browse the repository at this point in the history
Forward port #337
  • Loading branch information
weierophinney committed Dec 3, 2018
2 parents 059c226 + 2a1761c commit bab2c85
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 2 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ All notable changes to this project will be documented in this file, in reverse

### Fixed

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

## 2.0.0 - 2018-09-27

Expand Down
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());
$this->assertTrue($body->isSeekable());
$this->assertSame(0, $body->getSize());
}
}

0 comments on commit bab2c85

Please sign in to comment.