/**
  * @test
  */
 function shouldHandleTimeAwareSoftDeleteable()
 {
     $address = new Address();
     $address->setStreet('13 Boulangerie, 404');
     $person = new Person();
     $person->setName('Gedi');
     $person->setDeletedAt(new \DateTime(date('Y-m-d H:i:s', time() + 15 * 3600)));
     // in an hour
     $person->setAddress($address);
     $this->em->persist($address);
     $this->em->persist($person);
     $this->em->flush();
     $this->em->clear();
     $person = $this->em->getRepository('SoftDeleteable\\Fixture\\Entity\\Person')->findOneById($person->getId());
     $this->assertNotNull($person, "Should not be softdeleted");
     $person->setDeletedAt(new \DateTime(date('Y-m-d H:i:s', time() - 15 * 3600)));
     // in an hour
     $this->em->persist($person);
     $this->em->flush();
     $this->em->clear();
     $person = $this->em->getRepository('SoftDeleteable\\Fixture\\Entity\\Person')->findOneById($person->getId());
     $this->assertNull($person, "Should be softdeleted");
 }
Example #2
0
 public function setAddress(Address $address)
 {
     $this->address = $address;
     $address->setOwner($this);
     return $this;
 }