Skip to content

Commit 757b49b

Browse files
author
Roman Syroeshko
committed
Merged TemplateProcessorTest.
1 parent 310991b commit 757b49b

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

tests/PhpWord/Tests/TemplateProcessorTest.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,14 @@ final public function testTemplateCanBeSavedInTemporaryLocation()
5151
$templateZip = new \ZipArchive();
5252
$templateZip->open($templateFqfn);
5353
$templateXml = $templateZip->getFromName('word/document.xml');
54-
if ($templateZip->close() === false) {
54+
if (false === $templateZip->close()) {
5555
throw new \Exception("Could not close zip file \"{$templateZip}\".");
5656
}
5757

5858
$documentZip = new \ZipArchive();
5959
$documentZip->open($documentFqfn);
6060
$documentXml = $documentZip->getFromName('word/document.xml');
61-
if ($documentZip->close() === false) {
61+
if (false === $documentZip->close()) {
6262
throw new \Exception("Could not close zip file \"{$documentZip}\".");
6363
}
6464

@@ -78,19 +78,19 @@ final public function testTemplateCanBeSavedInTemporaryLocation()
7878
*/
7979
final public function testXslStyleSheetCanBeApplied($actualDocumentFqfn)
8080
{
81-
$expectedDocumentFqfn = __DIR__ . "/_files/documents/without_table_macros.docx";
81+
$expectedDocumentFqfn = __DIR__ . '/_files/documents/without_table_macros.docx';
8282

8383
$actualDocumentZip = new \ZipArchive();
8484
$actualDocumentZip->open($actualDocumentFqfn);
8585
$actualDocumentXml = $actualDocumentZip->getFromName('word/document.xml');
86-
if ($actualDocumentZip->close() === false) {
86+
if (false === $actualDocumentZip->close()) {
8787
throw new \Exception("Could not close zip file \"{$actualDocumentFqfn}\".");
8888
}
8989

9090
$expectedDocumentZip = new \ZipArchive();
9191
$expectedDocumentZip->open($expectedDocumentFqfn);
9292
$expectedDocumentXml = $expectedDocumentZip->getFromName('word/document.xml');
93-
if ($expectedDocumentZip->close() === false) {
93+
if (false === $expectedDocumentZip->close()) {
9494
throw new \Exception("Could not close zip file \"{$expectedDocumentFqfn}\".");
9595
}
9696

@@ -116,7 +116,7 @@ final public function testXslStyleSheetCanNotBeAppliedOnFailureOfSettingParamete
116116
* We have to use error control below, because \XSLTProcessor::setParameter omits warning on failure.
117117
* This warning fails the test.
118118
*/
119-
@$templateProcessor->applyXslStyleSheet($xslDOMDocument, array(1 => 'somevalue'));
119+
@$templateProcessor->applyXslStyleSheet($xslDOMDocument, array(1 => htmlspecialchars('somevalue', ENT_COMPAT, 'UTF-8')));
120120
}
121121

122122
/**
@@ -157,9 +157,9 @@ public function testCloneRow()
157157
);
158158

159159
$docName = 'clone-test-result.docx';
160-
$templateProcessor->setValue('tableHeader', utf8_decode('ééé'));
160+
$templateProcessor->setValue('tableHeader', utf8_decode(htmlspecialchars('ééé', ENT_COMPAT, 'UTF-8')));
161161
$templateProcessor->cloneRow('userId', 1);
162-
$templateProcessor->setValue('userId#1', 'Test');
162+
$templateProcessor->setValue('userId#1', htmlspecialchars('Test', ENT_COMPAT, 'UTF-8'));
163163
$templateProcessor->saveAs($docName);
164164
$docFound = file_exists($docName);
165165
unlink($docName);
@@ -181,9 +181,9 @@ public function testVariablesCanBeReplacedInHeaderAndFooter()
181181
);
182182

183183
$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'));
187187
$templateProcessor->saveAs($docName);
188188
$docFound = file_exists($docName);
189189
unlink($docName);

0 commit comments

Comments
 (0)