public function testForcedValues() { $sport = new Article(); $sport->setTitle('sport forced'); $sport->setCreated(new \DateTime('2000-01-01')); $sport->setUpdated(new \DateTime('2000-01-01 12:00:00')); $this->em->persist($sport); $this->em->flush(); $this->em->clear(); $repo = $this->em->getRepository(self::ARTICLE); $sport = $repo->findOneByTitle('sport forced'); $this->assertEquals('2000-01-01', $sport->getCreated()->format('Y-m-d')); $this->assertEquals('2000-01-01 12:00:00', $sport->getUpdated()->format('Y-m-d H:i:s')); $published = new Type(); $published->setTitle('Published'); $sport->setType($published); $sport->setPublished(new \DateTime('2000-01-01 12:00:00')); $this->em->persist($sport); $this->em->persist($published); $this->em->flush(); $this->em->clear(); $sport = $repo->findOneByTitle('sport forced'); $this->assertEquals('2000-01-01 12:00:00', $sport->getPublished()->format('Y-m-d H:i:s')); }
/** * @test */ function shouldSolveIssue767() { $type = new Type(); $type->setTitle('Published'); $this->em->persist($type); $this->em->flush(); $this->em->clear(); $type = $this->em->getReference(self::TYPE, $type->getId()); $this->assertInstanceOf('Doctrine\\ORM\\Proxy\\Proxy', $type); $art = new Article(); $art->setTitle('Art'); $art->setBody('body'); $this->em->persist($art); $this->em->flush(); $art->setType($type); $this->em->flush(); // in v2.4.x will work on insert too $this->assertNotNull($art->getPublished()); }