@@ -1630,4 +1630,101 @@ public function testShouldMakeFieldsUpdateOnOpenWithCustomMacro(): void
1630
1630
$ templateProcessor ->setUpdateFields (false );
1631
1631
self ::assertStringContainsString ('<w:updateFields w:val="false"/> ' , $ templateProcessor ->getSettingsPart ());
1632
1632
}
1633
+
1634
+ public function testEnsureUtf8Encoded (): void
1635
+ {
1636
+ $ mainPart = '<w:tbl>
1637
+ <w:tr>
1638
+ <w:tc>
1639
+ <w:tcPr>
1640
+ <w:vMerge w:val="restart"/>
1641
+ </w:tcPr>
1642
+ <w:p>
1643
+ <w:r>
1644
+ <w:t t=1>${stringZero}</w:t>
1645
+ </w:r>
1646
+ </w:p>
1647
+ </w:tc>
1648
+ <w:tc>
1649
+ <w:p>
1650
+ <w:r>
1651
+ <w:t t=2>${intZero}</w:t>
1652
+ </w:r>
1653
+ </w:p>
1654
+ </w:tc>
1655
+ <w:tc>
1656
+ <w:p>
1657
+ <w:r>
1658
+ <w:t t=3>${stringTest}</w:t>
1659
+ </w:r>
1660
+ </w:p>
1661
+ </w:tc>
1662
+ <w:tc>
1663
+ <w:p>
1664
+ <w:r>
1665
+ <w:t t=4>${null}</w:t>
1666
+ </w:r>
1667
+ </w:p>
1668
+ </w:tc>
1669
+ <w:tc>
1670
+ <w:p>
1671
+ <w:r>
1672
+ <w:t t=5>${floatZero}</w:t>
1673
+ </w:r>
1674
+ </w:p>
1675
+ </w:tc>
1676
+ <w:tc>
1677
+ <w:p>
1678
+ <w:r>
1679
+ <w:t t=6>${intTen}</w:t>
1680
+ </w:r>
1681
+ </w:p>
1682
+ </w:tc>
1683
+ <w:tc>
1684
+ <w:p>
1685
+ <w:r>
1686
+ <w:t t=7>${boolFalse}</w:t>
1687
+ </w:r>
1688
+ </w:p>
1689
+ </w:tc>
1690
+ <w:tc>
1691
+ <w:p>
1692
+ <w:r>
1693
+ <w:t t=8>${boolTrue}</w:t>
1694
+ </w:r>
1695
+ </w:p>
1696
+ </w:tc>
1697
+ </w:tr>
1698
+ </w:tbl> ' ;
1699
+ $ templateProcessor = new TestableTemplateProcesor ($ mainPart );
1700
+
1701
+ self ::assertEquals (
1702
+ ['stringZero ' , 'intZero ' , 'stringTest ' , 'null ' , 'floatZero ' , 'intTen ' , 'boolFalse ' , 'boolTrue ' ],
1703
+ $ templateProcessor ->getVariables ()
1704
+ );
1705
+
1706
+ $ templateProcessor ->setValue ('stringZero ' , '0 ' );
1707
+ self ::assertStringContainsString ('<w:t t=1>0</w:t> ' , $ templateProcessor ->getMainPart ());
1708
+
1709
+ $ templateProcessor ->setValue ('intZero ' , 0 );
1710
+ self ::assertStringContainsString ('<w:t t=2>0</w:t> ' , $ templateProcessor ->getMainPart ());
1711
+
1712
+ $ templateProcessor ->setValue ('stringTest ' , 'test ' );
1713
+ self ::assertStringContainsString ('<w:t t=3>test</w:t> ' , $ templateProcessor ->getMainPart ());
1714
+
1715
+ $ templateProcessor ->setValue ('null ' , null );
1716
+ self ::assertStringContainsString ('<w:t t=4></w:t> ' , $ templateProcessor ->getMainPart ());
1717
+
1718
+ $ templateProcessor ->setValue ('floatZero ' , 0.00 );
1719
+ self ::assertStringContainsString ('<w:t t=5>0</w:t> ' , $ templateProcessor ->getMainPart ());
1720
+
1721
+ $ templateProcessor ->setValue ('intTen ' , 10 );
1722
+ self ::assertStringContainsString ('<w:t t=6>10</w:t> ' , $ templateProcessor ->getMainPart ());
1723
+
1724
+ $ templateProcessor ->setValue ('boolFalse ' , false );
1725
+ self ::assertStringContainsString ('<w:t t=7></w:t> ' , $ templateProcessor ->getMainPart ());
1726
+
1727
+ $ templateProcessor ->setValue ('boolTrue ' , true );
1728
+ self ::assertStringContainsString ('<w:t t=8>1</w:t> ' , $ templateProcessor ->getMainPart ());
1729
+ }
1633
1730
}
0 commit comments