diff --git a/tests/PhpWord/TemplateProcessorTest.php b/tests/PhpWord/TemplateProcessorTest.php
index e4789671..73b4910c 100644
--- a/tests/PhpWord/TemplateProcessorTest.php
+++ b/tests/PhpWord/TemplateProcessorTest.php
@@ -393,6 +393,36 @@ final class TemplateProcessorTest extends \PHPUnit\Framework\TestCase
}
}
+ /**
+ * @covers ::cloneBlock
+ * @test
+ */
+ public function testCloneBlock()
+ {
+ $mainPart = '
+
+
+
+ ${CLONEME}
+
+
+
+
+ This block will be cloned
+
+
+
+
+ ${/CLONEME}
+
+ ';
+
+ $templateProcessor = new TestableTemplateProcesor($mainPart);
+ $templateProcessor->cloneBlock('CLONEME', 3);
+
+ $this->assertEquals(3, substr_count($templateProcessor->getMainPart(), 'This block will be cloned'));
+ }
+
/**
* Template macros can be fixed.
*
diff --git a/tests/PhpWord/_includes/TestableTemplateProcesor.php b/tests/PhpWord/_includes/TestableTemplateProcesor.php
index 65e83695..3b6f5b56 100644
--- a/tests/PhpWord/_includes/TestableTemplateProcesor.php
+++ b/tests/PhpWord/_includes/TestableTemplateProcesor.php
@@ -25,8 +25,9 @@ namespace PhpOffice\PhpWord;
*/
class TestableTemplateProcesor extends TemplateProcessor
{
- public function __construct()
+ public function __construct($mainPart = null)
{
+ $this->tempDocumentMainPart = $mainPart;
}
public function fixBrokenMacros($documentPart)
@@ -40,4 +41,9 @@ class TestableTemplateProcesor extends TemplateProcessor
return parent::getVariablesForPart($documentPartXML);
}
+
+ public function getMainPart()
+ {
+ return $this->tempDocumentMainPart;
+ }
}