/** * Persist scheduled objects to ElasticSearch * After persisting, clear the scheduled queue to prevent multiple data updates when using multiple flush calls */ private function persistScheduled() { /*if (count($this->scheduledForInsertion)) { $this->objectPersister->insertMany($this->scheduledForInsertion); $this->scheduledForInsertion = array(); } if (count($this->scheduledForUpdate)) { $this->objectPersister->replaceMany($this->scheduledForUpdate); $this->scheduledForUpdate = array(); } if (count($this->scheduledForDeletion)) { $this->objectPersister->deleteManyByIdentifiers($this->scheduledForDeletion); $this->scheduledForDeletion = array(); }*/ if ($this->shouldPersist()) { if (count($this->scheduledForInsertion)) { $this->objectPersister->insertMany($this->scheduledForInsertion); $this->scheduledForInsertion = array(); } if (count($this->scheduledForUpdate)) { $this->objectPersister->replaceMany($this->scheduledForUpdate); $this->scheduledForUpdate = array(); } if (count($this->scheduledForDeletion)) { $this->objectPersister->deleteManyByIdentifiers($this->scheduledForDeletion); $this->scheduledForDeletion = array(); } } }
public function testThatCanInsertManyObjects() { $transformer = $this->getTransformer(); /** @var $typeMock \PHPUnit_Framework_MockObject_MockObject|\Elastica\Type */ $typeMock = $this->getMockBuilder('Elastica\\Type')->disableOriginalConstructor()->getMock(); $typeMock->expects($this->never())->method('deleteById'); $typeMock->expects($this->never())->method('addDocument'); $typeMock->expects($this->once())->method('addDocuments'); $fields = array('name' => array()); $objectPersister = new ObjectPersister($typeMock, $transformer, 'SomeClass', $fields); $objectPersister->insertMany(array(new POPO(), new POPO())); }