getSource()); self::assertEquals($oLink->getSource(), $oLink->getText()); self::assertNull($oLink->getFontStyle()); self::assertNull($oLink->getParagraphStyle()); } /** * Create new instance with array. */ public function testConstructWithParamsArray(): void { $oLink = new Link( 'https://github.com/PHPOffice/PHPWord', 'PHPWord on GitHub', ['color' => '0000FF', 'underline' => Font::UNDERLINE_SINGLE], ['marginLeft' => 600, 'marginRight' => 600, 'marginTop' => 600, 'marginBottom' => 600] ); self::assertInstanceOf('PhpOffice\\PhpWord\\Element\\Link', $oLink); self::assertEquals('https://github.com/PHPOffice/PHPWord', $oLink->getSource()); self::assertEquals('PHPWord on GitHub', $oLink->getText()); self::assertInstanceOf('PhpOffice\\PhpWord\\Style\\Font', $oLink->getFontStyle()); self::assertInstanceOf('PhpOffice\\PhpWord\\Style\\Paragraph', $oLink->getParagraphStyle()); } /** * Create new instance with style name string. */ public function testConstructWithParamsString(): void { $oLink = new Link('https://github.com/PHPOffice/PHPWord', null, 'fontStyle', 'paragraphStyle'); self::assertEquals('fontStyle', $oLink->getFontStyle()); self::assertEquals('paragraphStyle', $oLink->getParagraphStyle()); } /** * Set/get relation Id. */ public function testRelationId(): void { $oLink = new Link('https://github.com/PHPOffice/PHPWord'); $iVal = mt_rand(1, 1000); $oLink->setRelationId($iVal); self::assertEquals($iVal, $oLink->getRelationId()); } }