1414
1515class HttpServerRunnerTest extends TestCase
1616{
17- public function testRunWillReportDefaultListeningAddressAndRunLoop (): void
17+ public function testInvokeWillReportDefaultListeningAddressAndRunLoop (): void
1818 {
1919 $ socket = @stream_socket_server ('127.0.0.1:8080 ' );
2020 if ($ socket === false ) {
@@ -41,10 +41,12 @@ public function testRunWillReportDefaultListeningAddressAndRunLoop(): void
4141 Loop::stop ();
4242 });
4343
44- $ runner ->run (function (): void { });
44+ $ runner (function (): void {
45+ throw new \BadFunctionCallException ('Should not be reached ' );
46+ });
4547 }
4648
47- public function testRunWillReportGivenListeningAddressAndRunLoop (): void
49+ public function testInvokeWillReportGivenListeningAddressAndRunLoop (): void
4850 {
4951 $ socket = stream_socket_server ('127.0.0.1:0 ' );
5052 assert (is_resource ($ socket ));
@@ -70,10 +72,12 @@ public function testRunWillReportGivenListeningAddressAndRunLoop(): void
7072 Loop::stop ();
7173 });
7274
73- $ runner ->run (function (): void { });
75+ $ runner (function (): void {
76+ throw new \BadFunctionCallException ('Should not be reached ' );
77+ });
7478 }
7579
76- public function testRunWillReportGivenListeningAddressWithRandomPortAndRunLoop (): void
80+ public function testInvokeWillReportGivenListeningAddressWithRandomPortAndRunLoop (): void
7781 {
7882 $ logger = $ this ->createMock (LogStreamHandler::class);
7983 $ logger ->expects ($ this ->atLeastOnce ())->method ('log ' )->withConsecutive ([$ this ->matches ('Listening on http://127.0.0.1:%d ' )]);
@@ -93,10 +97,12 @@ public function testRunWillReportGivenListeningAddressWithRandomPortAndRunLoop()
9397 Loop::stop ();
9498 });
9599
96- $ runner ->run (function (): void { });
100+ $ runner (function (): void {
101+ throw new \BadFunctionCallException ('Should not be reached ' );
102+ });
97103 }
98104
99- public function testRunWillRestartLoopUntilSocketIsClosed (): void
105+ public function testInvokeWillRestartLoopUntilSocketIsClosed (): void
100106 {
101107 $ logger = $ this ->createMock (LogStreamHandler::class);
102108 assert ($ logger instanceof LogStreamHandler);
@@ -120,10 +126,12 @@ public function testRunWillRestartLoopUntilSocketIsClosed(): void
120126 Loop::stop ();
121127 });
122128
123- $ runner ->run (function (): void { });
129+ $ runner (function (): void {
130+ throw new \BadFunctionCallException ('Should not be reached ' );
131+ });
124132 }
125133
126- public function testRunWillListenForHttpRequestAndSendBackHttpResponseOverSocket (): void
134+ public function testInvokeWillListenForHttpRequestAndSendBackHttpResponseOverSocket (): void
127135 {
128136 $ socket = stream_socket_server ('127.0.0.1:0 ' );
129137 assert (is_resource ($ socket ));
@@ -163,12 +171,12 @@ public function testRunWillListenForHttpRequestAndSendBackHttpResponseOverSocket
163171 });
164172 });
165173
166- $ runner-> run (function (): Response {
174+ $ runner (function (): Response {
167175 return new Response (200 , ['Date ' => '' , 'Server ' => '' ], "OK \n" );
168176 });
169177 }
170178
171- public function testRunWillOnlyRestartLoopAfterAwaitingWhenFibersAreNotAvailable (): void
179+ public function testInvokeWillOnlyRestartLoopAfterAwaitingWhenFibersAreNotAvailable (): void
172180 {
173181 $ socket = stream_socket_server ('127.0.0.1:0 ' );
174182 assert (is_resource ($ socket ));
@@ -216,7 +224,7 @@ public function testRunWillOnlyRestartLoopAfterAwaitingWhenFibersAreNotAvailable
216224 });
217225
218226 $ done = false ;
219- $ runner-> run (function () use (&$ done ): Response {
227+ $ runner (function () use (&$ done ): Response {
220228 $ promise = new Promise (function (callable $ resolve ) use (&$ done ): void {
221229 Loop::futureTick (function () use ($ resolve , &$ done ): void {
222230 $ resolve (null );
@@ -232,7 +240,7 @@ public function testRunWillOnlyRestartLoopAfterAwaitingWhenFibersAreNotAvailable
232240 $ this ->assertTrue ($ done );
233241 }
234242
235- public function testRunWillReportHttpErrorForInvalidClientRequest (): void
243+ public function testInvokeWillReportHttpErrorForInvalidClientRequest (): void
236244 {
237245 $ socket = stream_socket_server ('127.0.0.1:0 ' );
238246 assert (is_resource ($ socket ));
@@ -269,14 +277,16 @@ public function testRunWillReportHttpErrorForInvalidClientRequest(): void
269277 });
270278 });
271279
272- $ runner ->run (function (): void { });
280+ $ runner (function (): void {
281+ throw new \BadFunctionCallException ('Should not be reached ' );
282+ });
273283 }
274284
275285 /**
276286 * @requires function pcntl_signal
277287 * @requires function posix_kill
278288 */
279- public function testRunWillStopWhenReceivingSigint (): void
289+ public function testInvokeWillStopWhenReceivingSigint (): void
280290 {
281291 $ logger = $ this ->createMock (LogStreamHandler::class);
282292 $ logger ->expects ($ this ->exactly (2 ))->method ('log ' );
@@ -293,14 +303,16 @@ public function testRunWillStopWhenReceivingSigint(): void
293303 });
294304
295305 $ this ->expectOutputRegex ("#^ \r?$# " );
296- $ runner ->run (function (): void { });
306+ $ runner (function (): void {
307+ throw new \BadFunctionCallException ('Should not be reached ' );
308+ });
297309 }
298310
299311 /**
300312 * @requires function pcntl_signal
301313 * @requires function posix_kill
302314 */
303- public function testRunWillStopWhenReceivingSigterm (): void
315+ public function testInvokeWillStopWhenReceivingSigterm (): void
304316 {
305317 $ logger = $ this ->createMock (LogStreamHandler::class);
306318 assert ($ logger instanceof LogStreamHandler);
@@ -315,21 +327,25 @@ public function testRunWillStopWhenReceivingSigterm(): void
315327 posix_kill ($ pid , defined ('SIGTERM ' ) ? SIGTERM : 15 );
316328 });
317329
318- $ runner ->run (function (): void { });
330+ $ runner (function (): void {
331+ throw new \BadFunctionCallException ('Should not be reached ' );
332+ });
319333 }
320334
321- public function testRunWithEmptyAddressThrows (): void
335+ public function testInvokeWithEmptyAddressThrows (): void
322336 {
323337 $ logger = $ this ->createMock (LogStreamHandler::class);
324338 assert ($ logger instanceof LogStreamHandler);
325339
326340 $ runner = new HttpServerRunner ($ logger , '' );
327341
328342 $ this ->expectException (\InvalidArgumentException::class);
329- $ runner ->run (function (): void { });
343+ $ runner (function (): void {
344+ throw new \BadFunctionCallException ('Should not be reached ' );
345+ });
330346 }
331347
332- public function testRunWithBusyPortThrows (): void
348+ public function testInvokeWithBusyPortThrows (): void
333349 {
334350 $ socket = stream_socket_server ('127.0.0.1:0 ' );
335351 assert (is_resource ($ socket ));
@@ -347,6 +363,8 @@ public function testRunWithBusyPortThrows(): void
347363
348364 $ this ->expectException (\RuntimeException::class);
349365 $ this ->expectExceptionMessage ('Failed to listen on ' );
350- $ runner ->run (function (): void { });
366+ $ runner (function (): void {
367+ throw new \BadFunctionCallException ('Should not be reached ' );
368+ });
351369 }
352370}
0 commit comments