Skip to content

Commit 2539d9e

Browse files
authored
Merge pull request #364 from SimonFrings/tests
Run tests on PHPUnit 9 and clean up test suite
2 parents 390ca70 + 087c420 commit 2539d9e

21 files changed

+224
-221
lines changed

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ matrix:
1818
- php: 7.2
1919
- php: 7.3
2020
- php: 7.4
21-
- php: hhvm
21+
- php: hhvm-3.18
2222
allow_failures:
23-
- php: hhvm
23+
- php: hhvm-3.18
2424

2525
install:
2626
- composer install --no-interaction

composer.json

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,14 @@
1212
"evenement/evenement": "^3.0 || ^2.0 || ^1.0",
1313
"react/promise-stream": "^1.1"
1414
},
15-
"autoload": {
16-
"psr-4": {
17-
"React\\Http\\": "src"
18-
}
19-
},
2015
"require-dev": {
2116
"clue/block-react": "^1.1",
22-
"phpunit/phpunit": "^7.0 || ^6.4 || ^5.7 || ^4.8.35"
17+
"phpunit/phpunit": "^9.0 || ^5.7 || ^4.8.35"
18+
},
19+
"autoload": {
20+
"psr-4": { "React\\Http\\": "src" }
21+
},
22+
"autoload-dev": {
23+
"psr-4": { "React\\Tests\\Http\\": "tests" }
2324
}
2425
}

phpunit.xml.dist

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22

3-
<phpunit backupGlobals="false"
4-
backupStaticAttributes="false"
5-
colors="true"
6-
convertErrorsToExceptions="true"
7-
convertNoticesToExceptions="true"
8-
convertWarningsToExceptions="true"
9-
processIsolation="false"
10-
stopOnFailure="false"
11-
bootstrap="tests/bootstrap.php"
12-
>
3+
<phpunit bootstrap="vendor/autoload.php" colors="true">
134
<testsuites>
145
<testsuite name="React Test Suite">
156
<directory>./tests/</directory>

tests/CallableStub.php

Lines changed: 0 additions & 10 deletions
This file was deleted.

tests/FunctionalServerTest.php

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ public function testPlainHttpOnRandomPort()
4040

4141
$response = Block\await($result, $loop, 1.0);
4242

43-
$this->assertContains("HTTP/1.0 200 OK", $response);
44-
$this->assertContains('http://' . noScheme($socket->getAddress()) . '/', $response);
43+
$this->assertContainsString("HTTP/1.0 200 OK", $response);
44+
$this->assertContainsString('http://' . noScheme($socket->getAddress()) . '/', $response);
4545

4646
$socket->close();
4747
}
@@ -68,7 +68,7 @@ function () {
6868

6969
$response = Block\await($result, $loop, 1.0);
7070

71-
$this->assertContains("HTTP/1.0 404 Not Found", $response);
71+
$this->assertContainsString("HTTP/1.0 404 Not Found", $response);
7272

7373
$socket->close();
7474
}
@@ -93,8 +93,8 @@ public function testPlainHttpOnRandomPortWithoutHostHeaderUsesSocketUri()
9393

9494
$response = Block\await($result, $loop, 1.0);
9595

96-
$this->assertContains("HTTP/1.0 200 OK", $response);
97-
$this->assertContains('http://' . noScheme($socket->getAddress()) . '/', $response);
96+
$this->assertContainsString("HTTP/1.0 200 OK", $response);
97+
$this->assertContainsString('http://' . noScheme($socket->getAddress()) . '/', $response);
9898

9999
$socket->close();
100100
}
@@ -119,16 +119,16 @@ public function testPlainHttpOnRandomPortWithOtherHostHeaderTakesPrecedence()
119119

120120
$response = Block\await($result, $loop, 1.0);
121121

122-
$this->assertContains("HTTP/1.0 200 OK", $response);
123-
$this->assertContains('http://localhost:1000/', $response);
122+
$this->assertContainsString("HTTP/1.0 200 OK", $response);
123+
$this->assertContainsString('http://localhost:1000/', $response);
124124

125125
$socket->close();
126126
}
127127

128128
public function testSecureHttpsOnRandomPort()
129129
{
130-
if (!function_exists('stream_socket_enable_crypto')) {
131-
$this->markTestSkipped('Not supported on your platform (outdated HHVM?)');
130+
if (defined('HHVM_VERSION')) {
131+
$this->markTestSkipped('Not supported on HHVM');
132132
}
133133

134134
$loop = Factory::create();
@@ -154,16 +154,16 @@ public function testSecureHttpsOnRandomPort()
154154

155155
$response = Block\await($result, $loop, 1.0);
156156

157-
$this->assertContains("HTTP/1.0 200 OK", $response);
158-
$this->assertContains('https://' . noScheme($socket->getAddress()) . '/', $response);
157+
$this->assertContainsString("HTTP/1.0 200 OK", $response);
158+
$this->assertContainsString('https://' . noScheme($socket->getAddress()) . '/', $response);
159159

160160
$socket->close();
161161
}
162162

163163
public function testSecureHttpsReturnsData()
164164
{
165-
if (!function_exists('stream_socket_enable_crypto')) {
166-
$this->markTestSkipped('Not supported on your platform (outdated HHVM?)');
165+
if (defined('HHVM_VERSION')) {
166+
$this->markTestSkipped('Not supported on HHVM');
167167
}
168168

169169
$loop = Factory::create();
@@ -194,17 +194,17 @@ public function testSecureHttpsReturnsData()
194194

195195
$response = Block\await($result, $loop, 1.0);
196196

197-
$this->assertContains("HTTP/1.0 200 OK", $response);
198-
$this->assertContains("\r\nContent-Length: 33000\r\n", $response);
197+
$this->assertContainsString("HTTP/1.0 200 OK", $response);
198+
$this->assertContainsString("\r\nContent-Length: 33000\r\n", $response);
199199
$this->assertStringEndsWith("\r\n". str_repeat('.', 33000), $response);
200200

201201
$socket->close();
202202
}
203203

204204
public function testSecureHttpsOnRandomPortWithoutHostHeaderUsesSocketUri()
205205
{
206-
if (!function_exists('stream_socket_enable_crypto')) {
207-
$this->markTestSkipped('Not supported on your platform (outdated HHVM?)');
206+
if (defined('HHVM_VERSION')) {
207+
$this->markTestSkipped('Not supported on HHVM');
208208
}
209209

210210
$loop = Factory::create();
@@ -230,8 +230,8 @@ public function testSecureHttpsOnRandomPortWithoutHostHeaderUsesSocketUri()
230230

231231
$response = Block\await($result, $loop, 1.0);
232232

233-
$this->assertContains("HTTP/1.0 200 OK", $response);
234-
$this->assertContains('https://' . noScheme($socket->getAddress()) . '/', $response);
233+
$this->assertContainsString("HTTP/1.0 200 OK", $response);
234+
$this->assertContainsString('https://' . noScheme($socket->getAddress()) . '/', $response);
235235

236236
$socket->close();
237237
}
@@ -260,8 +260,8 @@ public function testPlainHttpOnStandardPortReturnsUriWithNoPort()
260260

261261
$response = Block\await($result, $loop, 1.0);
262262

263-
$this->assertContains("HTTP/1.0 200 OK", $response);
264-
$this->assertContains('http://127.0.0.1/', $response);
263+
$this->assertContainsString("HTTP/1.0 200 OK", $response);
264+
$this->assertContainsString('http://127.0.0.1/', $response);
265265

266266
$socket->close();
267267
}
@@ -290,8 +290,8 @@ public function testPlainHttpOnStandardPortWithoutHostHeaderReturnsUriWithNoPort
290290

291291
$response = Block\await($result, $loop, 1.0);
292292

293-
$this->assertContains("HTTP/1.0 200 OK", $response);
294-
$this->assertContains('http://127.0.0.1/', $response);
293+
$this->assertContainsString("HTTP/1.0 200 OK", $response);
294+
$this->assertContainsString('http://127.0.0.1/', $response);
295295

296296
$socket->close();
297297
}
@@ -329,8 +329,8 @@ public function testSecureHttpsOnStandardPortReturnsUriWithNoPort()
329329

330330
$response = Block\await($result, $loop, 1.0);
331331

332-
$this->assertContains("HTTP/1.0 200 OK", $response);
333-
$this->assertContains('https://127.0.0.1/', $response);
332+
$this->assertContainsString("HTTP/1.0 200 OK", $response);
333+
$this->assertContainsString('https://127.0.0.1/', $response);
334334

335335
$socket->close();
336336
}
@@ -368,8 +368,8 @@ public function testSecureHttpsOnStandardPortWithoutHostHeaderUsesSocketUri()
368368

369369
$response = Block\await($result, $loop, 1.0);
370370

371-
$this->assertContains("HTTP/1.0 200 OK", $response);
372-
$this->assertContains('https://127.0.0.1/', $response);
371+
$this->assertContainsString("HTTP/1.0 200 OK", $response);
372+
$this->assertContainsString('https://127.0.0.1/', $response);
373373

374374
$socket->close();
375375
}
@@ -398,8 +398,8 @@ public function testPlainHttpOnHttpsStandardPortReturnsUriWithPort()
398398

399399
$response = Block\await($result, $loop, 1.0);
400400

401-
$this->assertContains("HTTP/1.0 200 OK", $response);
402-
$this->assertContains('http://127.0.0.1:443/', $response);
401+
$this->assertContainsString("HTTP/1.0 200 OK", $response);
402+
$this->assertContainsString('http://127.0.0.1:443/', $response);
403403

404404
$socket->close();
405405
}
@@ -437,8 +437,8 @@ public function testSecureHttpsOnHttpStandardPortReturnsUriWithPort()
437437

438438
$response = Block\await($result, $loop, 1.0);
439439

440-
$this->assertContains("HTTP/1.0 200 OK", $response);
441-
$this->assertContains('https://127.0.0.1:80/', $response);
440+
$this->assertContainsString("HTTP/1.0 200 OK", $response);
441+
$this->assertContainsString('https://127.0.0.1:80/', $response);
442442

443443
$socket->close();
444444
}
@@ -784,7 +784,7 @@ function (ServerRequestInterface $request) {
784784
$responses = Block\await(Promise\all($result), $loop, 1.0);
785785

786786
foreach ($responses as $response) {
787-
$this->assertContains("HTTP/1.0 200 OK", $response, $response);
787+
$this->assertContainsString("HTTP/1.0 200 OK", $response, $response);
788788
$this->assertTrue(substr($response, -4) == 1024, $response);
789789
}
790790

tests/Io/ChunkedDecoderTest.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@
88

99
class ChunkedDecoderTest extends TestCase
1010
{
11-
public function setUp()
11+
12+
/**
13+
* @before
14+
*/
15+
public function setUpParser()
1216
{
1317
$this->input = new ThroughStream();
1418
$this->parser = new ChunkedDecoder($this->input);

tests/Io/ChunkedEncoderTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@ class ChunkedEncoderTest extends TestCase
1111
private $input;
1212
private $chunkedStream;
1313

14-
public function setUp()
14+
/**
15+
* @before
16+
*/
17+
public function setUpChunkedStream()
1518
{
1619
$this->input = new ThroughStream();
1720
$this->chunkedStream = new ChunkedEncoder($this->input);

tests/Io/EmptyBodyStreamTest.php

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@ class EmptyBodyStreamTest extends TestCase
1010
private $input;
1111
private $bodyStream;
1212

13-
public function setUp()
13+
/**
14+
* @before
15+
*/
16+
public function setUpBodyStream()
1417
{
1518
$this->bodyStream = new EmptyBodyStream();
1619
}
@@ -65,19 +68,15 @@ public function testCloseTwiceEmitsCloseEventAndClearsListeners()
6568
$this->assertEquals(array(), $this->bodyStream->listeners('close'));
6669
}
6770

68-
/**
69-
* @expectedException BadMethodCallException
70-
*/
7171
public function testTell()
7272
{
73+
$this->setExpectedException('BadMethodCallException');
7374
$this->bodyStream->tell();
7475
}
7576

76-
/**
77-
* @expectedException BadMethodCallException
78-
*/
7977
public function testEof()
8078
{
79+
$this->setExpectedException('BadMethodCallException');
8180
$this->bodyStream->eof();
8281
}
8382

@@ -86,19 +85,15 @@ public function testIsSeekable()
8685
$this->assertFalse($this->bodyStream->isSeekable());
8786
}
8887

89-
/**
90-
* @expectedException BadMethodCallException
91-
*/
9288
public function testWrite()
9389
{
90+
$this->setExpectedException('BadMethodCallException');
9491
$this->bodyStream->write('');
9592
}
9693

97-
/**
98-
* @expectedException BadMethodCallException
99-
*/
10094
public function testRead()
10195
{
96+
$this->setExpectedException('BadMethodCallException');
10297
$this->bodyStream->read(1);
10398
}
10499

@@ -129,19 +124,15 @@ public function testIsReadableReturnsFalseWhenAlreadyClosed()
129124
$this->assertFalse($this->bodyStream->isReadable());
130125
}
131126

132-
/**
133-
* @expectedException BadMethodCallException
134-
*/
135127
public function testSeek()
136128
{
129+
$this->setExpectedException('BadMethodCallException');
137130
$this->bodyStream->seek('');
138131
}
139132

140-
/**
141-
* @expectedException BadMethodCallException
142-
*/
143133
public function testRewind()
144134
{
135+
$this->setExpectedException('BadMethodCallException');
145136
$this->bodyStream->rewind();
146137
}
147138

0 commit comments

Comments
 (0)