Esempio n. 1
0
 public function testReplace()
 {
     $filePath = TEST_FILE_FIXTURE_PATH . '/persisting-test.mig';
     $unitToReplace = $this->buildUnitOfWork();
     $replacementUnit = $this->buildUnitOfWork('replaced!');
     $this->repository->add($unitToReplace);
     $this->repository->persist();
     $this->repository->replace($replacementUnit);
     $this->repository->persist();
     static::assertEquals('replaced!', file_get_contents($filePath));
 }
Esempio n. 2
0
 /**
  * Dispatches the migration process
  *
  * @throws Exception\LockNotAcquirableException
  * @throws Exception\HistoryHasSourceUnknownUnitsOfWorkException
  * @throws Exception\UnitIsAlreadyPresentException
  *
  * @return void
  */
 public function dispatch()
 {
     $this->lock->acquire();
     $this->guardThatHistoryRepositoryDoesNotHaveMoreUnitsOfWork();
     $workloadRepository = $this->sourceRepository->diff($this->historyRepository);
     foreach ($workloadRepository as $unitOfWork) {
         $this->executeMigration($unitOfWork);
     }
     $this->historyRepository->persist();
     $this->lock->release();
 }
Esempio n. 3
0
 public function testReplace()
 {
     $unitToReplace = $this->buildUnitOfWork();
     $replacementUnit = $this->buildUnitOfWork('replaced!');
     $this->repository->add($unitToReplace);
     $this->repository->persist();
     $this->repository->replace($replacementUnit);
     $this->repository->persist();
     $result = $this->connection->query(sprintf('SELECT * FROM %s', $this->tableName));
     static::assertEquals($this->uidValue, $result[0]['unique_id']);
     static::assertEquals('replaced!', $result[0]['query']);
 }
Esempio n. 4
0
 public function testPersisting()
 {
     $fileName = 'persisting-test.mig';
     $fileContent = 'file-contents';
     $filePath = TEST_GROUPED_FILE_FIXTURE_PATH . '/b/d/' . $fileName;
     $unitOfWorkToPersist = new UnitOfWork(new Uid($fileName), new Workload($fileContent), new \DateTime());
     $this->repository->add($unitOfWorkToPersist);
     $wasSuccess = $this->repository->persist();
     static::assertTrue($wasSuccess);
     static::assertFileExists($filePath);
     static::assertEquals($fileContent, file_get_contents($filePath));
 }
Esempio n. 5
0
 public function testPersisting()
 {
     static::assertTrue($this->repository->persist());
 }