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 $database = $this->getMockBuilder(
'ilDBInterface')
209 $database->method(
'nextId')
212 $database->method(
'fetchAssoc')->willReturn(array());
214 $logger = $this->getMockBuilder(
'ilLogger')
215 ->disableOriginalConstructor()
218 $logger->expects($this->atLeastOnce())
223 $repository->fetchActiveCertificate(400, 20);
225 $this->fail(
'Should never happen. Certificate Found?');
230 $database = $this->getMockBuilder(
'ilDBInterface')
233 $database->method(
'nextId')
236 $database->method(
'fetchAssoc')->willReturnOnConsecutiveCalls(
239 'pattern_certificate_id' => 1,
243 'user_name' =>
'Niels Theen',
244 'acquired_timestamp' => 123456789,
245 'certificate_content' =>
'<xml>Some Content</xml>',
246 'template_values' =>
'[]',
247 'valid_until' => null,
249 'ilias_version' =>
'v5.4.0',
250 'currently_active' =>
true,
251 'background_image_path' =>
'/some/where/background.jpg',
252 'thumbnail_image_path' =>
'/some/where/else/thumbnail.svg',
253 'title' =>
'SomeTitle',
254 'someDescription' =>
'SomeDescription' 258 'pattern_certificate_id' => 5,
262 'user_name' =>
'Niels Theen',
263 'acquired_timestamp' => 987654321,
264 'certificate_content' =>
'<xml>Some Other Content</xml>',
265 'template_values' =>
'[]',
266 'valid_until' => null,
268 'ilias_version' =>
'v5.3.0',
269 'currently_active' =>
true,
270 'background_image_path' =>
'/some/where/else/background.jpg',
271 'thumbnail_image_path' =>
'/some/where/else/thumbnail.svg',
272 'title' =>
'SomeTitle',
273 'someDescription' =>
'SomeDescription' 277 $logger = $this->getMockBuilder(
'ilLogger')
278 ->disableOriginalConstructor()
281 $logger->expects($this->atLeastOnce())
286 $results = $repository->fetchActiveCertificatesByTypeForPresentation(400,
'crs');
288 $this->assertEquals(141,
$results[0]->getUserCertificate()->getId());
289 $this->assertEquals(142,
$results[1]->getUserCertificate()->getId());
294 $database = $this->getMockBuilder(
'ilDBInterface')
297 $database->method(
'nextId')
300 $database->method(
'fetchAssoc')->willReturn(
303 'pattern_certificate_id' => 1,
307 'user_name' =>
'Niels Theen',
308 'acquired_timestamp' => 123456789,
309 'certificate_content' =>
'<xml>Some Content</xml>',
310 'template_values' =>
'[]',
311 'valid_until' => null,
313 'ilias_version' =>
'v5.4.0',
314 'currently_active' =>
true,
315 'background_image_path' =>
'/some/where/background.jpg',
316 'thumbnail_image_path' =>
'/some/where/else/thumbnail.svg',
317 'title' =>
'SomeTitle',
318 'someDescription' =>
'SomeDescription' 322 $logger = $this->getMockBuilder(
'ilLogger')
323 ->disableOriginalConstructor()
326 $logger->expects($this->atLeastOnce())
331 $result = $repository->fetchCertificate(141);
333 $this->assertEquals(141,
$result->getId());
341 $database = $this->getMockBuilder(
'ilDBInterface')
344 $database->method(
'nextId')
347 $database->method(
'fetchAssoc')
348 ->willReturn(array());
350 $logger = $this->getMockBuilder(
'ilLogger')
351 ->disableOriginalConstructor()
354 $logger->expects($this->atLeastOnce())
359 $repository->fetchCertificate(141);
361 $this->fail(
'Should never happen. Certificate Found?');
366 $database = $this->getMockBuilder(
'ilDBInterface')
370 ->expects($this->
once())
374 ->expects($this->
once())
378 ->expects($this->exactly(3))
379 ->method(
'fetchAssoc')
380 ->willReturnOnConsecutiveCalls(
381 array(
'obj_id' => 100),
382 array(
'obj_id' => 300),
386 $database->method(
'fetchAssoc')
387 ->willReturn(array());
389 $logger = $this->getMockBuilder(
'ilLogger')
390 ->disableOriginalConstructor()
393 $logger->expects($this->atLeastOnce())
399 $objectIds = array(200, 300, 400);
401 $results = $repository->fetchObjectIdsWithCertificateForUser($userId, $objectIds);
403 $this->assertEquals(array(100, 300),
$results);
408 $database = $this->getMockBuilder(
'ilDBInterface')
412 ->expects($this->
once())
416 ->expects($this->exactly(3))
417 ->method(
'fetchAssoc')
418 ->willReturnOnConsecutiveCalls(
419 array(
'user_id' => 100),
420 array(
'user_id' => 300),
424 $database->method(
'fetchAssoc')
425 ->willReturn(array());
427 $logger = $this->getMockBuilder(
'ilLogger')
428 ->disableOriginalConstructor()
431 $logger->expects($this->atLeastOnce())
438 $results = $repository->fetchUserIdsWithCertificateForObject($objectId);
440 $this->assertEquals(array(100, 300),
$results);
testNoCertificateInFetchtCertificateLeadsToException()
ilException
testFetchUserIdsWithCertificateForObject()
testFetchActiveCertificatesByType()
testFetchObjectWithCertificateForUser()
testFetchActiveCertificateForUserObjectCombination()
testSaveOfUserCertificateToDatabase()
once($eventName, callable $callBack, $priority=100)
Subscribe to an event exactly once.
testFetchAllActiveCertificateForUser()
testFetchNoActiveCertificateLeadsToException()
ilException