public function testAsyncCallbackResponse() { $this->connectToHttpd(); $expectedToCount = 5; $asyncCallbackResponseMock = $this->getMockBuilder('\\stdClass')->setMethods(array('run'))->getMock(); $asyncCallbackResponseMock->expects($this->exactly($expectedToCount))->method('run'); $httpRequestFactory = new HttpRequestFactory(); $asyncCurlRequest = $httpRequestFactory->newAsyncCurlRequest(); $asyncCurlRequest->setCallback(function ($data, $info) use($asyncCallbackResponseMock) { $asyncCallbackResponseMock->run($data, $info); }); for ($i = 0; $i < $expectedToCount; $i++) { $asyncCurlRequest->addHttpRequest($httpRequestFactory->newCurlRequest($this->getHttpdRequestUrl($i))); } $asyncCurlRequest->execute(); }
public function testCanConstructAsyncCurlRequest() { $instance = new HttpRequestFactory(); $this->assertInstanceOf('\\Onoi\\HttpRequest\\AsyncCurlRequest', $instance->newAsyncCurlRequest()); }