Skip to content

Commit

Permalink
Merge pull request PHPOffice#5 from MichaelPFrey/mfr-2024-11-25
Browse files Browse the repository at this point in the history
add test for default color
  • Loading branch information
Collie-IT authored Jan 15, 2025
2 parents 8566727 + 195dc55 commit 4d85196
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions tests/PhpWordTests/Writer/Word2007/Part/StylesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,4 +144,43 @@ public function testFontStyleBasedOnOtherFontStyle(): void
$element = $doc->getElement($path, $file);
self::assertEquals('Generation', $element->getAttribute('w:val'));
}

/**
* Test default font color.
*/
public function testDefaultDefaultFontColor(): void
{
$phpWord = new PhpWord();

$doc = TestHelperDOCX::getDocument($phpWord);

$file = 'word/styles.xml';

$path = '/w:styles/w:docDefaults/w:rPrDefault/w:rPr/w:color';
self::assertTrue($doc->elementExists($path, $file));
$element = $doc->getElement($path, $file);

self::assertEquals('000000', $element->getAttribute('w:val'));
}

/**
* Test default font color.
*/
public function testDefaultFontColor(): void
{
$phpWord = new PhpWord();
$defaultFontColor = '00FF00';
$phpWord->setDefaultFontColor($defaultFontColor);

$doc = TestHelperDOCX::getDocument($phpWord);

$file = 'word/styles.xml';

$path = '/w:styles/w:docDefaults/w:rPrDefault/w:rPr/w:color';
self::assertTrue($doc->elementExists($path, $file));
$element = $doc->getElement($path, $file);

self::assertEquals($defaultFontColor, $element->getAttribute('w:val'));
}

}

0 comments on commit 4d85196

Please sign in to comment.