Skip to content

Commit

Permalink
test: Add test case for vMerge's default value of continue
Browse files Browse the repository at this point in the history
This new test case essentially covers the changes in b457ff5.
It ensures the new behavior works as intended and
doesn't break/change by accident in the future.
  • Loading branch information
SpraxDev committed Sep 13, 2024
1 parent f0ec497 commit 19ae1c7
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions tests/PhpWordTests/Reader/Word2007/StyleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,44 @@ public function testReadTableCellStyle(): void
self::assertEquals('auto', $styleCell->getBorderBottomColor());
}

public function testReadTableCellsWithVerticalMerge(): void
{
$documentXml = '<w:tbl>
<w:tr>
<w:tc>
<w:tcPr>
<w:vMerge w:val="restart" />
</w:tcPr>
</w:tc>
</w:tr>
<w:tr>
<w:tc>
<w:tcPr>
<w:vMerge />
</w:tcPr>
</w:tc>
</w:tr>
<w:tr>
<w:tc />
</w:tr>
</w:tbl>';

$phpWord = $this->getDocumentFromString(['document' => $documentXml]);

$table = $phpWord->getSection(0)->getElements()[0];
self::assertInstanceOf('PhpOffice\PhpWord\Element\Table', $table);

$rows = $table->getRows();
self::assertCount(3, $rows);
foreach ($rows as $row) {
self::assertCount(1, $row->getCells());
}

self::assertSame('restart', $rows[0]->getCells()[0]->getStyle()->getVMerge());
self::assertSame('continue', $rows[1]->getCells()[0]->getStyle()->getVMerge());
self::assertNull($rows[2]->getCells()[0]->getStyle()->getVMerge());
}

/**
* Test reading of position.
*/
Expand Down

0 comments on commit 19ae1c7

Please sign in to comment.