ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilDefaultPlaceholderValuesTest Class Reference
+ Inheritance diagram for ilDefaultPlaceholderValuesTest:
+ Collaboration diagram for ilDefaultPlaceholderValuesTest:

Public Member Functions

 testGetPlaceholderValues ()
 
 testGetPlaceholderValuesForPreview ()
 

Additional Inherited Members

- Protected Member Functions inherited from ilCertificateBaseTestCase
 setUp ()
 
 tearDown ()
 
 assertDoesNotThrow (callable $cb, string $message='')
 
 assertThrows (callable $cb, ?string $expected_class=null, ?string $expected_message=null)
 @template T of Throwable More...
 
 setGlobalVariable (string $name, mixed $value)
 
- Protected Attributes inherited from ilCertificateBaseTestCase
Container $dic
 

Detailed Description

Definition at line 23 of file ilDefaultPlaceholderValuesTest.php.

Member Function Documentation

◆ testGetPlaceholderValues()

ilDefaultPlaceholderValuesTest::testGetPlaceholderValues ( )

Definition at line 25 of file ilDefaultPlaceholderValuesTest.php.

25 : void
26 {
27 $objectMock = $this->getMockBuilder(ilObjUser::class)
28 ->disableOriginalConstructor()
29 ->onlyMethods(
30 [
31 'getLogin',
32 'getFullname',
33 'getFirstname',
34 'getLastname',
35 'getUTitle',
36 'getGender',
37 'getBirthday',
38 'getInstitution',
39 'getDepartment',
40 'getStreet',
41 'getCity',
42 'getZipcode',
43 'getCountry',
44 'getMatriculation'
45 ]
46 )
47 ->getMock();
48
49 $objectMock->expects($this->once())
50 ->method('getLogin')
51 ->willReturn('a_login');
52
53 $objectMock->expects($this->once())
54 ->method('getFullname')
55 ->willReturn('Niels Theen');
56
57 $objectMock->expects($this->once())
58 ->method('getFirstname')
59 ->willReturn('Niels');
60
61 $objectMock->expects($this->once())
62 ->method('getLastname')
63 ->willReturn('Theen');
64
65 $objectMock->expects($this->once())
66 ->method('getUTitle')
67 ->willReturn('');
68
69 $objectMock->expects($this->once())
70 ->method('getGender')
71 ->willReturn('m');
72
73 $objectMock->expects($this->once())
74 ->method('getBirthday')
75 ->willReturn('2018-10-10');
76
77 $objectMock->expects($this->once())
78 ->method('getInstitution')
79 ->willReturn('');
80
81 $objectMock->expects($this->once())
82 ->method('getDepartment')
83 ->willReturn('');
84
85 $objectMock->expects($this->once())
86 ->method('getStreet')
87 ->willReturn('');
88
89 $objectMock->expects($this->once())
90 ->method('getCity')
91 ->willReturn('');
92
93 $objectMock->expects($this->once())
94 ->method('getZipcode')
95 ->willReturn('');
96
97 $objectMock->expects($this->once())
98 ->method('getCountry')
99 ->willReturn('');
100
101 $objectMock->expects($this->once())
102 ->method('getMatriculation')
103 ->willReturn('');
104
105 $objectHelper = $this->getMockBuilder(ilCertificateObjectHelper::class)
106 ->getMock();
107
108 $objectHelper->expects($this->once())
109 ->method('getInstanceByObjId')
110 ->with(100)
111 ->willReturn($objectMock);
112
113 $dateHelper = $this->getMockBuilder(ilCertificateDateHelper::class)
114 ->getMock();
115
116 $dateHelper->expects($this->exactly(2))
117 ->method('formatDate')
118 ->willReturn('2018-09-10');
119
120 $dateHelper->expects($this->once())
121 ->method('formatDateTime')
122 ->willReturn('2018-09-10 12:01:33');
123
124 $language = $this->getMockBuilder(ilLanguage::class)
125 ->disableOriginalConstructor()
126 ->getMock();
127
128 $language->method('txt')
129 ->willReturn('Something');
130
131 $profile = $this->getMockBuilder(Profile::class)
132 ->disableOriginalConstructor()
133 ->getMock();
134
135 $utilHelper = $this->getMockBuilder(ilCertificateUtilHelper::class)
136 ->disableOriginalConstructor()
137 ->getMock();
138
139 $utilHelper->method('prepareFormOutput')
140 ->willReturnCallback(function ($input) {
141 return $input;
142 });
143
144 $userDefinePlaceholderMock = $this->getMockBuilder(ilUserDefinedFieldsPlaceholderValues::class)
145 ->disableOriginalConstructor()
146 ->getMock();
147
148 $userDefinePlaceholderMock->method('getPlaceholderValues')
149 ->willReturn([]);
150
151 $userDefinePlaceholderMock->method('getPlaceholderValuesForPreview')
152 ->willReturn([]);
153
154 $uuid_factory_mock = $this->getMockBuilder(ILIAS\Data\UUID\Factory::class)
155 ->getMock();
156 $uuid_factory_mock->method('uuid4AsString')->willReturn('randomUniqueString');
157
158 $placeHolderObject = new ilDefaultPlaceholderValues(
159 $objectHelper,
160 $dateHelper,
161 3,
162 $language,
163 $profile,
164 $utilHelper,
165 $userDefinePlaceholderMock,
166 $uuid_factory_mock,
167 2
168 );
169 $placeHolderObject->setUserLanguage($language);
170
171 $result = $placeHolderObject->getPlaceholderValues(100, 200);
172
173 $this->assertEquals(
174 [
175 'CERTIFICATE_ID' => '',
176 'USER_LOGIN' => 'a_login',
177 'USER_FULLNAME' => 'Niels Theen',
178 'USER_FIRSTNAME' => 'Niels',
179 'USER_LASTNAME' => 'Theen',
180 'USER_TITLE' => '',
181 'USER_SALUTATION' => 'Something',
182 'USER_BIRTHDAY' => '2018-09-10',
183 'USER_INSTITUTION' => '',
184 'USER_DEPARTMENT' => '',
185 'USER_STREET' => '',
186 'USER_CITY' => '',
187 'USER_ZIPCODE' => '',
188 'USER_COUNTRY' => '',
189 'USER_MATRICULATION' => '',
190 'DATE_COMPLETED' => '',
191 'DATETIME_COMPLETED' => '',
192 'DATE' => '2018-09-10',
193 'DATETIME' => '2018-09-10 12:01:33'
194 ],
195 $result
196 );
197 }
Collection of basic placeholder values that can be used.
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.

◆ testGetPlaceholderValuesForPreview()

ilDefaultPlaceholderValuesTest::testGetPlaceholderValuesForPreview ( )

Definition at line 199 of file ilDefaultPlaceholderValuesTest.php.

199 : void
200 {
201 $objectHelper = $this->getMockBuilder(ilCertificateObjectHelper::class)
202 ->getMock();
203
204 $dateHelper = $this->getMockBuilder(ilCertificateDateHelper::class)
205 ->getMock();
206
207 $dateHelper->method('formatDate')
208 ->willReturn('2018-09-09');
209
210 $dateHelper->method('formatDateTime')
211 ->willReturn('2018-09-09 14:00:30');
212
213 $language = $this->getMockBuilder(ilLanguage::class)
214 ->disableOriginalConstructor()
215 ->getMock();
216
217 $language->method('txt')
218 ->willReturn('Something');
219
220 $profile = $this->getMockBuilder(Profile::class)
221 ->disableOriginalConstructor()
222 ->getMock();
223
224 $utilHelper = $this->getMockBuilder(ilCertificateUtilHelper::class)
225 ->disableOriginalConstructor()
226 ->getMock();
227
228 $utilHelper->method('prepareFormOutput')
229 ->willReturnCallback(function ($input) {
230 return $input;
231 });
232
233 $userDefinePlaceholderMock = $this->getMockBuilder(ilUserDefinedFieldsPlaceholderValues::class)
234 ->disableOriginalConstructor()
235 ->getMock();
236
237 $userDefinePlaceholderMock->method('getPlaceholderValues')
238 ->willReturn([]);
239
240 $userDefinePlaceholderMock->method('getPlaceholderValuesForPreview')
241 ->willReturn([]);
242
243 $uuid_factory_mock = $this->getMockBuilder(ILIAS\Data\UUID\Factory::class)
244 ->getMock();
245 $uuid_factory_mock->method('uuid4AsString')->willReturn('randomUniqueString');
246
247 $placeHolderObject = new ilDefaultPlaceholderValues(
248 $objectHelper,
249 $dateHelper,
250 3,
251 $language,
252 $profile,
253 $utilHelper,
254 $userDefinePlaceholderMock,
255 $uuid_factory_mock,
256 2
257 );
258
259 $result = $placeHolderObject->getPlaceholderValuesForPreview(
260 100,
261 10
262 );
263
264 $this->assertSame(
265 [
266 'CERTIFICATE_ID' => 'randomUniqueString',
267 'USER_LOGIN' => 'Something',
268 'USER_FULLNAME' => 'Something',
269 'USER_FIRSTNAME' => 'Something',
270 'USER_LASTNAME' => 'Something',
271 'USER_TITLE' => 'Something',
272 'USER_SALUTATION' => 'Something',
273 'USER_BIRTHDAY' => '2018-09-09',
274 'USER_INSTITUTION' => 'Something',
275 'USER_DEPARTMENT' => 'Something',
276 'USER_STREET' => 'Something',
277 'USER_CITY' => 'Something',
278 'USER_ZIPCODE' => 'Something',
279 'USER_COUNTRY' => 'Something',
280 'USER_MATRICULATION' => 'Something',
281 'DATE' => '2018-09-09',
282 'DATETIME' => '2018-09-09 14:00:30',
283 'DATE_COMPLETED' => '2018-09-09',
284 'DATETIME_COMPLETED' => '2018-09-09 14:00:30'
285 ],
286 $result
287 );
288 }

The documentation for this class was generated from the following file: