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