Exemplo n.º 1
0
 public function testGetCurrentRevision()
 {
     $car = new Car();
     $car->setLicensePlate('AB-123-C');
     $car->setSeats(1);
     $this->em->persist($car);
     $this->em->flush();
     $car->setSeats(2);
     $this->em->flush();
     $this->assertEquals(2, $this->revisionManager->getCurrentRevision($car));
     $car->setSeats(3);
     $this->em->flush();
     sleep(1);
     $car->setLicensePlate('A');
     $car->setDraft(true);
     $this->em->flush();
     $this->revisionManager->revert($car, 3);
     $this->assertEquals(3, $this->revisionManager->getCurrentRevision($car));
 }
Exemplo n.º 2
0
 public function testDraftDelete()
 {
     $car = new Car();
     $car->setLicensePlate('AB-123-C');
     $car->setSeats(5);
     $this->em->persist($car);
     $this->em->flush();
     $carId = $car->getId();
     $car->setDraft(true);
     $this->em->remove($car);
     $this->em->flush();
     $this->em->detach($car);
     // clear cache
     $this->assertEquals(2, count($this->em->getConnection()->fetchAll('SELECT id FROM opifer_vehicle_revisions WHERE id = "' . $carId . '"')));
     $persistedCar = $this->em->getRepository('Opifer\\Revisions\\Tests\\Entity\\Vehicle')->find($carId);
     $this->assertNull($persistedCar->getDeletedAt());
 }