@@ -51,14 +51,14 @@ final public function testTemplateCanBeSavedInTemporaryLocation()
51
51
$ templateZip = new \ZipArchive ();
52
52
$ templateZip ->open ($ templateFqfn );
53
53
$ templateXml = $ templateZip ->getFromName ('word/document.xml ' );
54
- if ($ templateZip ->close () === false ) {
54
+ if (false === $ templateZip ->close ()) {
55
55
throw new \Exception ("Could not close zip file \"{$ templateZip }\". " );
56
56
}
57
57
58
58
$ documentZip = new \ZipArchive ();
59
59
$ documentZip ->open ($ documentFqfn );
60
60
$ documentXml = $ documentZip ->getFromName ('word/document.xml ' );
61
- if ($ documentZip ->close () === false ) {
61
+ if (false === $ documentZip ->close ()) {
62
62
throw new \Exception ("Could not close zip file \"{$ documentZip }\". " );
63
63
}
64
64
@@ -78,19 +78,19 @@ final public function testTemplateCanBeSavedInTemporaryLocation()
78
78
*/
79
79
final public function testXslStyleSheetCanBeApplied ($ actualDocumentFqfn )
80
80
{
81
- $ expectedDocumentFqfn = __DIR__ . " /_files/documents/without_table_macros.docx " ;
81
+ $ expectedDocumentFqfn = __DIR__ . ' /_files/documents/without_table_macros.docx ' ;
82
82
83
83
$ actualDocumentZip = new \ZipArchive ();
84
84
$ actualDocumentZip ->open ($ actualDocumentFqfn );
85
85
$ actualDocumentXml = $ actualDocumentZip ->getFromName ('word/document.xml ' );
86
- if ($ actualDocumentZip ->close () === false ) {
86
+ if (false === $ actualDocumentZip ->close ()) {
87
87
throw new \Exception ("Could not close zip file \"{$ actualDocumentFqfn }\". " );
88
88
}
89
89
90
90
$ expectedDocumentZip = new \ZipArchive ();
91
91
$ expectedDocumentZip ->open ($ expectedDocumentFqfn );
92
92
$ expectedDocumentXml = $ expectedDocumentZip ->getFromName ('word/document.xml ' );
93
- if ($ expectedDocumentZip ->close () === false ) {
93
+ if (false === $ expectedDocumentZip ->close ()) {
94
94
throw new \Exception ("Could not close zip file \"{$ expectedDocumentFqfn }\". " );
95
95
}
96
96
@@ -116,7 +116,7 @@ final public function testXslStyleSheetCanNotBeAppliedOnFailureOfSettingParamete
116
116
* We have to use error control below, because \XSLTProcessor::setParameter omits warning on failure.
117
117
* This warning fails the test.
118
118
*/
119
- @$ templateProcessor ->applyXslStyleSheet ($ xslDOMDocument , array (1 => 'somevalue ' ));
119
+ @$ templateProcessor ->applyXslStyleSheet ($ xslDOMDocument , array (1 => htmlspecialchars ( 'somevalue ' , ENT_COMPAT , ' UTF-8 ' ) ));
120
120
}
121
121
122
122
/**
@@ -157,9 +157,9 @@ public function testCloneRow()
157
157
);
158
158
159
159
$ docName = 'clone-test-result.docx ' ;
160
- $ templateProcessor ->setValue ('tableHeader ' , utf8_decode ('ééé ' ));
160
+ $ templateProcessor ->setValue ('tableHeader ' , utf8_decode (htmlspecialchars ( 'ééé ' , ENT_COMPAT , ' UTF-8 ' ) ));
161
161
$ templateProcessor ->cloneRow ('userId ' , 1 );
162
- $ templateProcessor ->setValue ('userId#1 ' , 'Test ' );
162
+ $ templateProcessor ->setValue ('userId#1 ' , htmlspecialchars ( 'Test ' , ENT_COMPAT , ' UTF-8 ' ) );
163
163
$ templateProcessor ->saveAs ($ docName );
164
164
$ docFound = file_exists ($ docName );
165
165
unlink ($ docName );
@@ -181,9 +181,9 @@ public function testVariablesCanBeReplacedInHeaderAndFooter()
181
181
);
182
182
183
183
$ docName = 'header-footer-test-result.docx ' ;
184
- $ templateProcessor ->setValue ('headerValue ' , 'Header Value ' );
185
- $ templateProcessor ->setValue ('documentContent ' , 'Document text. ' );
186
- $ templateProcessor ->setValue ('footerValue ' , 'Footer Value ' );
184
+ $ templateProcessor ->setValue ('headerValue ' , htmlspecialchars ( 'Header Value ' , ENT_COMPAT , ' UTF-8 ' ) );
185
+ $ templateProcessor ->setValue ('documentContent ' , htmlspecialchars ( 'Document text. ' , ENT_COMPAT , ' UTF-8 ' ) );
186
+ $ templateProcessor ->setValue ('footerValue ' , htmlspecialchars ( 'Footer Value ' , ENT_COMPAT , ' UTF-8 ' ) );
187
187
$ templateProcessor ->saveAs ($ docName );
188
188
$ docFound = file_exists ($ docName );
189
189
unlink ($ docName );
0 commit comments