ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
ilCertificateValueReplacementTest.php
Go to the documentation of this file.
1 <?php
2 
19 declare(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]
31 Hurray [NAME] you have received [PRIZE]
32 </xml>';
33 
34  $replacedContent = $replacement->replace($placeholderValues, $certificateContent);
35 
36  $expected = '<xml>
37 [BACKGROUND_IMAGE]
38 Hurray 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
53 Hurray [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
61 Hurray Peter you have received a fantastic prize
62 </xml>';
63 
64  $this->assertSame($expected, $replacedContent);
65  }
66 }