Ejemplo n.º 1
0
 public function testChange()
 {
     $test = new TitledArticle();
     $test->setTitle('Test');
     $test->setText('Test');
     $currentDate = new \DateTime('now');
     $this->listener->eventAdapter->setDateValue($currentDate);
     $this->em->persist($test);
     $this->em->flush();
     $this->em->clear();
     $test = $this->em->getRepository(self::FIXTURE)->findOneByTitle('Test');
     $test->setTitle('New Title');
     $this->em->persist($test);
     $this->em->flush();
     $this->em->clear();
     //Changed
     $this->assertEquals($currentDate->format('Y-m-d H:i:s'), $test->getChtitle()->format('Y-m-d H:i:s'));
     $this->listener->eventAdapter->setDateValue(\DateTime::createFromFormat('Y-m-d H:i:s', '2000-01-01 00:00:00'));
     $test = $this->em->getRepository(self::FIXTURE)->findOneByTitle('New Title');
     $test->setText('New Text');
     $this->em->persist($test);
     $this->em->flush();
     $this->em->clear();
     //Not Changed
     $this->assertEquals($currentDate->format('Y-m-d H:i:s'), $test->getChtitle()->format('Y-m-d H:i:s'));
 }
Ejemplo n.º 2
0
 public function testChange()
 {
     $test = new TitledArticle();
     $test->setTitle('Test');
     $test->setText('Test');
     $date = new \DateTime('now');
     $this->em->persist($test);
     $this->em->flush();
     $this->em->clear();
     $test = $this->em->getRepository(self::FIXTURE)->findOneByTitle('Test');
     $test->setTitle('New Title');
     $this->em->persist($test);
     $this->em->flush();
     $this->em->clear();
     //Changed
     $this->assertEquals($date->format('Y-m-d H:i:s'), $test->getChtitle()->format('Y-m-d H:i:s'));
     sleep(1);
     $test = $this->em->getRepository(self::FIXTURE)->findOneByTitle('New Title');
     $test->setText('New Text');
     $this->em->persist($test);
     $this->em->flush();
     $this->em->clear();
     //Not Changed
     $this->assertEquals($date->format('Y-m-d H:i:s'), $test->getChtitle()->format('Y-m-d H:i:s'));
     $date = new \DateTime('now');
 }