11 $database = $this->getMockBuilder(
'ilDBInterface')
14 $database->method(
'nextId')
17 $database->method(
'insert')->with(
20 'id' => array(
'integer', 141),
21 'pattern_certificate_id' => array(
'integer', 1),
22 'obj_id' => array(
'integer', 20),
23 'obj_type' => array(
'text',
'crs'),
24 'user_id' => array(
'integer', 400),
25 'user_name' => array(
'text',
'Niels Theen'),
26 'acquired_timestamp' => array(
'integer', 123456789),
27 'certificate_content' => array(
'clob',
'<xml>Some Content</xml>'),
28 'template_values' => array(
'clob',
'[]'),
29 'valid_until' => array(
'integer', null),
30 'version' => array(
'integer', 1),
31 'ilias_version' => array(
'text',
'v5.4.0'),
32 'currently_active' => array(
'integer',
true),
33 'background_image_path' => array(
'text',
'/some/where/background.jpg'),
34 'thumbnail_image_path' => array(
'text',
'/some/where/thumbnail.svg'),
38 $logger = $this->getMockBuilder(
'ilLogger')
39 ->disableOriginalConstructor()
42 $logger->expects($this->atLeastOnce())
58 '<xml>Some Content</xml>',
64 '/some/where/background.jpg',
65 '/some/where/thumbnail.svg' 68 $repository->save($userCertificate);
73 $database = $this->getMockBuilder(
'ilDBInterface')
76 $database->method(
'nextId')
79 $database->method(
'fetchAssoc')->willReturnOnConsecutiveCalls(
82 'pattern_certificate_id' => 1,
86 'user_name' =>
'Niels Theen',
87 'acquired_timestamp' => 123456789,
88 'certificate_content' =>
'<xml>Some Content</xml>',
89 'template_values' =>
'[]',
90 'valid_until' => null,
92 'ilias_version' =>
'v5.4.0',
93 'currently_active' =>
true,
94 'background_image_path' =>
'/some/where/background.jpg',
95 'thumbnail_image_path' => array(
'clob',
'/some/where/thumbnail.svg'),
96 'title' =>
'Some Title' 100 'pattern_certificate_id' => 5,
104 'user_name' =>
'Niels Theen',
105 'acquired_timestamp' => 987654321,
106 'certificate_content' =>
'<xml>Some Other Content</xml>',
107 'template_values' =>
'[]',
108 'valid_until' => null,
110 'ilias_version' =>
'v5.3.0',
111 'currently_active' =>
true,
112 'background_image_path' =>
'/some/where/else/background.jpg',
113 'thumbnail_image_path' => array(
'clob',
'/some/where/thumbnail.svg'),
114 'title' =>
'Someother Title' 118 $logger = $this->getMockBuilder(
'ilLogger')
119 ->disableOriginalConstructor()
122 $logger->expects($this->atLeastOnce())
129 'someDefaultDescription' 132 $results = $repository->fetchActiveCertificates(400);
134 $this->assertEquals(141,
$results[0]->getUserCertificate()->getId());
135 $this->assertEquals(142,
$results[1]->getUserCertificate()->getId());
140 $database = $this->getMockBuilder(
'ilDBInterface')
143 $database->method(
'nextId')
146 $database->method(
'fetchAssoc')->willReturnOnConsecutiveCalls(
149 'pattern_certificate_id' => 1,
153 'user_name' =>
'Niels Theen',
154 'acquired_timestamp' => 123456789,
155 'certificate_content' =>
'<xml>Some Content</xml>',
156 'template_values' =>
'[]',
157 'valid_until' => null,
159 'ilias_version' =>
'v5.4.0',
160 'currently_active' =>
true,
161 'background_image_path' =>
'/some/where/background.jpg',
162 'thumbnail_image_path' => array(
'clob',
'/some/where/thumbnail.svg'),
166 'pattern_certificate_id' => 5,
170 'user_name' =>
'Niels Theen',
171 'acquired_timestamp' => 987654321,
172 'certificate_content' =>
'<xml>Some Other Content</xml>',
173 'template_values' =>
'[]',
174 'valid_until' => null,
176 'ilias_version' =>
'v5.3.0',
177 'currently_active' =>
true,
178 'background_image_path' =>
'/some/where/else/background.jpg',
179 'thumbnail_image_path' => array(
'clob',
'/some/where/thumbnail.svg'),
183 $logger = $this->getMockBuilder(
'ilLogger')
184 ->disableOriginalConstructor()
187 $logger->expects($this->atLeastOnce())
196 $result = $repository->fetchActiveCertificate(400, 20);
198 $this->assertEquals(141,
$result->getId());
206 $this->expectException(\ilException::class);
208 $database = $this->getMockBuilder(
'ilDBInterface')
211 $database->method(
'nextId')
214 $database->method(
'fetchAssoc')->willReturn(array());
216 $logger = $this->getMockBuilder(
'ilLogger')
217 ->disableOriginalConstructor()
220 $logger->expects($this->atLeastOnce())
225 $repository->fetchActiveCertificate(400, 20);
227 $this->fail(
'Should never happen. Certificate Found?');
232 $database = $this->getMockBuilder(
'ilDBInterface')
235 $database->method(
'nextId')
238 $database->method(
'fetchAssoc')->willReturnOnConsecutiveCalls(
241 'pattern_certificate_id' => 1,
245 'user_name' =>
'Niels Theen',
246 'acquired_timestamp' => 123456789,
247 'certificate_content' =>
'<xml>Some Content</xml>',
248 'template_values' =>
'[]',
249 'valid_until' => null,
251 'ilias_version' =>
'v5.4.0',
252 'currently_active' =>
true,
253 'background_image_path' =>
'/some/where/background.jpg',
254 'thumbnail_image_path' =>
'/some/where/else/thumbnail.svg',
255 'title' =>
'SomeTitle',
256 'someDescription' =>
'SomeDescription' 260 'pattern_certificate_id' => 5,
264 'user_name' =>
'Niels Theen',
265 'acquired_timestamp' => 987654321,
266 'certificate_content' =>
'<xml>Some Other Content</xml>',
267 'template_values' =>
'[]',
268 'valid_until' => null,
270 'ilias_version' =>
'v5.3.0',
271 'currently_active' =>
true,
272 'background_image_path' =>
'/some/where/else/background.jpg',
273 'thumbnail_image_path' =>
'/some/where/else/thumbnail.svg',
274 'title' =>
'SomeTitle',
275 'someDescription' =>
'SomeDescription' 279 $logger = $this->getMockBuilder(
'ilLogger')
280 ->disableOriginalConstructor()
283 $logger->expects($this->atLeastOnce())
288 $results = $repository->fetchActiveCertificatesByTypeForPresentation(400,
'crs');
290 $this->assertEquals(141,
$results[0]->getUserCertificate()->getId());
291 $this->assertEquals(142,
$results[1]->getUserCertificate()->getId());
296 $database = $this->getMockBuilder(
'ilDBInterface')
299 $database->method(
'nextId')
302 $database->method(
'fetchAssoc')->willReturn(
305 'pattern_certificate_id' => 1,
309 'user_name' =>
'Niels Theen',
310 'acquired_timestamp' => 123456789,
311 'certificate_content' =>
'<xml>Some Content</xml>',
312 'template_values' =>
'[]',
313 'valid_until' => null,
315 'ilias_version' =>
'v5.4.0',
316 'currently_active' =>
true,
317 'background_image_path' =>
'/some/where/background.jpg',
318 'thumbnail_image_path' =>
'/some/where/else/thumbnail.svg',
319 'title' =>
'SomeTitle',
320 'someDescription' =>
'SomeDescription' 324 $logger = $this->getMockBuilder(
'ilLogger')
325 ->disableOriginalConstructor()
328 $logger->expects($this->atLeastOnce())
333 $result = $repository->fetchCertificate(141);
335 $this->assertEquals(141,
$result->getId());
343 $this->expectException(\ilException::class);
345 $database = $this->getMockBuilder(
'ilDBInterface')
348 $database->method(
'nextId')
351 $database->method(
'fetchAssoc')
352 ->willReturn(array());
354 $logger = $this->getMockBuilder(
'ilLogger')
355 ->disableOriginalConstructor()
358 $logger->expects($this->atLeastOnce())
363 $repository->fetchCertificate(141);
365 $this->fail(
'Should never happen. Certificate Found?');
370 $database = $this->getMockBuilder(
'ilDBInterface')
374 ->expects($this->once())
378 ->expects($this->once())
382 ->expects($this->exactly(3))
383 ->method(
'fetchAssoc')
384 ->willReturnOnConsecutiveCalls(
385 array(
'obj_id' => 100),
386 array(
'obj_id' => 300),
390 $database->method(
'fetchAssoc')
391 ->willReturn(array());
393 $logger = $this->getMockBuilder(
'ilLogger')
394 ->disableOriginalConstructor()
397 $logger->expects($this->atLeastOnce())
403 $objectIds = array(200, 300, 400);
405 $results = $repository->fetchObjectIdsWithCertificateForUser($userId, $objectIds);
407 $this->assertEquals(array(100, 300),
$results);
412 $database = $this->getMockBuilder(
'ilDBInterface')
416 ->expects($this->once())
420 ->expects($this->exactly(3))
421 ->method(
'fetchAssoc')
422 ->willReturnOnConsecutiveCalls(
423 array(
'user_id' => 100),
424 array(
'user_id' => 300),
428 $database->method(
'fetchAssoc')
429 ->willReturn(array());
431 $logger = $this->getMockBuilder(
'ilLogger')
432 ->disableOriginalConstructor()
435 $logger->expects($this->atLeastOnce())
442 $results = $repository->fetchUserIdsWithCertificateForObject($objectId);
444 $this->assertEquals(array(100, 300),
$results);
testNoCertificateInFetchtCertificateLeadsToException()
testFetchUserIdsWithCertificateForObject()
testFetchActiveCertificatesByType()
Class ilCertificateBaseTestCase.
testFetchObjectWithCertificateForUser()
testFetchActiveCertificateForUserObjectCombination()
testSaveOfUserCertificateToDatabase()
testFetchAllActiveCertificateForUser()
testFetchNoActiveCertificateLeadsToException()