Skip to content

Commit

Permalink
test: Add test case for vMerge's default value of continue (#2677)
Browse files Browse the repository at this point in the history
* test: Add test case for vMerge's default value of continue

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.

* docs(changelog): Add note about added test case for vMerge default value
  • Loading branch information
SpraxDev authored Sep 13, 2024
1 parent f0ec497 commit 43785fe
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/changes/1.x/1.4.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@
### Miscellaneous

- Bump dompdf/dompdf from 2.0.4 to 3.0.0 by [@dependabot](https://github.com/dependabot) fixing [#2621](https://github.com/PHPOffice/PHPWord/issues/2621) in [#2666](https://github.com/PHPOffice/PHPWord/pull/2666)
- Add test case to make sure vMerge defaults to 'continue' by [@SpraxDev](https://github.com/SpraxDev) in [#2677](https://github.com/PHPOffice/PHPWord/pull/2677)

### BC Breaks
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 43785fe

Please sign in to comment.