Skip to content

Commit

Permalink
test: Extend existing table test case to check if unsetting vAlign works
Browse files Browse the repository at this point in the history
  • Loading branch information
SpraxDev committed Sep 13, 2024
1 parent 7ee9050 commit 116be46
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tests/PhpWordTests/Writer/HTML/Element/TableTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,12 +179,24 @@ public function testWriteTableCellVAlign(): void
$cell->addText('bottom text');
$cell->getStyle()->setVAlign(VerticalJc::BOTTOM);

$cell = $row->addCell();
$cell->addText('no vAlign');
$cell->getStyle()->setVAlign(VerticalJc::BOTTOM);
$cell->getStyle()->setVAlign();

$dom = Helper::getAsHTML($phpWord);
$xpath = new DOMXPath($dom);

$cell1Style = Helper::getTextContent($xpath, '//table/tr/td[1]', 'style');
$cell2Style = Helper::getTextContent($xpath, '//table/tr/td[2]', 'style');
self::assertSame('vertical-align: top;', $cell1Style);
self::assertSame('vertical-align: bottom;', $cell2Style);

$cell3Query = $xpath->query('//table/tr/td[3]');
self::assertNotFalse($cell3Query);
self::assertCount(1, $cell3Query);

$cell3Style = $cell3Query->item(0)->attributes->getNamedItem('style');
self::assertNull($cell3Style);
}
}

0 comments on commit 116be46

Please sign in to comment.