ILIAS  trunk Revision v11.0_alpha-1744-gb0451eebef4
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilExercisePlaceholderDescriptionTest.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
23 use ilLanguage;
24 use ilTemplate;
27 
32 {
33  public function testPlaceholderGetHtmlDescription(): void
34  {
35  $languageMock = $this->getMockBuilder(ilLanguage::class)
36  ->disableOriginalConstructor()
37  ->onlyMethods(['txt', 'loadLanguageModule'])
38  ->getMock();
39 
40  $templateMock = $this->getMockBuilder(ilTemplate::class)
41  ->disableOriginalConstructor()
42  ->getMock();
43 
44  $userDefinePlaceholderMock = $this->getMockBuilder(ilUserDefinedFieldsPlaceholderDescription::class)
45  ->disableOriginalConstructor()
46  ->getMock();
47 
48  $userDefinePlaceholderMock->method('createPlaceholderHtmlDescription')
49  ->willReturn('');
50 
51  $userDefinePlaceholderMock->method('getPlaceholderDescriptions')
52  ->willReturn([]);
53 
54  $templateMock->method('get')
55  ->willReturn('');
56 
57  $placeholderDescriptionObject = new ExercisePlaceholderDescription(null, $languageMock, $userDefinePlaceholderMock);
58 
59  $html = $placeholderDescriptionObject->createPlaceholderHtmlDescription($templateMock);
60 
61  $this->assertSame('', $html);
62  }
63 
64  public function testPlaceholderDescriptions(): void
65  {
66  $languageMock = $this->getMockBuilder(ilLanguage::class)
67  ->disableOriginalConstructor()
68  ->onlyMethods(['txt', 'loadLanguageModule'])
69  ->getMock();
70 
71  $languageMock->expects($this->exactly(22))
72  ->method('txt')
73  ->willReturn('Something translated');
74 
75  $userDefinePlaceholderMock = $this->getMockBuilder(ilUserDefinedFieldsPlaceholderDescription::class)
76  ->disableOriginalConstructor()
77  ->getMock();
78 
79  $userDefinePlaceholderMock->method('createPlaceholderHtmlDescription')
80  ->willReturn('');
81 
82  $userDefinePlaceholderMock->method('getPlaceholderDescriptions')
83  ->willReturn([]);
84 
85  $placeholderDescriptionObject = new ExercisePlaceholderDescription(null, $languageMock, $userDefinePlaceholderMock);
86 
87  $placeHolders = $placeholderDescriptionObject->getPlaceholderDescriptions();
88 
89  $this->assertSame(
90  [
91  'CERTIFICATE_ID' => 'Something translated',
92  'USER_LOGIN' => 'Something translated',
93  'USER_FULLNAME' => 'Something translated',
94  'USER_FIRSTNAME' => 'Something translated',
95  'USER_LASTNAME' => 'Something translated',
96  'USER_TITLE' => 'Something translated',
97  'USER_SALUTATION' => 'Something translated',
98  'USER_BIRTHDAY' => 'Something translated',
99  'USER_INSTITUTION' => 'Something translated',
100  'USER_DEPARTMENT' => 'Something translated',
101  'USER_STREET' => 'Something translated',
102  'USER_CITY' => 'Something translated',
103  'USER_ZIPCODE' => 'Something translated',
104  'USER_COUNTRY' => 'Something translated',
105  'USER_MATRICULATION' => 'Something translated',
106  'DATE' => 'Something translated',
107  'DATETIME' => 'Something translated',
108  'RESULT_PASSED' => 'Something translated',
109  'RESULT_MARK' => 'Something translated',
110  'EXERCISE_TITLE' => 'Something translated',
111  'DATE_COMPLETED' => 'Something translated',
112  'DATETIME_COMPLETED' => 'Something translated'
113  ],
114  $placeHolders
115  );
116  }
117 }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null