Skip to content

Commit d3b7511

Browse files
committed
Run tests on PHPUnit 9
1 parent 390ca70 commit d3b7511

16 files changed

+198
-178
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@
1919
},
2020
"require-dev": {
2121
"clue/block-react": "^1.1",
22-
"phpunit/phpunit": "^7.0 || ^6.4 || ^5.7 || ^4.8.35"
22+
"phpunit/phpunit": "^9.0 || ^5.7 || ^4.8.35"
2323
}
2424
}

tests/FunctionalServerTest.php

Lines changed: 26 additions & 26 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,8 +119,8 @@ 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
}
@@ -154,8 +154,8 @@ 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
}
@@ -194,8 +194,8 @@ 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();
@@ -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

tests/Io/HttpBodyStreamTest.php

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

14-
public function setUp()
14+
/**
15+
* @before
16+
*/
17+
public function setUpBodyStream()
1518
{
1619
$this->input = new ThroughStream();
1720
$this->bodyStream = new HttpBodyStream($this->input, null);
@@ -102,19 +105,15 @@ public function testGetSizeCustom()
102105
$this->assertEquals(5, $stream->getSize());
103106
}
104107

105-
/**
106-
* @expectedException BadMethodCallException
107-
*/
108108
public function testTell()
109109
{
110+
$this->setExpectedException('BadMethodCallException');
110111
$this->bodyStream->tell();
111112
}
112113

113-
/**
114-
* @expectedException BadMethodCallException
115-
*/
116114
public function testEof()
117115
{
116+
$this->setExpectedException('BadMethodCallException');
118117
$this->bodyStream->eof();
119118
}
120119

@@ -123,19 +122,15 @@ public function testIsSeekable()
123122
$this->assertFalse($this->bodyStream->isSeekable());
124123
}
125124

126-
/**
127-
* @expectedException BadMethodCallException
128-
*/
129125
public function testWrite()
130126
{
127+
$this->setExpectedException('BadMethodCallException');
131128
$this->bodyStream->write('');
132129
}
133130

134-
/**
135-
* @expectedException BadMethodCallException
136-
*/
137131
public function testRead()
138132
{
133+
$this->setExpectedException('BadMethodCallException');
139134
$this->bodyStream->read('');
140135
}
141136

@@ -154,19 +149,15 @@ public function testIsReadable()
154149
$this->assertTrue($this->bodyStream->isReadable());
155150
}
156151

157-
/**
158-
* @expectedException BadMethodCallException
159-
*/
160152
public function testSeek()
161153
{
154+
$this->setExpectedException('BadMethodCallException');
162155
$this->bodyStream->seek('');
163156
}
164157

165-
/**
166-
* @expectedException BadMethodCallException
167-
*/
168158
public function testRewind()
169159
{
160+
$this->setExpectedException('BadMethodCallException');
170161
$this->bodyStream->rewind();
171162
}
172163

tests/Io/IniUtilTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,10 @@ public function provideInvalidInputIniSizeToBytes()
6868

6969
/**
7070
* @dataProvider provideInvalidInputIniSizeToBytes
71-
* @expectedException InvalidArgumentException
7271
*/
7372
public function testInvalidInputIniSizeToBytes($input)
7473
{
74+
$this->setExpectedException('InvalidArgumentException');
7575
IniUtil::iniSizeToBytes($input);
7676
}
7777
}

tests/Io/LengthLimitedStreamTest.php

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

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

0 commit comments

Comments
 (0)