Example #1
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']);
 }
Example #2
0
 /**
  * Migrates the unit of work into the database
  *
  * @throws \Bytepark\Component\Migration\Exception\QueryNotSuccessfulException
  *
  * @param Connection $connection The connection to migrate to
  */
 public function migrate(Connection $connection)
 {
     $connection->execute($this->getQuery());
 }
Example #3
0
 /**
  * Loads the UnitsOfWork from the database as Iterator
  *
  * @return \ArrayIterator
  */
 private function loadUnitDataIteratorFromDatabase()
 {
     $result = $this->connection->query(sprintf("SELECT * FROM %s ORDER BY unique_id ASC", $this->tableName));
     return new \ArrayIterator($result);
 }