diff --git a/src/Client.php b/src/Client.php index 5350b54..83970e6 100644 --- a/src/Client.php +++ b/src/Client.php @@ -200,11 +200,11 @@ function (Exception $e) use ($uri, $deferred) { // Exception trace arguments are not available on some PHP 7.4 installs // @codeCoverageIgnoreStart - foreach ($trace as &$one) { + foreach ($trace as $ti => $one) { if (isset($one['args'])) { - foreach ($one['args'] as &$arg) { + foreach ($one['args'] as $ai => $arg) { if ($arg instanceof \Closure) { - $arg = 'Object(' . \get_class($arg) . ')'; + $trace[$ti]['args'][$ai] = 'Object(' . \get_class($arg) . ')'; } } } diff --git a/tests/ClientTest.php b/tests/ClientTest.php index 90451fb..e0e3520 100644 --- a/tests/ClientTest.php +++ b/tests/ClientTest.php @@ -173,11 +173,17 @@ public function testConnectorRejectsWillRejectConnection() $promise = $this->client->connect('google.com:80'); - $promise->then(null, $this->expectCallableOnceWithException( - 'RuntimeException', - 'Connection to tcp://google.com:80 failed because connection to proxy failed (ECONNREFUSED)', - defined('SOCKET_ECONNREFUSED') ? SOCKET_ECONNREFUSED : 111 - )); + $exception = null; + $promise->then(null, function ($reason) use (&$exception) { + $exception = $reason; + }); + + assert($exception instanceof \RuntimeException); + $this->assertInstanceOf('RuntimeException', $exception); + $this->assertEquals('Connection to tcp://google.com:80 failed because connection to proxy failed (ECONNREFUSED)', $exception->getMessage()); + $this->assertEquals(defined('SOCKET_ECONNREFUSED') ? SOCKET_ECONNREFUSED : 111, $exception->getCode()); + $this->assertInstanceOf('RuntimeException', $exception->getPrevious()); + $this->assertNotEquals('', $exception->getTraceAsString()); } public function testCancelConnectionDuringConnectionWillCancelConnection()