setStartElement($oText); $oComment->setEndElement($oText); self::assertInstanceOf('PhpOffice\\PhpWord\\Element\\Comment', $oComment); self::assertEquals($author, $oComment->getAuthor()); self::assertEquals($date, $oComment->getDate()); self::assertEquals($initials, $oComment->getInitials()); self::assertEquals($oText, $oComment->getStartElement()); self::assertEquals($oText, $oComment->getEndElement()); } /** * Add text. */ public function testAddText(): void { $oComment = new Comment('Test User', new DateTime(), 'my_initials'); $element = $oComment->addText('text'); self::assertInstanceOf('PhpOffice\\PhpWord\\Element\\Text', $element); self::assertCount(1, $oComment->getElements()); self::assertEquals('text', $element->getText()); } /** * Get elements. */ public function testGetElements(): void { $oComment = new Comment('Test User', new DateTime(), 'my_initials'); self::assertIsArray($oComment->getElements()); } /** * Set/get relation Id. */ public function testRelationId(): void { $oComment = new Comment('Test User', new DateTime(), 'my_initials'); $iVal = mt_rand(1, 1000); $oComment->setRelationId($iVal); self::assertEquals($iVal, $oComment->getRelationId()); } public function testExceptionOnCommentStartOnComment(): void { $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(): void { $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); } }