Skip to content

Commit aa13b54

Browse files
committed
testSetValues with a zero replacement
1 parent 98d0127 commit aa13b54

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

tests/PhpWordTests/TemplateProcessorTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -630,16 +630,25 @@ public function testSetValues(): void
630630
$templateProcessor = new TestableTemplateProcesor($mainPart);
631631
$templateProcessor->setValues(['firstname' => 'John', 'lastname' => 'Doe']);
632632
self::assertStringContainsString('Hello John Doe', $templateProcessor->getMainPart());
633+
self::assertStringNotContainsString('Hello ${firstname} ${lastname}', $templateProcessor->getMainPart());
633634

634635
// test with a specific limit that is lower than the number of replacements
635636
$templateProcessor = new TestableTemplateProcesor($mainPart);
636637
$templateProcessor->setValues(['firstname' => 'Jane', 'lastname' => 'Smith'], 2);
637638
self::assertStringContainsString('Hello Jane Smith', $templateProcessor->getMainPart());
639+
self::assertStringContainsString('Hello ${firstname} ${lastname}', $templateProcessor->getMainPart());
638640

639641
// test with a limit for only one replacement
640642
$templateProcessor = new TestableTemplateProcesor($mainPart);
641643
$templateProcessor->setValues(['firstname' => 'Alice', 'lastname' => 'Wonderland'], 1);
642644
self::assertStringContainsString('Hello Alice Wonderland', $templateProcessor->getMainPart());
645+
self::assertStringContainsString('Hello ${firstname} ${lastname}', $templateProcessor->getMainPart());
646+
647+
// Test with a limit of 0 for a result with no replacements
648+
$templateProcessor = new TestableTemplateProcesor($mainPart);
649+
$templateProcessor->setValues(['firstname' => 'Test', 'lastname' => 'User'], 0);
650+
self::assertStringContainsString('Hello ${firstname} ${lastname}', $templateProcessor->getMainPart());
651+
self::assertStringNotContainsString('Hello Test User', $templateProcessor->getMainPart());
643652
}
644653

645654
/**

0 commit comments

Comments
 (0)