public function testGetters() { // Given $thread = new BaseThread(); $thread->setId('my-comment-thread'); $comment = new BaseComment(); $comment->setBody('Comment text'); $comment->setWebsite('http://www.example.com'); $comment->setEmail('*****@*****.**'); $comment->setNote(0.2); $comment->setPrivate(true); $comment->setAuthorName('My name'); $date = new \DateTime(); $comment->setCreatedAt($date); $comment->setState(1); $comment->setThread($thread); // Then $this->assertEquals('Comment text', $comment->getBody(), 'Should return correct comment body'); $this->assertEquals('http://www.example.com', $comment->getWebsite(), 'Should return correct comment author website'); $this->assertEquals('*****@*****.**', $comment->getEmail(), 'Should return correct comment author email address'); $this->assertEquals(0.2, $comment->getNote(), 'Should return correct comment note'); $this->assertTrue($comment->isPrivate(), 'Should return that comment is flagged as private'); $this->assertEquals('My name', $comment->getAuthorName(), 'Should return correct comment author name'); $this->assertEquals($date, $comment->getCreatedAt(), 'Should return correct creation date'); $this->assertEquals($thread, $comment->getThread(), 'Should return correct thread'); $this->assertEquals('my-comment-thread', $comment->getThread()->getId(), 'Should return correct thread identifier'); }
/** * Tests category setter & getter if using SonataClassificationBundle */ public function testCategoryGetters() { if (!interface_exists('Sonata\\ClassificationBundle\\Model\\CategoryInterface')) { $this->markTestSkipped('Sonata\\ClassificationBundle\\Model\\CategoryInterface does not exist'); } // Given $category = $this->getMock('Sonata\\ClassificationBundle\\Model\\CategoryInterface'); $category->expects($this->once())->method('getName')->will($this->returnValue('my-category')); $thread = new BaseThread(); $thread->setId('my-comment-thread'); $thread->setCategory($category); // Then $this->assertEquals('my-category', $thread->getCategory()->getName(), 'Should return correct category name'); }