ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilCertificateValueReplacementTest.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22{
23 public function testReplace(): void
24 {
25 $replacement = new ilCertificateValueReplacement();
26
27 $placeholderValues = ['NAME' => 'Peter', 'PRIZE' => 'a fantastic prize'];
28
29 $certificateContent = '<xml>
30[BACKGROUND_IMAGE]
31Hurray [NAME] you have received [PRIZE]
32</xml>';
33
34 $replacedContent = $replacement->replace($placeholderValues, $certificateContent);
35
36 $expected = '<xml>
37[BACKGROUND_IMAGE]
38Hurray Peter you have received a fantastic prize
39</xml>';
40
41 $this->assertSame($expected, $replacedContent);
42 }
43
44 public function testReplaceClientWebDir(): void
45 {
46 $replacement = new ilCertificateValueReplacement();
47
48 $placeholderValues = ['NAME' => 'Peter', 'PRIZE' => 'a fantastic prize'];
49
50 $certificateContent = '<xml>
51[BACKGROUND_IMAGE]
52[CLIENT_WEB_DIR]/background.jpg
53Hurray [NAME] you have received [PRIZE]
54</xml>';
55
56 $replacedContent = $replacement->replace($placeholderValues, $certificateContent);
57
58 $expected = '<xml>
59[BACKGROUND_IMAGE]
60[CLIENT_WEB_DIR]/background.jpg
61Hurray Peter you have received a fantastic prize
62</xml>';
63
64 $this->assertSame($expected, $replacedContent);
65 }
66}