From 757b49b5a8d567e4b38628be3ef69116fc8d4c99 Mon Sep 17 00:00:00 2001 From: Roman Syroeshko Date: Sun, 16 Aug 2015 21:13:15 +0400 Subject: [PATCH] Merged ``TemplateProcessorTest``. --- tests/PhpWord/Tests/TemplateProcessorTest.php | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/tests/PhpWord/Tests/TemplateProcessorTest.php b/tests/PhpWord/Tests/TemplateProcessorTest.php index 04d1e77715..69b4f99821 100644 --- a/tests/PhpWord/Tests/TemplateProcessorTest.php +++ b/tests/PhpWord/Tests/TemplateProcessorTest.php @@ -51,14 +51,14 @@ final public function testTemplateCanBeSavedInTemporaryLocation() $templateZip = new \ZipArchive(); $templateZip->open($templateFqfn); $templateXml = $templateZip->getFromName('word/document.xml'); - if ($templateZip->close() === false) { + if (false === $templateZip->close()) { throw new \Exception("Could not close zip file \"{$templateZip}\"."); } $documentZip = new \ZipArchive(); $documentZip->open($documentFqfn); $documentXml = $documentZip->getFromName('word/document.xml'); - if ($documentZip->close() === false) { + if (false === $documentZip->close()) { throw new \Exception("Could not close zip file \"{$documentZip}\"."); } @@ -78,19 +78,19 @@ final public function testTemplateCanBeSavedInTemporaryLocation() */ final public function testXslStyleSheetCanBeApplied($actualDocumentFqfn) { - $expectedDocumentFqfn = __DIR__ . "/_files/documents/without_table_macros.docx"; + $expectedDocumentFqfn = __DIR__ . '/_files/documents/without_table_macros.docx'; $actualDocumentZip = new \ZipArchive(); $actualDocumentZip->open($actualDocumentFqfn); $actualDocumentXml = $actualDocumentZip->getFromName('word/document.xml'); - if ($actualDocumentZip->close() === false) { + if (false === $actualDocumentZip->close()) { throw new \Exception("Could not close zip file \"{$actualDocumentFqfn}\"."); } $expectedDocumentZip = new \ZipArchive(); $expectedDocumentZip->open($expectedDocumentFqfn); $expectedDocumentXml = $expectedDocumentZip->getFromName('word/document.xml'); - if ($expectedDocumentZip->close() === false) { + if (false === $expectedDocumentZip->close()) { throw new \Exception("Could not close zip file \"{$expectedDocumentFqfn}\"."); } @@ -116,7 +116,7 @@ final public function testXslStyleSheetCanNotBeAppliedOnFailureOfSettingParamete * We have to use error control below, because \XSLTProcessor::setParameter omits warning on failure. * This warning fails the test. */ - @$templateProcessor->applyXslStyleSheet($xslDOMDocument, array(1 => 'somevalue')); + @$templateProcessor->applyXslStyleSheet($xslDOMDocument, array(1 => htmlspecialchars('somevalue', ENT_COMPAT, 'UTF-8'))); } /** @@ -157,9 +157,9 @@ public function testCloneRow() ); $docName = 'clone-test-result.docx'; - $templateProcessor->setValue('tableHeader', utf8_decode('ééé')); + $templateProcessor->setValue('tableHeader', utf8_decode(htmlspecialchars('ééé', ENT_COMPAT, 'UTF-8'))); $templateProcessor->cloneRow('userId', 1); - $templateProcessor->setValue('userId#1', 'Test'); + $templateProcessor->setValue('userId#1', htmlspecialchars('Test', ENT_COMPAT, 'UTF-8')); $templateProcessor->saveAs($docName); $docFound = file_exists($docName); unlink($docName); @@ -181,9 +181,9 @@ public function testVariablesCanBeReplacedInHeaderAndFooter() ); $docName = 'header-footer-test-result.docx'; - $templateProcessor->setValue('headerValue', 'Header Value'); - $templateProcessor->setValue('documentContent', 'Document text.'); - $templateProcessor->setValue('footerValue', 'Footer Value'); + $templateProcessor->setValue('headerValue', htmlspecialchars('Header Value', ENT_COMPAT, 'UTF-8')); + $templateProcessor->setValue('documentContent', htmlspecialchars('Document text.', ENT_COMPAT, 'UTF-8')); + $templateProcessor->setValue('footerValue', htmlspecialchars('Footer Value', ENT_COMPAT, 'UTF-8')); $templateProcessor->saveAs($docName); $docFound = file_exists($docName); unlink($docName);