|
17 | 17 |
|
18 | 18 | namespace PhpOffice\PhpWordTests\Writer\Word2007\Style;
|
19 | 19 |
|
| 20 | +use PhpOffice\PhpWord\PhpWord; |
| 21 | +use PhpOffice\PhpWord\Shared\Html; |
20 | 22 | use PhpOffice\PhpWordTests\TestHelperDOCX;
|
21 | 23 |
|
22 | 24 | /**
|
@@ -155,4 +157,44 @@ public function testPosition(): void
|
155 | 157 | self::assertTrue($doc->elementExists($path));
|
156 | 158 | self::assertEquals(-20, $doc->getElementAttribute($path, 'w:val'));
|
157 | 159 | }
|
| 160 | + |
| 161 | + public static function testRgb(): void |
| 162 | + { |
| 163 | + $phpWord = new PhpWord(); |
| 164 | + $section = $phpWord->addSection(['pageNumberingStart' => 1]); |
| 165 | + $html = implode( |
| 166 | + "\n", |
| 167 | + [ |
| 168 | + '<table>', |
| 169 | + '<tbody>', |
| 170 | + '<tr>', |
| 171 | + '<td style="color: #A7D9C1;">This one is in color.</td>', |
| 172 | + '<td style="color: rgb(167, 217, 193);">This one too.</td>', |
| 173 | + '</tr>', |
| 174 | + '</tbody>', |
| 175 | + '</table>', |
| 176 | + ] |
| 177 | + ); |
| 178 | + |
| 179 | + Html::addHtml($section, $html, false, false); |
| 180 | + $doc = TestHelperDOCX::getDocument($phpWord, 'Word2007'); |
| 181 | + |
| 182 | + $element = '/w:document/w:body/w:tbl/w:tr/w:tc/w:p/w:r'; |
| 183 | + $txtelem = $element . '/w:t'; |
| 184 | + $styelem = $element . '/w:rPr'; |
| 185 | + self::assertTrue($doc->elementExists($txtelem)); |
| 186 | + self::assertSame('This one is in color.', $doc->getElement($txtelem)->textContent); |
| 187 | + self::assertTrue($doc->elementExists($styelem)); |
| 188 | + self::assertTrue($doc->elementExists($styelem . '/w:color')); |
| 189 | + self::assertSame('A7D9C1', $doc->getElementAttribute($styelem . '/w:color', 'w:val')); |
| 190 | + |
| 191 | + $element = '/w:document/w:body/w:tbl/w:tr/w:tc[2]/w:p/w:r'; |
| 192 | + $txtelem = $element . '/w:t'; |
| 193 | + $styelem = $element . '/w:rPr'; |
| 194 | + self::assertTrue($doc->elementExists($txtelem)); |
| 195 | + self::assertSame('This one too.', $doc->getElement($txtelem)->textContent); |
| 196 | + self::assertTrue($doc->elementExists($styelem)); |
| 197 | + self::assertTrue($doc->elementExists($styelem . '/w:color')); |
| 198 | + self::assertSame('A7D9C1', $doc->getElementAttribute($styelem . '/w:color', 'w:val')); |
| 199 | + } |
158 | 200 | }
|
0 commit comments