Пример #1
0
 /**
  * Flush all job batches
  *
  * @return void
  */
 protected function flushBatches()
 {
     $batches = $this->job->getBatches();
     foreach ($batches as $i => $batch) {
         $url = sprintf('job/%s/batch', $this->job->getId());
         $requestEvent = new CreateBatchEvent($this->client->getRestEndpoint() . $url, $batch->asXML());
         $this->client->dispatch(Events::CREATE_BATCH, $requestEvent);
         $response = $this->httpClient->post($url, $batch->asXML());
         $response = ResponseMediator::getContent($response);
         $this->client->dispatch(Events::RESPONSE, new ResponseEvent($requestEvent, $response->asXML()));
         $batches[$i]->fromXml($response);
     }
 }
Пример #2
0
 public function testShouldDivideDataInBatches()
 {
     $job = new Job('Account');
     for ($i = 0; $i < 1001; $i++) {
         $object = $this->getObjectMock();
         $object->method('getObjectType')->willReturn('Account');
         $job->addObject($object);
     }
     $this->assertGreaterThan(1, count($job->getBatches()));
     $this->assertEquals(2, count($job->getBatches()));
 }