function testDoRequestCurlError() { $client = new ClientMock(); $request = new Request('GET', 'http://example.org/'); $client->on('curlExec', function (&$return) { $return = ""; }); $client->on('curlStuff', function (&$return) { $return = [[], 1, 'Curl error']; }); try { $response = $client->doRequest($request); $this->fail('This should have thrown an exception'); } catch (ClientException $e) { $this->assertEquals(1, $e->getCode()); $this->assertEquals('Curl error', $e->getMessage()); } }