diff --git a/tests/PhpWord/TemplateProcessorTest.php b/tests/PhpWord/TemplateProcessorTest.php
index fa84cf3b..e4789671 100644
--- a/tests/PhpWord/TemplateProcessorTest.php
+++ b/tests/PhpWord/TemplateProcessorTest.php
@@ -425,6 +425,9 @@ final class TemplateProcessorTest extends \PHPUnit\Framework\TestCase
$this->assertEquals('$15,000.00. ${variable_name}', $fixed);
}
+ /**
+ * @covers ::getMainPartName
+ */
public function testMainPartNameDetection()
{
$templateProcessor = new TemplateProcessor(__DIR__ . '/_files/templates/document22-xml.docx');
@@ -433,4 +436,21 @@ final class TemplateProcessorTest extends \PHPUnit\Framework\TestCase
$this->assertEquals($variables, $templateProcessor->getVariables());
}
+
+ /**
+ * @covers ::getVariables
+ */
+ public function testGetVariables()
+ {
+ $templateProcessor = new TestableTemplateProcesor();
+
+ $variables = $templateProcessor->getVariablesForPart('normal text');
+ $this->assertEquals(array(), $variables);
+
+ $variables = $templateProcessor->getVariablesForPart('${documentContent}');
+ $this->assertEquals(array('documentContent'), $variables);
+
+ $variables = $templateProcessor->getVariablesForPart('$15,000.00. ${variable_name}');
+ $this->assertEquals(array('variable_name'), $variables);
+ }
}
diff --git a/tests/PhpWord/_includes/TestableTemplateProcesor.php b/tests/PhpWord/_includes/TestableTemplateProcesor.php
index f76da417..65e83695 100644
--- a/tests/PhpWord/_includes/TestableTemplateProcesor.php
+++ b/tests/PhpWord/_includes/TestableTemplateProcesor.php
@@ -17,6 +17,12 @@
namespace PhpOffice\PhpWord;
+/**
+ * This class is used to expose publicly methods that are otherwise private or protected.
+ * This makes testing those methods easier
+ *
+ * @author troosan
+ */
class TestableTemplateProcesor extends TemplateProcessor
{
public function __construct()
@@ -27,4 +33,11 @@ class TestableTemplateProcesor extends TemplateProcessor
{
return parent::fixBrokenMacros($documentPart);
}
+
+ public function getVariablesForPart($documentPartXML)
+ {
+ $documentPartXML = parent::fixBrokenMacros($documentPartXML);
+
+ return parent::getVariablesForPart($documentPartXML);
+ }
}