public function testBlameable() { $sport = new Article(); $sport->setTitle('Sport'); $this->assertTrue($sport instanceof Blameable); $sportComment = new Comment(); $sportComment->setMessage('hello'); $sportComment->setArticle($sport); $sportComment->setStatus(0); $this->assertTrue($sportComment instanceof Blameable); $this->em->persist($sport); $this->em->persist($sportComment); $this->em->flush(); $this->em->clear(); $sport = $this->em->getRepository(self::ARTICLE)->findOneByTitle('Sport'); $this->assertEquals('testuser', $sport->getCreated()); $this->assertEquals('testuser', $sport->getUpdated()); $this->assertNull($sport->getPublished()); $sportComment = $this->em->getRepository(self::COMMENT)->findOneByMessage('hello'); $this->assertEquals('testuser', $sportComment->getModified()); $this->assertNull($sportComment->getClosed()); $sportComment->setStatus(1); $published = new Type(); $published->setTitle('Published'); $sport->setTitle('Updated'); $sport->setType($published); $this->em->persist($sport); $this->em->persist($published); $this->em->persist($sportComment); $this->em->flush(); $this->em->clear(); $sportComment = $this->em->getRepository(self::COMMENT)->findOneByMessage('hello'); $this->assertEquals('testuser', $sportComment->getClosed()); $this->assertEquals('testuser', $sport->getPublished()); }
public function addComment(Comment $comment) { $comment->setArticle($this); $this->comments[] = $comment; }