public function testInvokesOnStatsOnError()
{
$req = new Psr7\Request('GET', 'http://127.0.0.1:123');
$gotStats = null;
$handler = new Handler\CurlHandler();
$promise = $handler($req, ['connect_timeout' => 0.001, 'timeout' => 0.001, 'on_stats' => function (TransferStats $stats) use(&$gotStats) {
$gotStats = $stats;
}]);
$promise->wait(false);
$this->assertFalse($gotStats->hasResponse());
$this->assertEquals('http://127.0.0.1:123', $gotStats->getEffectiveUri());
$this->assertEquals('http://127.0.0.1:123', $gotStats->getRequest()->getUri());
$this->assertInternalType('float', $gotStats->getTransferTime());
$this->assertInternalType('int', $gotStats->getHandlerErrorData());
}