From 43785fe76b35d5a5c9338ed943383a2529e30deb Mon Sep 17 00:00:00 2001 From: Christian Koop Date: Fri, 13 Sep 2024 19:58:26 +0200 Subject: [PATCH] test: Add test case for vMerge's default value of continue (#2677) * test: Add test case for vMerge's default value of continue This new test case essentially covers the changes in b457ff5f7fadf28f4d62d1fcd5b9ee3424392835. 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 --- docs/changes/1.x/1.4.0.md | 1 + .../Reader/Word2007/StyleTest.php | 38 +++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/docs/changes/1.x/1.4.0.md b/docs/changes/1.x/1.4.0.md index 13d9bc0937..8db845337d 100644 --- a/docs/changes/1.x/1.4.0.md +++ b/docs/changes/1.x/1.4.0.md @@ -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 diff --git a/tests/PhpWordTests/Reader/Word2007/StyleTest.php b/tests/PhpWordTests/Reader/Word2007/StyleTest.php index 015a3cfcb7..f622c57e90 100644 --- a/tests/PhpWordTests/Reader/Word2007/StyleTest.php +++ b/tests/PhpWordTests/Reader/Word2007/StyleTest.php @@ -165,6 +165,44 @@ public function testReadTableCellStyle(): void self::assertEquals('auto', $styleCell->getBorderBottomColor()); } + public function testReadTableCellsWithVerticalMerge(): void + { + $documentXml = ' + + + + + + + + + + + + + + + + + + '; + + $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. */