예제 #1
0
 public function testMultiCurlForCallbackResponse()
 {
     $this->connectToHttpd();
     $expectedToCount = 5;
     $asyncCallbackResponseMock = $this->getMockBuilder('\\stdClass')->setMethods(array('run'))->getMock();
     $asyncCallbackResponseMock->expects($this->exactly($expectedToCount))->method('run');
     $httpRequestFactory = new HttpRequestFactory();
     $multiCurlRequest = $httpRequestFactory->newMultiCurlRequest();
     $multiCurlRequest->setOption(ONOI_HTTP_REQUEST_ON_COMPLETED_CALLBACK, function ($requestResponse) use($asyncCallbackResponseMock) {
         $asyncCallbackResponseMock->run($requestResponse);
     });
     for ($i = 0; $i < $expectedToCount; $i++) {
         $multiCurlRequest->addHttpRequest($httpRequestFactory->newCurlRequest($this->getHttpdRequestUrl($i)));
     }
     $multiCurlRequest->execute();
 }
예제 #2
0
 public function testCanConstructMultiCurlRequest()
 {
     $instance = new HttpRequestFactory();
     $this->assertInstanceOf('\\Onoi\\HttpRequest\\MultiCurlRequest', $instance->newMultiCurlRequest());
 }