Passed
Push — master ( bd616f...fda8a7 )
by Bingo
02:57
created

PhpDocxTemplateTest::testCyrillic()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 36
Code Lines 34

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 34
nc 1
nop 0
dl 0
loc 36
rs 9.376
c 0
b 0
f 0
1
<?php
2
3
namespace Doctrine\Tests\DBAL\Query;
4
5
use PHPUnit\Framework\TestCase;
6
use DOMDocument;
7
use PhpDocxTemplate\PhpDocxTemplate;
8
use PhpDocxTemplate\DocxDocument;
9
use Twig\Loader\ArrayLoader;
10
use Twig\Environment;
11
12
class PhpDocxTemplateTest extends TestCase
13
{
14
    private const TEMPLATE1 = __DIR__ . "/templates/template1.docx";
15
    private const TEMPLATE2 = __DIR__ . "/templates/template2.docx";
16
    private const TEMPLATE3 = __DIR__ . "/templates/template3.docx";
17
    private const TEMPLATE4 = __DIR__ . "/templates/template4.docx";
18
    private const TEMPLATE5 = __DIR__ . "/templates/template5.docx";
19
20
    public function testXmlToString(): void
21
    {
22
        $xml = new DOMDocument('1.0');
23
        $root = $xml->createElement('book');
24
        $root = $xml->appendChild($root);
25
        $title = $xml->createElement('title');
26
        $title = $root->appendChild($title);
27
        $text = $xml->createTextNode('Title');
28
        $title->appendChild($text);
29
        $reporter = new PhpDocxTemplate(self::TEMPLATE1);
30
31
        $this->assertEquals(
32
            $reporter->xmlToString($xml),
33
            "<?xml version=\"1.0\"?>\n<book><title>Title</title></book>\n"
34
        );
35
        $reporter->close();
36
    }
37
38
    public function testGetDocx(): void
39
    {
40
        $reporter = new PhpDocxTemplate(self::TEMPLATE1);
41
        $this->assertInstanceOf(DocxDocument::class, $reporter->getDocx());
42
        $reporter->close();
43
    }
44
45
    public function testGetXml(): void
46
    {
47
        $reporter = new PhpDocxTemplate(self::TEMPLATE1);
48
        $this->assertEquals(
49
            $reporter->getXml(),
50
            "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n" .
51
            "<w:document xmlns:wpc=\"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas\" " .
52
            "xmlns:cx=\"http://schemas.microsoft.com/office/drawing/2014/chartex\" " .
53
            "xmlns:cx1=\"http://schemas.microsoft.com/office/drawing/2015/9/8/chartex\" " .
54
            "xmlns:cx2=\"http://schemas.microsoft.com/office/drawing/2015/10/21/chartex\" " .
55
            "xmlns:cx3=\"http://schemas.microsoft.com/office/drawing/2016/5/9/chartex\" " .
56
            "xmlns:cx4=\"http://schemas.microsoft.com/office/drawing/2016/5/10/chartex\" " .
57
            "xmlns:cx5=\"http://schemas.microsoft.com/office/drawing/2016/5/11/chartex\" " .
58
            "xmlns:cx6=\"http://schemas.microsoft.com/office/drawing/2016/5/12/chartex\" " .
59
            "xmlns:cx7=\"http://schemas.microsoft.com/office/drawing/2016/5/13/chartex\" " .
60
            "xmlns:cx8=\"http://schemas.microsoft.com/office/drawing/2016/5/14/chartex\" " .
61
            "xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" " .
62
            "xmlns:aink=\"http://schemas.microsoft.com/office/drawing/2016/ink\" " .
63
            "xmlns:am3d=\"http://schemas.microsoft.com/office/drawing/2017/model3d\" " .
64
            "xmlns:o=\"urn:schemas-microsoft-com:office:office\" " .
65
            "xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" " .
66
            "xmlns:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\" " .
67
            "xmlns:v=\"urn:schemas-microsoft-com:vml\" " .
68
            "xmlns:wp14=\"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing\" " .
69
            "xmlns:wp=\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\" " .
70
            "xmlns:w10=\"urn:schemas-microsoft-com:office:word\" " .
71
            "xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" " .
72
            "xmlns:w14=\"http://schemas.microsoft.com/office/word/2010/wordml\" " .
73
            "xmlns:w15=\"http://schemas.microsoft.com/office/word/2012/wordml\" " .
74
            "xmlns:w16cid=\"http://schemas.microsoft.com/office/word/2016/wordml/cid\" " .
75
            "xmlns:w16se=\"http://schemas.microsoft.com/office/word/2015/wordml/symex\" " .
76
            "xmlns:wpg=\"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup\" " .
77
            "xmlns:wpi=\"http://schemas.microsoft.com/office/word/2010/wordprocessingInk\" " .
78
            "xmlns:wne=\"http://schemas.microsoft.com/office/word/2006/wordml\" " .
79
            "xmlns:wps=\"http://schemas.microsoft.com/office/word/2010/wordprocessingShape\" " .
80
            "mc:Ignorable=\"w14 w15 w16se w16cid wp14\"><w:body><w:p w14:paraId=\"504F2588\" " .
81
            "w14:textId=\"54DF26C8\" w:rsidR=\"0090657C\" w:rsidRPr=\"00FA3F61\" " .
82
            "w:rsidRDefault=\"00FA3F61\" w:rsidP=\"00C13DD6\"><w:pPr><w:rPr><w:lang w:val=\"en-US\"/>" .
83
            "</w:rPr></w:pPr><w:r><w:rPr><w:lang w:val=\"en-US\"/></w:rPr><w:t>Hello {{ object }}!</w:t>" .
84
            "</w:r><w:bookmarkStart w:id=\"0\" w:name=\"_GoBack\"/><w:bookmarkEnd w:id=\"0\"/></w:p>" .
85
            "<w:sectPr w:rsidR=\"0090657C\" w:rsidRPr=\"00FA3F61\"><w:pgSz w:w=\"11906\" w:h=\"16838\"/>" .
86
            "<w:pgMar w:top=\"1134\" w:right=\"850\" w:bottom=\"1134\" w:left=\"1701\" w:header=\"708\" " .
87
            "w:footer=\"708\" w:gutter=\"0\"/><w:cols w:space=\"708\"/><w:docGrid w:linePitch=\"360\"/>" .
88
            "</w:sectPr></w:body></w:document>\n"
89
        );
90
        $reporter->close();
91
    }
92
93
    public function testPatchXml(): void
94
    {
95
        $reporter = new PhpDocxTemplate(self::TEMPLATE1);
96
        //test stripTags
97
        $xml = "{<tag>%Hello</w:t><w:t>\nworld%<tag>}\n{<tag>{Hi</w:t><w:t>\nthere}<tag>}\n";
98
        $this->assertEquals(
99
            $reporter->patchXml($xml),
100
            "{%Hello\nworld%}\n{{Hi\nthere}}\n"
101
        );
102
103
        //test colspan
104
        $xml = "<w:tc xeLLm[t6;cT&!Z_#KI8cniins[)UX>TAnAaqg_a}sePvK.OO#Q=B-]cBDFM8UL]8m@i" .
105
               "Ct{% colspan val%}TkuSd<w:r meg+PYSJWO}~k<w:t></w:t></w:r>" .
106
               "<w:gridSpan88MJ@1bX/><w:tcPrL4><w:gridSpan@1bY/>?Nl`z:^kY@FXeJ@P{8WhCt0__/,8woI2." .
107
               "8#[r_Cqig!5Qt{8gl5ls<9Ci|^QN2IK#L[cB9@:XclVQQIxe</w:tc>";
108
        $this->assertEquals(
109
            $reporter->patchXml($xml),
110
            '<w:tc xeLLm[t6;cT&!Z_#KI8cniins[)UX>TAnAaqg_a}sePvK.OO#Q=B-]cBDFM8UL]8m@iCtTkuSd<w:tcPrL4>' .
111
            '<w:gridSpan w:val="{{val}}"/><w:gridSpan@1bY/>?Nl`z:^kY@FXeJ@P{8WhCt0__/,8woI2.8#[r_Cqig!5Qt' .
112
            '{8gl5ls<9Ci|^QN2IK#L[cB9@:XclVQQIxe</w:tc>'
113
        );
114
115
        //test cellbg
116
        $xml = "<w:tc xeLLm[t6;cT&!Z_#KI8cniins[)UX>TAnAaqg_a}sePvK.OO#Q=B-]cBDFM8UL]8m@i" .
117
               "Ct{% cellbg val%}TkuSd<w:r meg+PYSJWO}~k<w:t></w:t></w:r>" .
118
               "<w:shd88MJ@1bX/><w:tcPrL4><w:shd@1bY/>?Nl`z:^kY@FXeJ@P{8WhCt0__/,8woI2." .
119
               "8#[r_Cqig!5Qt{8gl5ls<9Ci|^QN2IK#L[cB9@:XclVQQIxe</w:tc>";
120
        $this->assertEquals(
121
            $reporter->patchXml($xml),
122
            '<w:tc xeLLm[t6;cT&!Z_#KI8cniins[)UX>TAnAaqg_a}sePvK.OO#Q=B-]cBDFM8UL]8m@iCtTkuSd<w:tcPrL4>' .
123
            '<w:shd w:val="clear" w:color="auto" w:fill="{{val}}"/><w:shd@1bY/>?Nl`z:^kY@FXeJ@P{8WhCt0__/,' .
124
            '8woI2.8#[r_Cqig!5Qt{8gl5ls<9Ci|^QN2IK#L[cB9@:XclVQQIxe</w:tc>'
125
        );
126
127
        $xml = "{%r _Rom{X=aC3/s#W#~o<#d:tH^>DTAz;s<}O0RJ#V!wW:]%kR@wzLf*\iu^zAGrr!3]v<SUc|B)o>kA.:*1?,0%}";
128
        $this->assertEquals(
129
            $reporter->patchXml($xml),
130
            '</w:t></w:r><w:r><w:t xml:space="preserve">{%r _Rom{X=aC3/s#W#~o<#d:tH^>DTAz;s<}O0RJ#V!wW:]%kR' .
131
            '@wzLf*\iu^zAGrr!3]v<SUc|B)o>kA.:*1?,0%}</w:t></w:r><w:r><w:t xml:space="preserve">'
132
        );
133
134
        // test vMerge
135
        $xml = "<w:tc></w:tcPr>t/H-Q.X)jC_sI6(J7w-;QI&JpDG}:>f02Zls<8(7&SEyc>" .
136
               "`@P/<Ero^KEbL`EX^<w:t>{% vm %}</w:t></w:tc>";
137
        $this->assertEquals(
138
            $reporter->patchXml($xml),
139
            '<w:tc><w:vMerge w:val="{% if loop.first %}restart{% else %}continue' .
140
            '{% endif %}"/></w:tcPr>t/H-Q.X)jC_sI6(J7w-;QI&JpDG}:>f02Zls<8(7&SEyc>`' .
141
            '@P/<Ero^KEbL`EX^<w:t>{% if loop.first %}{% endif %}</w:t></w:tc>'
142
        );
143
144
        // test hMerge
145
        $xml = "<w:tc></w:tcPr>t/H-Q.X)jC_sI6(J7w-;QI&JpDG}:>f02Zls<8(7&SEyc>" .
146
               "`@P/<Ero^KEbL`EX^<w:t>{% hm %}</w:t></w:tc>";
147
        $this->assertEquals(
148
            $reporter->patchXml($xml),
149
            '{% if loop.first %}<w:tc><w:gridSpan w:val="{{ loop.length }}"/></w:tcPr>t/H-Q.X)' .
150
            'jC_sI6(J7w-;QI&JpDG}:>f02Zls<8(7&SEyc>`@P/<Ero^KEbL`EX^<w:t></w:t></w:tc>{% endif %}'
151
        );
152
153
        // test cleanTags
154
        $xml = '{%&#8216;&lt;&gt;“”‘’%}';
155
        $this->assertEquals(
156
            $reporter->patchXml($xml),
157
            "{%'<>\"\"''%}"
158
        );
159
        $reporter->close();
160
    }
161
162
    public function testRenderXml(): void
163
    {
164
        $reporter = new PhpDocxTemplate(self::TEMPLATE1);
165
        $this->assertEquals(
166
            $reporter->buildXml(["object" => "world"]),
167
            "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n" .
168
            "<w:document xmlns:wpc=\"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas\" " .
169
            "xmlns:cx=\"http://schemas.microsoft.com/office/drawing/2014/chartex\" " .
170
            "xmlns:cx1=\"http://schemas.microsoft.com/office/drawing/2015/9/8/chartex\" " .
171
            "xmlns:cx2=\"http://schemas.microsoft.com/office/drawing/2015/10/21/chartex\" " .
172
            "xmlns:cx3=\"http://schemas.microsoft.com/office/drawing/2016/5/9/chartex\" " .
173
            "xmlns:cx4=\"http://schemas.microsoft.com/office/drawing/2016/5/10/chartex\" " .
174
            "xmlns:cx5=\"http://schemas.microsoft.com/office/drawing/2016/5/11/chartex\" " .
175
            "xmlns:cx6=\"http://schemas.microsoft.com/office/drawing/2016/5/12/chartex\" " .
176
            "xmlns:cx7=\"http://schemas.microsoft.com/office/drawing/2016/5/13/chartex\" " .
177
            "xmlns:cx8=\"http://schemas.microsoft.com/office/drawing/2016/5/14/chartex\" " .
178
            "xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" " .
179
            "xmlns:aink=\"http://schemas.microsoft.com/office/drawing/2016/ink\" " .
180
            "xmlns:am3d=\"http://schemas.microsoft.com/office/drawing/2017/model3d\" " .
181
            "xmlns:o=\"urn:schemas-microsoft-com:office:office\" " .
182
            "xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" " .
183
            "xmlns:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\" " .
184
            "xmlns:v=\"urn:schemas-microsoft-com:vml\" " .
185
            "xmlns:wp14=\"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing\" " .
186
            "xmlns:wp=\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\" " .
187
            "xmlns:w10=\"urn:schemas-microsoft-com:office:word\" " .
188
            "xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" " .
189
            "xmlns:w14=\"http://schemas.microsoft.com/office/word/2010/wordml\" " .
190
            "xmlns:w15=\"http://schemas.microsoft.com/office/word/2012/wordml\" " .
191
            "xmlns:w16cid=\"http://schemas.microsoft.com/office/word/2016/wordml/cid\" " .
192
            "xmlns:w16se=\"http://schemas.microsoft.com/office/word/2015/wordml/symex\" " .
193
            "xmlns:wpg=\"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup\" " .
194
            "xmlns:wpi=\"http://schemas.microsoft.com/office/word/2010/wordprocessingInk\" " .
195
            "xmlns:wne=\"http://schemas.microsoft.com/office/word/2006/wordml\" " .
196
            "xmlns:wps=\"http://schemas.microsoft.com/office/word/2010/wordprocessingShape\" " .
197
            "mc:Ignorable=\"w14 w15 w16se w16cid wp14\"><w:body><w:p w14:paraId=\"504F2588\" " .
198
            "w14:textId=\"54DF26C8\" w:rsidR=\"0090657C\" w:rsidRPr=\"00FA3F61\" " .
199
            "w:rsidRDefault=\"00FA3F61\" w:rsidP=\"00C13DD6\"><w:pPr><w:rPr><w:lang w:val=\"en-US\"/>" .
200
            "</w:rPr></w:pPr><w:r><w:rPr><w:lang w:val=\"en-US\"/></w:rPr><w:t>Hello world!</w:t>" .
201
            "</w:r><w:bookmarkStart w:id=\"0\" w:name=\"_GoBack\"/><w:bookmarkEnd w:id=\"0\"/></w:p>" .
202
            "<w:sectPr w:rsidR=\"0090657C\" w:rsidRPr=\"00FA3F61\"><w:pgSz w:w=\"11906\" w:h=\"16838\"/>" .
203
            "<w:pgMar w:top=\"1134\" w:right=\"850\" w:bottom=\"1134\" w:left=\"1701\" w:header=\"708\" " .
204
            "w:footer=\"708\" w:gutter=\"0\"/><w:cols w:space=\"708\"/><w:docGrid w:linePitch=\"360\"/>" .
205
            "</w:sectPr></w:body></w:document>\n"
206
        );
207
        $reporter->close();
208
    }
209
210
    public function testRender(): void
211
    {
212
        $reporter = new PhpDocxTemplate(self::TEMPLATE2);
213
        $reporter->render(["one" => "1", "two" => "2", "three" => "3", "four" => "4"]);
214
        $this->assertEquals(
215
            $reporter->getXml(),
216
            "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n" .
217
            "<w:document xmlns:wpc=\"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas\" xmlns:c" .
218
            "x=\"http://schemas.microsoft.com/office/drawing/2014/chartex\" xmlns:cx1=\"http://schemas.microsoft." .
219
            "com/office/drawing/2015/9/8/chartex\" xmlns:cx2=\"http://schemas.microsoft.com/office/drawing/2015/1" .
220
            "0/21/chartex\" xmlns:cx3=\"http://schemas.microsoft.com/office/drawing/2016/5/9/chartex\" xmlns:cx4=" .
221
            "\"http://schemas.microsoft.com/office/drawing/2016/5/10/chartex\" xmlns:cx5=\"http://schemas.microso" .
222
            "ft.com/office/drawing/2016/5/11/chartex\" xmlns:cx6=\"http://schemas.microsoft.com/office/drawing/20" .
223
            "16/5/12/chartex\" xmlns:cx7=\"http://schemas.microsoft.com/office/drawing/2016/5/13/chartex\" xmlns:" .
224
            "cx8=\"http://schemas.microsoft.com/office/drawing/2016/5/14/chartex\" xmlns:mc=\"http://schemas.open" .
225
            "xmlformats.org/markup-compatibility/2006\" xmlns:aink=\"http://schemas.microsoft.com/office/drawing/" .
226
            "2016/ink\" xmlns:am3d=\"http://schemas.microsoft.com/office/drawing/2017/model3d\" xmlns:o=\"urn:sch" .
227
            "emas-microsoft-com:office:office\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/r" .
228
            "elationships\" xmlns:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\" xmlns:v=\"urn:" .
229
            "schemas-microsoft-com:vml\" xmlns:wp14=\"http://schemas.microsoft.com/office/word/2010/wordprocessin" .
230
            "gDrawing\" xmlns:wp=\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\" xmlns" .
231
            ":w10=\"urn:schemas-microsoft-com:office:word\" xmlns:w=\"http://schemas.openxmlformats.org/wordproce" .
232
            "ssingml/2006/main\" xmlns:w14=\"http://schemas.microsoft.com/office/word/2010/wordml\" xmlns:w15=\"h" .
233
            "ttp://schemas.microsoft.com/office/word/2012/wordml\" xmlns:w16cid=\"http://schemas.microsoft.com/of" .
234
            "fice/word/2016/wordml/cid\" xmlns:w16se=\"http://schemas.microsoft.com/office/word/2015/wordml/symex" .
235
            "\" xmlns:wpg=\"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup\" xmlns:wpi=\"http:" .
236
            "//schemas.microsoft.com/office/word/2010/wordprocessingInk\" xmlns:wne=\"http://schemas.microsoft.co" .
237
            "m/office/word/2006/wordml\" xmlns:wps=\"http://schemas.microsoft.com/office/word/2010/wordprocessing" .
238
            "Shape\" mc:Ignorable=\"w14 w15 w16se w16cid wp14\"><w:body><w:tbl><w:tblPr><w:tblStyle w:val=\"a3\"/" .
239
            "><w:tblW w:w=\"0\" w:type=\"auto\"/><w:tblLook w:val=\"04A0\" w:firstRow=\"1\" w:lastRow=\"0\" w:fir" .
240
            "stColumn=\"1\" w:lastColumn=\"0\" w:noHBand=\"0\" w:noVBand=\"1\"/></w:tblPr><w:tblGrid><w:gridCol w" .
241
            ":w=\"3115\"/><w:gridCol w:w=\"3115\"/><w:gridCol w:w=\"3115\"/></w:tblGrid><w:tr w:rsidR=\"00031864" .
242
            "\" w14:paraId=\"73B274FD\" w14:textId=\"77777777\" w:rsidTr=\"00135B64\"><w:tc><w:tcPr><w:tcW w:w=\"3" .
243
            "115\" w:type=\"dxa\"/></w:tcPr><w:p w14:paraId=\"29117FB3\" w14:textId=\"713E58B3\" w:rsidR=\"000318" .
244
            "64\" w:rsidRPr=\"0033062B\" w:rsidRDefault=\"00031864\" w:rsidP=\"0033062B\"><w:pPr><w:rPr><w:lang w" .
245
            ":val=\"en-US\"/></w:rPr></w:pPr><w:r><w:rPr><w:lang w:val=\"en-US\"/></w:rPr><w:t>1</w:t></w:r></w:p" .
246
            "></w:tc><w:tc><w:tcPr><w:tcW w:w=\"6230\" w:type=\"dxa\"/><w:gridSpan w:val=\"2\"/></w:tcPr><w:p w14" .
247
            ":paraId=\"4620CF03\" w14:textId=\"7FD6FF29\" w:rsidR=\"00031864\" w:rsidRPr=\"00B6314C\" w:rsidRDefa" .
248
            "ult=\"00B6314C\" w:rsidP=\"0033062B\"><w:pPr><w:rPr><w:lang w:val=\"en-US\"/></w:rPr></w:pPr><w:r><w" .
249
            ":rPr><w:lang w:val=\"en-US\"/></w:rPr><w:t>1</w:t></w:r></w:p></w:tc></w:tr><w:tr w:rsidR=\"00031864" .
250
            "\" w14:paraId=\"638CAE21\" w14:textId=\"77777777\" w:rsidTr=\"0033062B\"><w:tc><w:tcPr><w:tcW w:w=\"" .
251
            "3115\" w:type=\"dxa\"/><w:vMerge w:val=\"restart\"/></w:tcPr><w:p w14:paraId=\"69D3958C\" w14:textId" .
252
            "=\"77777777\" w:rsidR=\"00031864\" w:rsidRPr=\"0033062B\" w:rsidRDefault=\"00031864\" w:rsidP=\"0033" .
253
            "062B\"><w:pPr><w:rPr><w:lang w:val=\"en-US\"/></w:rPr></w:pPr><w:r><w:rPr><w:lang w:val=\"en-US\"/><" .
254
            "/w:rPr><w:t>2</w:t></w:r></w:p><w:p w14:paraId=\"203EF204\" w14:textId=\"751D091A\" w:rsidR=\"000318" .
255
            "64\" w:rsidRPr=\"0033062B\" w:rsidRDefault=\"00031864\" w:rsidP=\"0033062B\"><w:pPr><w:rPr><w:lang w" .
256
            ":val=\"en-US\"/></w:rPr></w:pPr><w:r><w:rPr><w:lang w:val=\"en-US\"/></w:rPr><w:t>3</w:t></w:r></w:p" .
257
            "></w:tc><w:tc><w:tcPr><w:tcW w:w=\"3115\" w:type=\"dxa\"/></w:tcPr><w:p w14:paraId=\"29D750B5\" w14:" .
258
            "textId=\"52111D71\" w:rsidR=\"00031864\" w:rsidRPr=\"00B6314C\" w:rsidRDefault=\"00B6314C\" w:rsidP=" .
259
            "\"0033062B\"><w:pPr><w:rPr><w:lang w:val=\"en-US\"/></w:rPr></w:pPr><w:r><w:rPr><w:lang w:val=\"en-U" .
260
            "S\"/></w:rPr><w:t>2</w:t></w:r></w:p></w:tc><w:tc><w:tcPr><w:tcW w:w=\"3115\" w:type=\"dxa\"/></w:tc" .
261
            "Pr><w:p w14:paraId=\"443FEDA5\" w14:textId=\"77777777\" w:rsidR=\"00031864\" w:rsidRDefault=\"000318" .
262
            "64\" w:rsidP=\"0033062B\"/></w:tc></w:tr><w:tr w:rsidR=\"00031864\" w14:paraId=\"3400FAC6\" w14:text" .
263
            "Id=\"77777777\" w:rsidTr=\"0033062B\"><w:tc><w:tcPr><w:tcW w:w=\"3115\" w:type=\"dxa\"/><w:vMerge/><" .
264
            "/w:tcPr><w:p w14:paraId=\"27010401\" w14:textId=\"299C3CC2\" w:rsidR=\"00031864\" w:rsidRPr=\"003306" .
265
            "2B\" w:rsidRDefault=\"00031864\" w:rsidP=\"0033062B\"><w:pPr><w:rPr><w:lang w:val=\"en-US\"/></w:rPr" .
266
            "></w:pPr></w:p></w:tc><w:tc><w:tcPr><w:tcW w:w=\"3115\" w:type=\"dxa\"/></w:tcPr><w:p w14:paraId=\"6" .
267
            "D034FEF\" w14:textId=\"6465FA34\" w:rsidR=\"00031864\" w:rsidRPr=\"00B6314C\" w:rsidRDefault=\"00B63" .
268
            "14C\" w:rsidP=\"0033062B\"><w:pPr><w:rPr><w:lang w:val=\"en-US\"/></w:rPr></w:pPr><w:r><w:rPr><w:lan" .
269
            "g w:val=\"en-US\"/></w:rPr><w:t>3</w:t></w:r></w:p></w:tc><w:tc><w:tcPr><w:tcW w:w=\"3115\" w:type=" .
270
            "\"dxa\"/></w:tcPr><w:p w14:paraId=\"331E7F28\" w14:textId=\"77777777\" w:rsidR=\"00031864\" w:rsidRDe" .
271
            "fault=\"00031864\" w:rsidP=\"0033062B\"/></w:tc></w:tr><w:tr w:rsidR=\"0033062B\" w14:paraId=\"489E0" .
272
            "54E\" w14:textId=\"77777777\" w:rsidTr=\"0033062B\"><w:tc><w:tcPr><w:tcW w:w=\"3115\" w:type=\"dxa\"" .
273
            "/></w:tcPr><w:p w14:paraId=\"24A13E38\" w14:textId=\"18E3B4BC\" w:rsidR=\"0033062B\" w:rsidRPr=\"003" .
274
            "3062B\" w:rsidRDefault=\"0033062B\" w:rsidP=\"0033062B\"><w:pPr><w:rPr><w:lang w:val=\"en-US\"/></w:" .
275
            "rPr></w:pPr><w:r><w:rPr><w:lang w:val=\"en-US\"/></w:rPr><w:t>4</w:t></w:r></w:p></w:tc><w:tc><w:tcP" .
276
            "r><w:tcW w:w=\"3115\" w:type=\"dxa\"/></w:tcPr><w:p w14:paraId=\"58DCBE56\" w14:textId=\"5D680B0D\" " .
277
            "w:rsidR=\"0033062B\" w:rsidRPr=\"00B6314C\" w:rsidRDefault=\"00B6314C\" w:rsidP=\"0033062B\"><w:pPr>" .
278
            "<w:rPr><w:lang w:val=\"en-US\"/></w:rPr></w:pPr><w:r><w:rPr><w:lang w:val=\"en-US\"/></w:rPr><w:t>4<" .
279
            "/w:t></w:r><w:bookmarkStart w:id=\"0\" w:name=\"_GoBack\"/><w:bookmarkEnd w:id=\"0\"/></w:p></w:tc><" .
280
            "w:tc><w:tcPr><w:tcW w:w=\"3115\" w:type=\"dxa\"/></w:tcPr><w:p w14:paraId=\"277EDAD6\" w14:textId=\"" .
281
            "77777777\" w:rsidR=\"0033062B\" w:rsidRDefault=\"0033062B\" w:rsidP=\"0033062B\"/></w:tc></w:tr></w:" .
282
            "tbl><w:p w14:paraId=\"504F2588\" w14:textId=\"658244D8\" w:rsidR=\"0090657C\" w:rsidRPr=\"0033062B\"" .
283
            " w:rsidRDefault=\"0090657C\" w:rsidP=\"0033062B\"/><w:sectPr w:rsidR=\"0090657C\" w:rsidRPr=\"003306" .
284
            "2B\"><w:pgSz w:w=\"11906\" w:h=\"16838\"/><w:pgMar w:top=\"1134\" w:right=\"850\" w:bottom=\"1134\" " .
285
            "w:left=\"1701\" w:header=\"708\" w:footer=\"708\" w:gutter=\"0\"/><w:cols w:space=\"708\"/><w:docGri" .
286
            "d w:linePitch=\"360\"/></w:sectPr></w:body></w:document>\n"
287
        );
288
        $reporter->save(sys_get_temp_dir() . "/test.docx");
289
    }
290
291
    public function testLineBreak(): void
292
    {
293
        $reporter = new PhpDocxTemplate(self::TEMPLATE3);
294
        $reporter->render(["один" => "значение с \n переносом строки"]);
295
        $this->assertEquals(
296
            $reporter->getXml(),
297
            "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n" .
298
            "<w:document xmlns:wpc=\"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas\" xmlns:c" .
299
            "x=\"http://schemas.microsoft.com/office/drawing/2014/chartex\" xmlns:cx1=\"http://schemas.microsoft." .
300
            "com/office/drawing/2015/9/8/chartex\" xmlns:cx2=\"http://schemas.microsoft.com/office/drawing/2015/1" .
301
            "0/21/chartex\" xmlns:cx3=\"http://schemas.microsoft.com/office/drawing/2016/5/9/chartex\" xmlns:cx4=" .
302
            "\"http://schemas.microsoft.com/office/drawing/2016/5/10/chartex\" xmlns:cx5=\"http://schemas.microso" .
303
            "ft.com/office/drawing/2016/5/11/chartex\" xmlns:cx6=\"http://schemas.microsoft.com/office/drawing/20" .
304
            "16/5/12/chartex\" xmlns:cx7=\"http://schemas.microsoft.com/office/drawing/2016/5/13/chartex\" xmlns:" .
305
            "cx8=\"http://schemas.microsoft.com/office/drawing/2016/5/14/chartex\" xmlns:mc=\"http://schemas.open" .
306
            "xmlformats.org/markup-compatibility/2006\" xmlns:aink=\"http://schemas.microsoft.com/office/drawing/" .
307
            "2016/ink\" xmlns:am3d=\"http://schemas.microsoft.com/office/drawing/2017/model3d\" xmlns:o=\"urn:sch" .
308
            "emas-microsoft-com:office:office\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/r" .
309
            "elationships\" xmlns:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\" xmlns:v=\"urn:" .
310
            "schemas-microsoft-com:vml\" xmlns:wp14=\"http://schemas.microsoft.com/office/word/2010/wordprocessin" .
311
            "gDrawing\" xmlns:wp=\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\" xmlns" .
312
            ":w10=\"urn:schemas-microsoft-com:office:word\" xmlns:w=\"http://schemas.openxmlformats.org/wordproce" .
313
            "ssingml/2006/main\" xmlns:w14=\"http://schemas.microsoft.com/office/word/2010/wordml\" xmlns:w15=\"h" .
314
            "ttp://schemas.microsoft.com/office/word/2012/wordml\" xmlns:w16cid=\"http://schemas.microsoft.com/of" .
315
            "fice/word/2016/wordml/cid\" xmlns:w16se=\"http://schemas.microsoft.com/office/word/2015/wordml/symex" .
316
            "\" xmlns:wpg=\"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup\" xmlns:wpi=\"http:" .
317
            "//schemas.microsoft.com/office/word/2010/wordprocessingInk\" xmlns:wne=\"http://schemas.microsoft.co" .
318
            "m/office/word/2006/wordml\" xmlns:wps=\"http://schemas.microsoft.com/office/word/2010/wordprocessing" .
319
            "Shape\" mc:Ignorable=\"w14 w15 w16se w16cid wp14\"><w:body><w:p w14:paraId=\"504F2588\" w14:textId=" .
320
            "\"0B366F38\" w:rsidR=\"0090657C\" w:rsidRPr=\"00BC38E6\" w:rsidRDefault=\"00BC38E6\" w:rsidP=\"003306" .
321
            "2B\"><w:pPr><w:rPr><w:lang w:val=\"en-US\"/></w:rPr></w:pPr><w:r><w:rPr><w:lang w:val=\"en-US\"/></w" .
322
            ":rPr><w:t xml:space=\"preserve\">значение с </w:t></w:r></w:p><w:p><w:pPr><w:rPr><w:lang w:val=\"en-U" .
323
            "S\"/></w:rPr></w:pPr><w:r><w:rPr><w:lang w:val=\"en-US\"/></w:rPr><w:t xml:space=\"preserve\">".
324
            " переносом строки</w:t></w:r><w:bookmarkStart w:id=\"0\" w:name=\"_GoBack\"/>" .
325
            "<w:bookmarkEnd w:id=\"0\"/></w:p><w:sectPr w:rsidR=\"0090657C\" w:rsidRPr=\"00BC38E6\"><w:pgSz w:w=\"" .
326
            "11906\" w:h=\"16838\"/><w:pgMar w:top=\"1134\" w:right=\"850\" w:bottom=\"1134\" w:left=\"1701\" w:he" .
327
            "ader=\"708\" w:footer=\"708\" w:gutter=\"0\"/><w:cols w:space=\"708\"/><w:docGrid w:linePitch=\"360\"/><" .
328
            "/w:sectPr></w:body></w:document>\n"
329
        );
330
    }
331
332
    public function testCyrillic(): void
333
    {
334
        $reporter = new PhpDocxTemplate(self::TEMPLATE3);
335
        $reporter->render(["один" => "значение"]);
336
        $this->assertEquals(
337
            $reporter->getXml(),
338
            "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n" .
339
            "<w:document xmlns:wpc=\"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas\" xmlns:c" .
340
            "x=\"http://schemas.microsoft.com/office/drawing/2014/chartex\" xmlns:cx1=\"http://schemas.microsoft." .
341
            "com/office/drawing/2015/9/8/chartex\" xmlns:cx2=\"http://schemas.microsoft.com/office/drawing/2015/1" .
342
            "0/21/chartex\" xmlns:cx3=\"http://schemas.microsoft.com/office/drawing/2016/5/9/chartex\" xmlns:cx4=" .
343
            "\"http://schemas.microsoft.com/office/drawing/2016/5/10/chartex\" xmlns:cx5=\"http://schemas.microso" .
344
            "ft.com/office/drawing/2016/5/11/chartex\" xmlns:cx6=\"http://schemas.microsoft.com/office/drawing/20" .
345
            "16/5/12/chartex\" xmlns:cx7=\"http://schemas.microsoft.com/office/drawing/2016/5/13/chartex\" xmlns:" .
346
            "cx8=\"http://schemas.microsoft.com/office/drawing/2016/5/14/chartex\" xmlns:mc=\"http://schemas.open" .
347
            "xmlformats.org/markup-compatibility/2006\" xmlns:aink=\"http://schemas.microsoft.com/office/drawing/" .
348
            "2016/ink\" xmlns:am3d=\"http://schemas.microsoft.com/office/drawing/2017/model3d\" xmlns:o=\"urn:sch" .
349
            "emas-microsoft-com:office:office\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/r" .
350
            "elationships\" xmlns:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\" xmlns:v=\"urn:" .
351
            "schemas-microsoft-com:vml\" xmlns:wp14=\"http://schemas.microsoft.com/office/word/2010/wordprocessin" .
352
            "gDrawing\" xmlns:wp=\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\" xmlns" .
353
            ":w10=\"urn:schemas-microsoft-com:office:word\" xmlns:w=\"http://schemas.openxmlformats.org/wordproce" .
354
            "ssingml/2006/main\" xmlns:w14=\"http://schemas.microsoft.com/office/word/2010/wordml\" xmlns:w15=\"h" .
355
            "ttp://schemas.microsoft.com/office/word/2012/wordml\" xmlns:w16cid=\"http://schemas.microsoft.com/of" .
356
            "fice/word/2016/wordml/cid\" xmlns:w16se=\"http://schemas.microsoft.com/office/word/2015/wordml/symex" .
357
            "\" xmlns:wpg=\"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup\" xmlns:wpi=\"http:" .
358
            "//schemas.microsoft.com/office/word/2010/wordprocessingInk\" xmlns:wne=\"http://schemas.microsoft.co" .
359
            "m/office/word/2006/wordml\" xmlns:wps=\"http://schemas.microsoft.com/office/word/2010/wordprocessing" .
360
            "Shape\" mc:Ignorable=\"w14 w15 w16se w16cid wp14\"><w:body><w:p w14:paraId=\"504F2588\" w14:textId=" .
361
            "\"0B366F38\" w:rsidR=\"0090657C\" w:rsidRPr=\"00BC38E6\" w:rsidRDefault=\"00BC38E6\" w:rsidP=\"003306" .
362
            "2B\"><w:pPr><w:rPr><w:lang w:val=\"en-US\"/></w:rPr></w:pPr><w:r><w:rPr><w:lang w:val=\"en-US\"/></w" .
363
            ":rPr><w:t xml:space=\"preserve\">значение</w:t></w:r><w:bookmarkStart w:id=\"0\" w:name=\"_GoBack\"/>" .
364
            "<w:bookmarkEnd w:id=\"0\"/></w:p><w:sectPr w:rsidR=\"0090657C\" w:rsidRPr=\"00BC38E6\"><w:pgSz w:w=\"" .
365
            "11906\" w:h=\"16838\"/><w:pgMar w:top=\"1134\" w:right=\"850\" w:bottom=\"1134\" w:left=\"1701\" w:he" .
366
            "ader=\"708\" w:footer=\"708\" w:gutter=\"0\"/><w:cols w:space=\"708\"/><w:docGrid w:linePitch=\"360\"/><" .
367
            "/w:sectPr></w:body></w:document>\n"
368
        );
369
    }
370
371
    public function testForLoop(): void
372
    {
373
        $reporter = new PhpDocxTemplate(self::TEMPLATE4);
374
        $reporter->render(["сотрудники" => [
375
            [
376
                "фамилия" => "Иванов",
377
                "имя" => "Иван",
378
                "отчество" => "Иванович",
379
                "дети" => [
380
                    [
381
                        "фамилия" => "Иванова",
382
                        "имя" => "Алена",
383
                        "отчество" => "Ивановна",
384
                        "возраст" => 25
385
                    ],
386
                    [
387
                        "фамилия" => "Иванов",
388
                        "имя" => "Михаил",
389
                        "отчество" => "Иванович",
390
                        "возраст" => 6
391
                    ]
392
                ],
393
                "возраст" => 50
394
            ],
395
            [
396
                "фамилия" => "Петров",
397
                "имя" => "Петр",
398
                "отчество" => "Петрович",
399
                "возраст" => 30
400
            ]
401
        ]]);
402
        $this->assertEquals(
403
            $reporter->getXml(),
404
            "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n" .
405
            "<w:document xmlns:wpc=\"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas\" xmlns:c" .
406
            "x=\"http://schemas.microsoft.com/office/drawing/2014/chartex\" xmlns:cx1=\"http://schemas.microsoft." .
407
            "com/office/drawing/2015/9/8/chartex\" xmlns:cx2=\"http://schemas.microsoft.com/office/drawing/2015/1" .
408
            "0/21/chartex\" xmlns:cx3=\"http://schemas.microsoft.com/office/drawing/2016/5/9/chartex\" xmlns:cx4=" .
409
            "\"http://schemas.microsoft.com/office/drawing/2016/5/10/chartex\" xmlns:cx5=\"http://schemas.microso" .
410
            "ft.com/office/drawing/2016/5/11/chartex\" xmlns:cx6=\"http://schemas.microsoft.com/office/drawing/20" .
411
            "16/5/12/chartex\" xmlns:cx7=\"http://schemas.microsoft.com/office/drawing/2016/5/13/chartex\" xmlns:" .
412
            "cx8=\"http://schemas.microsoft.com/office/drawing/2016/5/14/chartex\" xmlns:mc=\"http://schemas.open" .
413
            "xmlformats.org/markup-compatibility/2006\" xmlns:aink=\"http://schemas.microsoft.com/office/drawing/" .
414
            "2016/ink\" xmlns:am3d=\"http://schemas.microsoft.com/office/drawing/2017/model3d\" xmlns:o=\"urn:sch" .
415
            "emas-microsoft-com:office:office\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/r" .
416
            "elationships\" xmlns:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\" xmlns:v=\"urn:" .
417
            "schemas-microsoft-com:vml\" xmlns:wp14=\"http://schemas.microsoft.com/office/word/2010/wordprocessin" .
418
            "gDrawing\" xmlns:wp=\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\" xmlns" .
419
            ":w10=\"urn:schemas-microsoft-com:office:word\" xmlns:w=\"http://schemas.openxmlformats.org/wordproce" .
420
            "ssingml/2006/main\" xmlns:w14=\"http://schemas.microsoft.com/office/word/2010/wordml\" xmlns:w15=\"h" .
421
            "ttp://schemas.microsoft.com/office/word/2012/wordml\" xmlns:w16cid=\"http://schemas.microsoft.com/of" .
422
            "fice/word/2016/wordml/cid\" xmlns:w16se=\"http://schemas.microsoft.com/office/word/2015/wordml/symex" .
423
            "\" xmlns:wpg=\"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup\" xmlns:wpi=\"http:" .
424
            "//schemas.microsoft.com/office/word/2010/wordprocessingInk\" xmlns:wne=\"http://schemas.microsoft.co" .
425
            "m/office/word/2006/wordml\" xmlns:wps=\"http://schemas.microsoft.com/office/word/2010/wordprocessing" .
426
            "Shape\" mc:Ignorable=\"w14 w15 w16se w16cid wp14\"><w:body><w:p w14:paraId=\"45D5C362\" w14:textId=" .
427
            "\"79C82D83\" w:rsidR=\"00AF4B5B\" w:rsidRDefault=\"005D75A1\" w:rsidP=\"006B0D50\"><w:pPr><w:pStyle w" .
428
            ":val=\"a4\"/><w:numPr><w:ilvl w:val=\"0\"/><w:numId w:val=\"2\"/></w:numPr></w:pPr><w:proofErr w:typ" .
429
            "e=\"gramStart\"/><w:r w:rsidRPr=\"005D75A1\"><w:t xml:space=\"preserve\">Иванов Иван Иванович</w:t><" .
430
            "/w:r><w:r w:rsidR=\"00FE09C8\" w:rsidRPr=\"00FE09C8\"><w:t xml:space=\"preserve\">, </w:t></w:r><w:r" .
431
            " w:rsidR=\"00FE09C8\"><w:t>возраст</w:t></w:r><w:r w:rsidR=\"00FE09C8\" w:rsidRPr=\"00FE09C8\"><w:t>" .
432
            ":</w:t></w:r><w:r w:rsidR=\"005E422E\"><w:t xml:space=\"preserve\"> </w:t></w:r><w:r w:rsidR=\"005E4" .
433
            "22E\" w:rsidRPr=\"00DE2B94\"><w:t>50</w:t></w:r></w:p><w:p w14:paraId=\"78D1FA3D\" w14:textId=\"55EF" .
434
            "7A47\" w:rsidR=\"00AF4B5B\" w:rsidRDefault=\"00DE2B94\" w:rsidP=\"0031223E\"><w:pPr><w:pStyle w:val=" .
435
            "\"a4\"/></w:pPr><w:r><w:t xml:space=\"preserve\">- </w:t></w:r><w:proofErr w:type=\"gramStart\"/><w:" .
436
            "r w:rsidRPr=\"00DE2B94\"><w:t xml:space=\"preserve\">Иванова Алена Ивановна</w:t></w:r><w:r w:rsidR=" .
437
            "\"00126257\" w:rsidRPr=\"00126257\"><w:t xml:space=\"preserve\"> </w:t></w:r></w:p><w:p w14:paraId=" .
438
            "\"78D1FA3D\" w14:textId=\"55EF7A47\" w:rsidR=\"00AF4B5B\" w:rsidRDefault=\"00DE2B94\" w:rsidP=\"00312" .
439
            "23E\"><w:pPr><w:pStyle w:val=\"a4\"/></w:pPr><w:r><w:t xml:space=\"preserve\">- </w:t></w:r><w:proofErr " .
440
            "w:type=\"gramStart\"/><w:r w:rsidRPr=\"00DE2B94\"><w:t xml:space=\"preserve\">Иванов Михаил Иванович" .
441
            "</w:t></w:r><w:r w:rsidR=\"00126257\" w:rsidRPr=\"00126257\"><w:t xml:space=\"preserve\"> </w:t></w:" .
442
            "r></w:p><w:p w14:paraId=\"45D5C362\" w14:textId=\"79C82D83\" w:rsidR=\"00AF4B5B\" w:rsidRDefault=\"0" .
443
            "05D75A1\" w:rsidP=\"006B0D50\"><w:pPr><w:pStyle w:val=\"a4\"/><w:numPr><w:ilvl w:val=\"0\"/><w:numId" .
444
            " w:val=\"2\"/></w:numPr></w:pPr><w:proofErr w:type=\"gramStart\"/><w:r w:rsidRPr=\"005D75A1\"><w:t x" .
445
            "ml:space=\"preserve\">Петров Петр Петрович</w:t></w:r><w:r w:rsidR=\"00FE09C8\" w:rsidRPr=\"00FE09C8" .
446
            "\"><w:t xml:space=\"preserve\">, </w:t></w:r><w:r w:rsidR=\"00FE09C8\"><w:t>возраст</w:t></w:r><w:r " .
447
            "w:rsidR=\"00FE09C8\" w:rsidRPr=\"00FE09C8\"><w:t>:</w:t></w:r><w:r w:rsidR=\"005E422E\"><w:t xml:spa" .
448
            "ce=\"preserve\"> </w:t></w:r><w:r w:rsidR=\"005E422E\" w:rsidRPr=\"00DE2B94\"><w:t>30</w:t></w:r></w" .
449
            ":p><w:p w14:paraId=\"4B66446E\" w14:textId=\"2D5C0B86\" w:rsidR=\"0024376E\" w:rsidRDefault=\"002437" .
450
            "6E\" w:rsidP=\"00AF4B5B\"/><w:p w14:paraId=\"3F32EC2C\" w14:textId=\"77777777\" w:rsidR=\"0024376E\"" .
451
            " w:rsidRPr=\"008D21C0\" w:rsidRDefault=\"0024376E\" w:rsidP=\"00AF4B5B\"/><w:sectPr w:rsidR=\"002437" .
452
            "6E\" w:rsidRPr=\"008D21C0\"><w:pgSz w:w=\"11906\" w:h=\"16838\"/><w:pgMar w:top=\"1134\" w:right=\"8" .
453
            "50\" w:bottom=\"1134\" w:left=\"1701\" w:header=\"708\" w:footer=\"708\" w:gutter=\"0\"/><w:cols w:s" .
454
            "pace=\"708\"/><w:docGrid w:linePitch=\"360\"/></w:sectPr></w:body></w:document>\n"
455
        );
456
    }
457
458
    public function testTable(): void
459
    {
460
        $reporter = new PhpDocxTemplate(self::TEMPLATE5);
461
        $reporter->render(["records" => [
462
            [
463
                "a" => "a1",
464
                "b" => "b1",
465
                "c" => "c1"
466
            ],
467
            [
468
                "a" => "a2",
469
                "b" => "b2",
470
                "c" => "c2"
471
            ]
472
        ]]);
473
        $this->assertEquals(
474
            $reporter->getXml(),
475
            "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n" .
476
            "<w:document xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\"><w:body><w:tbl>" .
477
            "<w:tblPr/><w:tblGrid><w:gridCol w:w=\"1526\"/><w:gridCol w:w=\"1843\"/><w:gridCol w:w=\"5919\"/></w:" .
478
            "tblGrid><w:tr><w:trPr><w:trHeight w:val=\"200\" w:hRule=\"auto\"/><w:jc w:val=\"left\"/></w:trPr><w:" .
479
            "tc><w:tcPr><w:tcW w:w=\"1526\" w:type=\"dxa\"/><w:tcBorders><w:top w:val=\"single\" w:color=\"000000" .
480
            "\" w:sz=\"4\"/><w:left w:val=\"single\" w:color=\"000000\" w:sz=\"4\"/><w:bottom w:val=\"single\" w:" .
481
            "color=\"000000\" w:sz=\"4\"/><w:right w:val=\"single\" w:color=\"000000\" w:sz=\"4\"/></w:tcBorders>" .
482
            "<w:shd w:color=\"000000\" w:fill=\"ffffff\" w:val=\"clear\"/><w:tcMar><w:left w:w=\"108\" w:type=\"d" .
483
            "xa\"/><w:right w:w=\"108\" w:type=\"dxa\"/></w:tcMar><w:vAlign w:val=\"top\"/></w:tcPr><w:p><w:pPr><" .
484
            "w:spacing w:before=\"0\" w:after=\"0\" w:line=\"240\"/><w:ind w:right=\"0\" w:left=\"0\" w:firstLine" .
485
            "=\"0\"/><w:jc w:val=\"left\"/><w:rPr><w:rFonts w:ascii=\"Calibri\" w:hAnsi=\"Calibri\" w:cs=\"Calibr" .
486
            "i\" w:eastAsia=\"Calibri\"/><w:color w:val=\"auto\"/><w:spacing w:val=\"0\"/><w:position w:val=\"0\"" .
487
            "/><w:sz w:val=\"22\"/><w:shd w:fill=\"auto\" w:val=\"clear\"/></w:rPr></w:pPr><w:r><w:rPr><w:rFonts " .
488
            "w:ascii=\"Calibri\" w:hAnsi=\"Calibri\" w:cs=\"Calibri\" w:eastAsia=\"Calibri\"/><w:color w:val=\"au" .
489
            "to\"/><w:spacing w:val=\"0\"/><w:position w:val=\"0\"/><w:sz w:val=\"22\"/><w:shd w:fill=\"auto\" w:" .
490
            "val=\"clear\"/></w:rPr><w:t xml:space=\"preserve\">A</w:t></w:r></w:p></w:tc><w:tc><w:tcPr><w:tcW w:" .
491
            "w=\"1843\" w:type=\"dxa\"/><w:tcBorders><w:top w:val=\"single\" w:color=\"000000\" w:sz=\"4\"/><w:le" .
492
            "ft w:val=\"single\" w:color=\"000000\" w:sz=\"4\"/><w:bottom w:val=\"single\" w:color=\"000000\" w:s" .
493
            "z=\"4\"/><w:right w:val=\"single\" w:color=\"000000\" w:sz=\"4\"/></w:tcBorders><w:shd w:color=\"000" .
494
            "000\" w:fill=\"ffffff\" w:val=\"clear\"/><w:tcMar><w:left w:w=\"108\" w:type=\"dxa\"/><w:right w:w=\"" .
495
            "108\" w:type=\"dxa\"/></w:tcMar><w:vAlign w:val=\"top\"/></w:tcPr><w:p><w:pPr><w:spacing w:before=\"" .
496
            "0\" w:after=\"0\" w:line=\"240\"/><w:ind w:right=\"0\" w:left=\"0\" w:firstLine=\"0\"/><w:jc w:val=" .
497
            "\"left\"/><w:rPr><w:rFonts w:ascii=\"Calibri\" w:hAnsi=\"Calibri\" w:cs=\"Calibri\" w:eastAsia=\"Cal" .
498
            "ibri\"/><w:color w:val=\"auto\"/><w:spacing w:val=\"0\"/><w:position w:val=\"0\"/><w:sz w:val=\"22\"" .
499
            "/><w:shd w:fill=\"auto\" w:val=\"clear\"/></w:rPr></w:pPr><w:r><w:rPr><w:rFonts w:ascii=\"Calibri\" " .
500
            "w:hAnsi=\"Calibri\" w:cs=\"Calibri\" w:eastAsia=\"Calibri\"/><w:color w:val=\"auto\"/><w:spacing w:v" .
501
            "al=\"0\"/><w:position w:val=\"0\"/><w:sz w:val=\"22\"/><w:shd w:fill=\"auto\" w:val=\"clear\"/></w:r" .
502
            "Pr><w:t xml:space=\"preserve\">B</w:t></w:r></w:p></w:tc><w:tc><w:tcPr><w:tcW w:w=\"5919\" w:type=\"" .
503
            "dxa\"/><w:tcBorders><w:top w:val=\"single\" w:color=\"000000\" w:sz=\"4\"/><w:left w:val=\"single\" " .
504
            "w:color=\"000000\" w:sz=\"4\"/><w:bottom w:val=\"single\" w:color=\"000000\" w:sz=\"4\"/><w:right w:" .
505
            "val=\"single\" w:color=\"000000\" w:sz=\"4\"/></w:tcBorders><w:shd w:color=\"000000\" w:fill=\"fffff" .
506
            "f\" w:val=\"clear\"/><w:tcMar><w:left w:w=\"108\" w:type=\"dxa\"/><w:right w:w=\"108\" w:type=\"dxa\"" .
507
            "/></w:tcMar><w:vAlign w:val=\"top\"/></w:tcPr><w:p><w:pPr><w:spacing w:before=\"0\" w:after=\"0\" w" .
508
            ":line=\"240\"/><w:ind w:right=\"0\" w:left=\"0\" w:firstLine=\"0\"/><w:jc w:val=\"left\"/><w:rPr><w:" .
509
            "rFonts w:ascii=\"Calibri\" w:hAnsi=\"Calibri\" w:cs=\"Calibri\" w:eastAsia=\"Calibri\"/><w:color w:v" .
510
            "al=\"auto\"/><w:spacing w:val=\"0\"/><w:position w:val=\"0\"/><w:sz w:val=\"22\"/><w:shd w:fill=\"au" .
511
            "to\" w:val=\"clear\"/></w:rPr></w:pPr><w:r><w:rPr><w:rFonts w:ascii=\"Calibri\" w:hAnsi=\"Calibri\" " .
512
            "w:cs=\"Calibri\" w:eastAsia=\"Calibri\"/><w:color w:val=\"auto\"/><w:spacing w:val=\"0\"/><w:positio" .
513
            "n w:val=\"0\"/><w:sz w:val=\"22\"/><w:shd w:fill=\"auto\" w:val=\"clear\"/></w:rPr><w:t xml:space=\"" .
514
            "preserve\">C</w:t></w:r></w:p></w:tc></w:tr><w:tr><w:trPr><w:trHeight w:val=\"1\" w:hRule=\"atLeast\"" .
515
            "/><w:jc w:val=\"left\"/></w:trPr><w:tc><w:tcPr><w:tcW w:w=\"1526\" w:type=\"dxa\"/><w:tcBorders><w:" .
516
            "top w:val=\"single\" w:color=\"000000\" w:sz=\"4\"/><w:left w:val=\"single\" w:color=\"000000\" w:sz" .
517
            "=\"4\"/><w:bottom w:val=\"single\" w:color=\"000000\" w:sz=\"4\"/><w:right w:val=\"single\" w:color=" .
518
            "\"000000\" w:sz=\"4\"/></w:tcBorders><w:shd w:color=\"000000\" w:fill=\"ffffff\" w:val=\"clear\"/><w" .
519
            ":tcMar><w:left w:w=\"108\" w:type=\"dxa\"/><w:right w:w=\"108\" w:type=\"dxa\"/></w:tcMar><w:vAlign " .
520
            "w:val=\"top\"/></w:tcPr><w:p><w:pPr><w:spacing w:before=\"0\" w:after=\"0\" w:line=\"240\"/><w:ind w" .
521
            ":right=\"0\" w:left=\"0\" w:firstLine=\"0\"/><w:jc w:val=\"left\"/><w:rPr><w:rFonts w:ascii=\"Calibr" .
522
            "i\" w:hAnsi=\"Calibri\" w:cs=\"Calibri\" w:eastAsia=\"Calibri\"/><w:color w:val=\"auto\"/><w:spacing" .
523
            " w:val=\"0\"/><w:position w:val=\"0\"/><w:sz w:val=\"22\"/><w:shd w:fill=\"auto\" w:val=\"clear\"/><" .
524
            "/w:rPr></w:pPr><w:r><w:rPr><w:rFonts w:ascii=\"Calibri\" w:hAnsi=\"Calibri\" w:cs=\"Calibri\" w:east" .
525
            "Asia=\"Calibri\"/><w:color w:val=\"auto\"/><w:spacing w:val=\"0\"/><w:position w:val=\"0\"/><w:sz w:" .
526
            "val=\"22\"/><w:shd w:fill=\"auto\" w:val=\"clear\"/></w:rPr><w:t xml:space=\"preserve\">a1</w:t></w:" .
527
            "r></w:p></w:tc><w:tc><w:tcPr><w:tcW w:w=\"1843\" w:type=\"dxa\"/><w:tcBorders><w:top w:val=\"single\"" .
528
            " w:color=\"000000\" w:sz=\"4\"/><w:left w:val=\"single\" w:color=\"000000\" w:sz=\"4\"/><w:bottom w" .
529
            ":val=\"single\" w:color=\"000000\" w:sz=\"4\"/><w:right w:val=\"single\" w:color=\"000000\" w:sz=\"4" .
530
            "\"/></w:tcBorders><w:shd w:color=\"000000\" w:fill=\"ffffff\" w:val=\"clear\"/><w:tcMar><w:left w:w=" .
531
            "\"108\" w:type=\"dxa\"/><w:right w:w=\"108\" w:type=\"dxa\"/></w:tcMar><w:vAlign w:val=\"top\"/></w:" .
532
            "tcPr><w:p><w:pPr><w:spacing w:before=\"0\" w:after=\"0\" w:line=\"240\"/><w:ind w:right=\"0\" w:left" .
533
            "=\"0\" w:firstLine=\"0\"/><w:jc w:val=\"left\"/><w:rPr><w:rFonts w:ascii=\"Calibri\" w:hAnsi=\"Calib" .
534
            "ri\" w:cs=\"Calibri\" w:eastAsia=\"Calibri\"/><w:color w:val=\"auto\"/><w:spacing w:val=\"0\"/><w:po" .
535
            "sition w:val=\"0\"/><w:sz w:val=\"22\"/><w:shd w:fill=\"auto\" w:val=\"clear\"/></w:rPr></w:pPr><w:r" .
536
            "><w:rPr><w:rFonts w:ascii=\"Calibri\" w:hAnsi=\"Calibri\" w:cs=\"Calibri\" w:eastAsia=\"Calibri\"/><" .
537
            "w:color w:val=\"auto\"/><w:spacing w:val=\"0\"/><w:position w:val=\"0\"/><w:sz w:val=\"22\"/><w:shd " .
538
            "w:fill=\"auto\" w:val=\"clear\"/></w:rPr><w:t xml:space=\"preserve\">b1</w:t></w:r></w:p></w:tc><w:t" .
539
            "c><w:tcPr><w:tcW w:w=\"5919\" w:type=\"dxa\"/><w:tcBorders><w:top w:val=\"single\" w:color=\"000000\"" .
540
            " w:sz=\"4\"/><w:left w:val=\"single\" w:color=\"000000\" w:sz=\"4\"/><w:bottom w:val=\"single\" w:c" .
541
            "olor=\"000000\" w:sz=\"4\"/><w:right w:val=\"single\" w:color=\"000000\" w:sz=\"4\"/></w:tcBorders><" .
542
            "w:shd w:color=\"000000\" w:fill=\"ffffff\" w:val=\"clear\"/><w:tcMar><w:left w:w=\"108\" w:type=\"dx" .
543
            "a\"/><w:right w:w=\"108\" w:type=\"dxa\"/></w:tcMar><w:vAlign w:val=\"top\"/></w:tcPr><w:p><w:pPr><w" .
544
            ":spacing w:before=\"0\" w:after=\"0\" w:line=\"240\"/><w:ind w:right=\"0\" w:left=\"0\" w:firstLine=" .
545
            "\"0\"/><w:jc w:val=\"left\"/><w:rPr><w:rFonts w:ascii=\"Calibri\" w:hAnsi=\"Calibri\" w:cs=\"Calibri" .
546
            "\" w:eastAsia=\"Calibri\"/><w:color w:val=\"auto\"/><w:spacing w:val=\"0\"/><w:position w:val=\"0\"/" .
547
            "><w:sz w:val=\"22\"/><w:shd w:fill=\"auto\" w:val=\"clear\"/></w:rPr></w:pPr><w:r><w:rPr><w:rFonts w" .
548
            ":ascii=\"Calibri\" w:hAnsi=\"Calibri\" w:cs=\"Calibri\" w:eastAsia=\"Calibri\"/><w:color w:val=\"aut" .
549
            "o\"/><w:spacing w:val=\"0\"/><w:position w:val=\"0\"/><w:sz w:val=\"22\"/><w:shd w:fill=\"auto\" w:v" .
550
            "al=\"clear\"/></w:rPr><w:t xml:space=\"preserve\">c1</w:t></w:r></w:p></w:tc></w:tr><w:tr><w:trPr><w" .
551
            ":trHeight w:val=\"1\" w:hRule=\"atLeast\"/><w:jc w:val=\"left\"/></w:trPr><w:tc><w:tcPr><w:tcW w:w=\"" .
552
            "1526\" w:type=\"dxa\"/><w:tcBorders><w:top w:val=\"single\" w:color=\"000000\" w:sz=\"4\"/><w:left " .
553
            "w:val=\"single\" w:color=\"000000\" w:sz=\"4\"/><w:bottom w:val=\"single\" w:color=\"000000\" w:sz=\"" .
554
            "4\"/><w:right w:val=\"single\" w:color=\"000000\" w:sz=\"4\"/></w:tcBorders><w:shd w:color=\"000000" .
555
            "\" w:fill=\"ffffff\" w:val=\"clear\"/><w:tcMar><w:left w:w=\"108\" w:type=\"dxa\"/><w:right w:w=\"10" .
556
            "8\" w:type=\"dxa\"/></w:tcMar><w:vAlign w:val=\"top\"/></w:tcPr><w:p><w:pPr><w:spacing w:before=\"0\"" .
557
            " w:after=\"0\" w:line=\"240\"/><w:ind w:right=\"0\" w:left=\"0\" w:firstLine=\"0\"/><w:jc w:val=\"l" .
558
            "eft\"/><w:rPr><w:rFonts w:ascii=\"Calibri\" w:hAnsi=\"Calibri\" w:cs=\"Calibri\" w:eastAsia=\"Calibr" .
559
            "i\"/><w:color w:val=\"auto\"/><w:spacing w:val=\"0\"/><w:position w:val=\"0\"/><w:sz w:val=\"22\"/><" .
560
            "w:shd w:fill=\"auto\" w:val=\"clear\"/></w:rPr></w:pPr><w:r><w:rPr><w:rFonts w:ascii=\"Calibri\" w:h" .
561
            "Ansi=\"Calibri\" w:cs=\"Calibri\" w:eastAsia=\"Calibri\"/><w:color w:val=\"auto\"/><w:spacing w:val=" .
562
            "\"0\"/><w:position w:val=\"0\"/><w:sz w:val=\"22\"/><w:shd w:fill=\"auto\" w:val=\"clear\"/></w:rPr>" .
563
            "<w:t xml:space=\"preserve\">a2</w:t></w:r></w:p></w:tc><w:tc><w:tcPr><w:tcW w:w=\"1843\" w:type=\"dx" .
564
            "a\"/><w:tcBorders><w:top w:val=\"single\" w:color=\"000000\" w:sz=\"4\"/><w:left w:val=\"single\" w:" .
565
            "color=\"000000\" w:sz=\"4\"/><w:bottom w:val=\"single\" w:color=\"000000\" w:sz=\"4\"/><w:right w:va" .
566
            "l=\"single\" w:color=\"000000\" w:sz=\"4\"/></w:tcBorders><w:shd w:color=\"000000\" w:fill=\"ffffff\"" .
567
            " w:val=\"clear\"/><w:tcMar><w:left w:w=\"108\" w:type=\"dxa\"/><w:right w:w=\"108\" w:type=\"dxa\"/" .
568
            "></w:tcMar><w:vAlign w:val=\"top\"/></w:tcPr><w:p><w:pPr><w:spacing w:before=\"0\" w:after=\"0\" w:l" .
569
            "ine=\"240\"/><w:ind w:right=\"0\" w:left=\"0\" w:firstLine=\"0\"/><w:jc w:val=\"left\"/><w:rPr><w:rF" .
570
            "onts w:ascii=\"Calibri\" w:hAnsi=\"Calibri\" w:cs=\"Calibri\" w:eastAsia=\"Calibri\"/><w:color w:val" .
571
            "=\"auto\"/><w:spacing w:val=\"0\"/><w:position w:val=\"0\"/><w:sz w:val=\"22\"/><w:shd w:fill=\"auto" .
572
            "\" w:val=\"clear\"/></w:rPr></w:pPr><w:r><w:rPr><w:rFonts w:ascii=\"Calibri\" w:hAnsi=\"Calibri\" w:" .
573
            "cs=\"Calibri\" w:eastAsia=\"Calibri\"/><w:color w:val=\"auto\"/><w:spacing w:val=\"0\"/><w:position " .
574
            "w:val=\"0\"/><w:sz w:val=\"22\"/><w:shd w:fill=\"auto\" w:val=\"clear\"/></w:rPr><w:t xml:space=\"pr" .
575
            "eserve\">b2</w:t></w:r></w:p></w:tc><w:tc><w:tcPr><w:tcW w:w=\"5919\" w:type=\"dxa\"/><w:tcBorders><" .
576
            "w:top w:val=\"single\" w:color=\"000000\" w:sz=\"4\"/><w:left w:val=\"single\" w:color=\"000000\" w:" .
577
            "sz=\"4\"/><w:bottom w:val=\"single\" w:color=\"000000\" w:sz=\"4\"/><w:right w:val=\"single\" w:colo" .
578
            "r=\"000000\" w:sz=\"4\"/></w:tcBorders><w:shd w:color=\"000000\" w:fill=\"ffffff\" w:val=\"clear\"/>" .
579
            "<w:tcMar><w:left w:w=\"108\" w:type=\"dxa\"/><w:right w:w=\"108\" w:type=\"dxa\"/></w:tcMar><w:vAlig" .
580
            "n w:val=\"top\"/></w:tcPr><w:p><w:pPr><w:spacing w:before=\"0\" w:after=\"0\" w:line=\"240\"/><w:ind" .
581
            " w:right=\"0\" w:left=\"0\" w:firstLine=\"0\"/><w:jc w:val=\"left\"/><w:rPr><w:rFonts w:ascii=\"Cali" .
582
            "bri\" w:hAnsi=\"Calibri\" w:cs=\"Calibri\" w:eastAsia=\"Calibri\"/><w:color w:val=\"auto\"/><w:spaci" .
583
            "ng w:val=\"0\"/><w:position w:val=\"0\"/><w:sz w:val=\"22\"/><w:shd w:fill=\"auto\" w:val=\"clear\"/" .
584
            "></w:rPr></w:pPr><w:r><w:rPr><w:rFonts w:ascii=\"Calibri\" w:hAnsi=\"Calibri\" w:cs=\"Calibri\" w:ea" .
585
            "stAsia=\"Calibri\"/><w:color w:val=\"auto\"/><w:spacing w:val=\"0\"/><w:position w:val=\"0\"/><w:sz " .
586
            "w:val=\"22\"/><w:shd w:fill=\"auto\" w:val=\"clear\"/></w:rPr><w:t xml:space=\"preserve\">c2</w:t></" .
587
            "w:r></w:p></w:tc></w:tr></w:tbl><w:p><w:pPr><w:spacing w:before=\"0\" w:after=\"200\" w:line=\"276\"" .
588
            "/><w:ind w:right=\"0\" w:left=\"0\" w:firstLine=\"0\"/><w:jc w:val=\"left\"/><w:rPr><w:rFonts w:asci" .
589
            "i=\"Calibri\" w:hAnsi=\"Calibri\" w:cs=\"Calibri\" w:eastAsia=\"Calibri\"/><w:color w:val=\"auto\"/>" .
590
            "<w:spacing w:val=\"0\"/><w:position w:val=\"0\"/><w:sz w:val=\"22\"/><w:shd w:fill=\"auto\" w:val=\"" .
591
            "clear\"/></w:rPr></w:pPr></w:p></w:body></w:document>\n"
592
        );
593
    }
594
}
595