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

Commit af9ff00

Browse files
committed
Merge branch 'hotfix/50'
Close #50
2 parents d3e7fe3 + 9377faa commit af9ff00

File tree

8 files changed

+70
-29
lines changed

8 files changed

+70
-29
lines changed

test/MessageTraitTest.php

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,19 @@
1010
namespace ZendTest\Diactoros;
1111

1212
use PHPUnit_Framework_TestCase as TestCase;
13+
use Psr\Http\Message\MessageInterface;
1314
use Zend\Diactoros\Request;
14-
use Zend\Diactoros\Stream;
1515

1616
class MessageTraitTest extends TestCase
1717
{
18+
/**
19+
* @var MessageInterface
20+
*/
21+
protected $message;
22+
1823
public function setUp()
1924
{
20-
$this->stream = new Stream('php://memory', 'wb+');
21-
$this->message = new Request(null, null, $this->stream);
25+
$this->message = new Request(null, null, $this->getMock('Psr\Http\Message\StreamInterface'));
2226
}
2327

2428
public function testProtocolHasAcceptableDefault()
@@ -35,12 +39,14 @@ public function testProtocolMutatorReturnsCloneWithChanges()
3539

3640
public function testUsesStreamProvidedInConstructorAsBody()
3741
{
38-
$this->assertSame($this->stream, $this->message->getBody());
42+
$stream = $this->getMock('Psr\Http\Message\StreamInterface');
43+
$message = new Request(null, null, $stream);
44+
$this->assertSame($stream, $message->getBody());
3945
}
4046

4147
public function testBodyMutatorReturnsCloneWithChanges()
4248
{
43-
$stream = new Stream('php://memory', 'wb+');
49+
$stream = $this->getMock('Psr\Http\Message\StreamInterface');
4450
$message = $this->message->withBody($stream);
4551
$this->assertNotSame($this->message, $message);
4652
$this->assertSame($stream, $message->getBody());
@@ -189,8 +195,8 @@ public function testWithoutHeaderDoesNothingIfHeaderDoesNotExist()
189195
public function testHeadersInitialization()
190196
{
191197
$headers = ['X-Foo' => ['bar']];
192-
$this->message = new Request(null, null, $this->stream, $headers);
193-
$this->assertSame($headers, $this->message->getHeaders());
198+
$message = new Request(null, null, 'php://temp', $headers);
199+
$this->assertSame($headers, $message->getHeaders());
194200
}
195201

196202
public function testGetHeaderReturnsAnEmptyArrayWhenHeaderDoesNotExist()

test/PhpInputStreamTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,16 @@
1414

1515
class PhpInputStreamTest extends TestCase
1616
{
17+
/**
18+
* @var string
19+
*/
20+
protected $file;
21+
22+
/**
23+
* @var PhpInputStream
24+
*/
25+
protected $stream;
26+
1727
public function setUp()
1828
{
1929
$this->file = __DIR__ . '/TestAsset/php-input-stream.txt';

test/RequestTest.php

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@
1616

1717
class RequestTest extends TestCase
1818
{
19+
/**
20+
* @var Request
21+
*/
22+
protected $request;
23+
1924
public function setUp()
2025
{
2126
$this->request = new Request();
@@ -44,19 +49,6 @@ public function testConstructorRaisesExceptionForInvalidStream()
4449
new Request(['TOTALLY INVALID']);
4550
}
4651

47-
public function invalidUrls()
48-
{
49-
return [
50-
'null' => [null],
51-
'true' => [true],
52-
'false' => [false],
53-
'int' => [1],
54-
'float' => [1.1],
55-
'array' => [['foo']],
56-
'object' => [(object) ['foo']],
57-
];
58-
}
59-
6052
public function testWithUriReturnsNewInstanceWithNewUri()
6153
{
6254
$request = $this->request->withUri(new Uri('https://example.com:10082/foo/bar?baz=bat'));

test/Response/SapiEmitterTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@
1717

1818
class SapiEmitterTest extends TestCase
1919
{
20+
/**
21+
* @var SapiEmitter
22+
*/
23+
protected $emitter;
24+
2025
public function setUp()
2126
{
2227
HeaderStack::reset();

test/ResponseTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@
1515

1616
class ResponseTest extends TestCase
1717
{
18+
/**
19+
* @var Response
20+
*/
21+
protected $response;
22+
1823
public function setUp()
1924
{
2025
$this->response = new Response();

test/ServerRequestTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@
1717

1818
class ServerRequestTest extends TestCase
1919
{
20+
/**
21+
* @var ServerRequest
22+
*/
23+
protected $request;
24+
2025
public function setUp()
2126
{
2227
$this->request = new ServerRequest();

test/ServerTest.php

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,37 @@
1010
namespace ZendTest\Diactoros;
1111

1212
use PHPUnit_Framework_TestCase as TestCase;
13+
use Psr\Http\Message\ResponseInterface;
14+
use Psr\Http\Message\ServerRequestInterface;
1315
use Zend\Diactoros\Server;
1416
use ZendTest\Diactoros\TestAsset\HeaderStack;
1517

1618
class ServerTest extends TestCase
1719
{
20+
/**
21+
* @var Callable
22+
*/
23+
protected $callback;
24+
25+
/**
26+
* @var ServerRequestInterface|\PHPUnit_Framework_MockObject_MockObject
27+
*/
28+
protected $request;
29+
30+
/**
31+
* @var ResponseInterface|\PHPUnit_Framework_MockObject_MockObject
32+
*/
33+
protected $response;
34+
1835
public function setUp()
1936
{
2037
HeaderStack::reset();
2138

2239
$this->callback = function ($req, $res, $done) {
2340
// Intentionally empty
2441
};
25-
$this->request = $this
26-
->getMockBuilder('Psr\Http\Message\ServerRequestInterface')
27-
->getMock();
28-
$this->response = $this
29-
->getMockBuilder('Psr\Http\Message\ResponseInterface')
30-
->getMock();
42+
$this->request = $this->getMock('Psr\Http\Message\ServerRequestInterface');
43+
$this->response = $this->getMock('Psr\Http\Message\ResponseInterface');
3144
}
3245

3346
public function tearDown()
@@ -129,7 +142,7 @@ public function testListenEmitsStatusHeaderWithoutReasonPhraseIfNoReasonPhrase()
129142
'QUERY_STRING' => 'bar=baz',
130143
];
131144

132-
$callback = function ($req, $res) {
145+
$callback = function (ServerRequestInterface $req, ResponseInterface $res) {
133146
$res = $res->withStatus(299);
134147
$res = $res->withAddedHeader('Content-Type', 'text/plain');
135148
$res->getBody()->write('FOOBAR');
@@ -155,7 +168,7 @@ public function testEnsurePercentCharactersDoNotResultInOutputError()
155168
'QUERY_STRING' => 'bar=baz',
156169
];
157170

158-
$callback = function ($req, $res) {
171+
$callback = function (ServerRequestInterface $req, ResponseInterface $res) {
159172
$res = $res->withAddedHeader('Content-Type', 'text/plain');
160173
$res->getBody()->write('100%');
161174
return $res;
@@ -178,7 +191,7 @@ public function testEmitsHeadersWithMultipleValuesMultipleTimes()
178191
'REQUEST_URI' => '/foo/bar',
179192
];
180193

181-
$callback = function ($req, $res) {
194+
$callback = function (ServerRequestInterface $req, ResponseInterface $res) {
182195
$res = $res->withAddedHeader('Content-Type', 'text/plain');
183196
$res = $res->withAddedHeader(
184197
'Set-Cookie',

test/StreamTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ class StreamTest extends TestCase
1717
{
1818
public $tmpnam;
1919

20+
/**
21+
* @var Stream
22+
*/
23+
protected $stream;
24+
2025
public function setUp()
2126
{
2227
$this->tmpnam = null;

0 commit comments

Comments
 (0)