/**
  * Merges this unit with given one
  *
  * @throws \InvalidArgumentException
  *
  * @param UnitOfWork $other
  */
 public function merge(UnitOfWork $other)
 {
     if (!$this->uniqueId->equals($other->uniqueId)) {
         throw new \InvalidArgumentException('Cannot merge units with different UIDs');
     }
     $this->workload = new Workload(sprintf('%s%s', $this->getQuery(), $other->getQuery()));
 }
 /**
  * @{inheritdoc}
  *
  * @param UnitOfWork $unitOfWork The unit to check
  *
  * @return boolean Whether the given unit is in the repository
  */
 public function contains(UnitOfWork $unitOfWork)
 {
     return array_key_exists($unitOfWork->getUniqueId(), $this->unitOfWorkStore);
 }
 public function testMerge()
 {
     $this->unitOfWork->merge($this->buildUnit('-and-some-more-merged'));
     static::assertEquals('my-workload-and-some-more-merged', $this->unitOfWork->getQuery());
 }
Exemple #4
0
 /**
  * Executes the given migration against the database connection
  *
  * @param UnitOfWork $unitOfWork
  *
  * @throws Exception\UnitIsAlreadyPresentException
  */
 private function executeMigration(UnitOfWork $unitOfWork)
 {
     try {
         $unitOfWork->migrate($this->connection);
         $this->historyRepository->add($unitOfWork);
     } catch (QueryNotSuccessfulException $e) {
         // for now do nothing  and leave out of history
     }
 }