|
19 | 19 |
|
20 | 20 | use DOMXPath;
|
21 | 21 | use PhpOffice\PhpWord\PhpWord;
|
22 |
| -use PhpOffice\PhpWord\Writer\HTML\Element\Table; |
| 22 | +use PhpOffice\PhpWord\SimpleType\VerticalJc; |
23 | 23 | use PhpOffice\PhpWordTests\Writer\HTML\Helper;
|
24 | 24 | use PHPUnit\Framework\TestCase;
|
25 | 25 |
|
@@ -162,4 +162,29 @@ public function testWriteTableBorders(): void
|
162 | 162 | self::assertNotFalse(preg_match('/^[.]tstyle[^\\r\\n]*/m', $style, $matches));
|
163 | 163 | self::assertEquals(".tstyle {table-layout: auto; $cssnone}", $matches[0]);
|
164 | 164 | }
|
| 165 | + |
| 166 | + public function testWriteTableCellVAlign(): void |
| 167 | + { |
| 168 | + $phpWord = new PhpWord(); |
| 169 | + $section = $phpWord->addSection(); |
| 170 | + |
| 171 | + $table = $section->addTable(); |
| 172 | + $row = $table->addRow(); |
| 173 | + |
| 174 | + $cell = $row->addCell(); |
| 175 | + $cell->addText('top text'); |
| 176 | + $cell->getStyle()->setVAlign(VerticalJc::TOP); |
| 177 | + |
| 178 | + $cell = $row->addCell(); |
| 179 | + $cell->addText('bottom text'); |
| 180 | + $cell->getStyle()->setVAlign(VerticalJc::BOTTOM); |
| 181 | + |
| 182 | + $dom = Helper::getAsHTML($phpWord); |
| 183 | + $xpath = new DOMXPath($dom); |
| 184 | + |
| 185 | + $cell1Style = Helper::getTextContent($xpath, '//table/tr/td[1]', 'style'); |
| 186 | + $cell2Style = Helper::getTextContent($xpath, '//table/tr/td[2]', 'style'); |
| 187 | + self::assertSame('vertical-align: top;', $cell1Style); |
| 188 | + self::assertSame('vertical-align: bottom;', $cell2Style); |
| 189 | + } |
165 | 190 | }
|
0 commit comments