debug(true); $request = $app->request->withServer(['HTTP_ACCEPT' => 'application/json']); $app->instance('request', $request); $handler = new WorkerExceptionHandle($app); $previous = ini_get('zend.exception_ignore_args'); ini_set('zend.exception_ignore_args', '0'); $stream = fopen('php://memory', 'r'); try { try { $this->throwWithResource($stream); $this->fail('Expected runtime exception was not thrown.'); } catch (\RuntimeException $exception) { if (empty($exception->getTrace()[0]['args'] ?? [])) { $this->markTestSkipped('Exception arguments are unavailable in this PHP configuration.'); } $content = $handler->render($request, $exception)->getContent(); } } finally { if (is_resource($stream)) { fclose($stream); } if ($previous !== false) { ini_set('zend.exception_ignore_args', $previous); } } $this->assertJson($content); $this->assertStringContainsString('"message":"worker boom"', $content); $this->assertStringContainsString('[resource(stream)]', $content); } private function throwWithResource($stream): void { throw new \RuntimeException('worker boom'); } }