Skip to content

Commit 16a6f23

Browse files
committed
testSetValues with different limit values
1 parent 88a2646 commit 16a6f23

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

tests/PhpWordTests/TemplateProcessorTest.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -629,8 +629,17 @@ public function testSetValues(): void
629629

630630
$templateProcessor = new TestableTemplateProcesor($mainPart);
631631
$templateProcessor->setValues(['firstname' => 'John', 'lastname' => 'Doe']);
632-
633632
self::assertStringContainsString('Hello John Doe', $templateProcessor->getMainPart());
633+
634+
// test with a specific limit that is lower than the number of replacements
635+
$templateProcessor = new TestableTemplateProcesor($mainPart);
636+
$templateProcessor->setValues(['firstname' => 'Jane', 'lastname' => 'Smith'], 2);
637+
self::assertStringContainsString('Hello Jane Smith', $templateProcessor->getMainPart());
638+
639+
// test with a limit for only one replacement
640+
$templateProcessor = new TestableTemplateProcesor($mainPart);
641+
$templateProcessor->setValues(['firstname' => 'Alice', 'lastname' => 'Wonderland'], 1);
642+
self::assertStringContainsString('Hello Alice Wonderland', $templateProcessor->getMainPart());
634643
}
635644

636645
/**

0 commit comments

Comments
 (0)