setStartElement($oText); $oComment->setEndElement($oText); $this->assertInstanceOf('PhpOffice\\PhpWord\\Element\\Comment', $oComment); $this->assertEquals($author, $oComment->getAuthor()); $this->assertEquals($date, $oComment->getDate()); $this->assertEquals($initials, $oComment->getInitials()); $this->assertEquals($oText, $oComment->getStartElement()); $this->assertEquals($oText, $oComment->getEndElement()); } /** * Add text */ public function testAddText() { $oComment = new Comment('Test User', new \DateTime(), 'my_initials'); $element = $oComment->addText('text'); $this->assertInstanceOf('PhpOffice\\PhpWord\\Element\\Text', $element); $this->assertCount(1, $oComment->getElements()); $this->assertEquals('text', $element->getText()); } /** * Get elements */ public function testGetElements() { $oComment = new Comment('Test User', new \DateTime(), 'my_initials'); $this->assertIsArray($oComment->getElements()); } /** * Set/get relation Id */ public function testRelationId() { $oComment = new Comment('Test User', new \DateTime(), 'my_initials'); $iVal = rand(1, 1000); $oComment->setRelationId($iVal); $this->assertEquals($iVal, $oComment->getRelationId()); } public function testExceptionOnCommentStartOnComment() { $this->expectException(\InvalidArgumentException::class); $dummyComment = new Comment('Test User', new \DateTime(), 'my_initials'); $oComment = new Comment('Test User', new \DateTime(), 'my_initials'); $oComment->setCommentRangeStart($dummyComment); } public function testExceptionOnCommentEndOnComment() { $this->expectException(\InvalidArgumentException::class); $dummyComment = new Comment('Test User', new \DateTime(), 'my_initials'); $oComment = new Comment('Test User', new \DateTime(), 'my_initials'); $oComment->setCommentRangeEnd($dummyComment); } }