Ejemplo n.º 1
0
 /**
  * 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()));
 }
Ejemplo n.º 2
0
 /**
  * @{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);
 }
Ejemplo n.º 3
0
 public function testMerge()
 {
     $this->unitOfWork->merge($this->buildUnit('-and-some-more-merged'));
     static::assertEquals('my-workload-and-some-more-merged', $this->unitOfWork->getQuery());
 }
Ejemplo n.º 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
     }
 }