예제 #1
0
 public function testAddRequests()
 {
     $requests = [new Request('url1', 'body1'), new Request('url2', 'body2')];
     $batchRequest = new BatchRequest();
     $batchRequest->addRequests($requests);
     $this->assertSame($requests, $batchRequest->getRequests());
 }
예제 #2
0
 /**
  * @inheritdoc
  */
 public function sendBatch(BatchRequest $batchRequest) : array
 {
     $requests = array_map([$this, 'createRequest'], $batchRequest->getRequests());
     $batchResults = Pool::batch($this->guzzleClient, $requests);
     if ($batchResults->getFailures()) {
         throw new BatchRequestFailureException($batchRequest, $batchResults);
     }
     return $batchResults->getSuccessful();
 }