11 $database = $this->getMockBuilder(
'ilDBInterface')
12 ->disableOriginalConstructor()
15 $logger = $this->getMockBuilder(
'ilLogger')
16 ->disableOriginalConstructor()
19 $objectDataCache = $this->getMockBuilder(
'ilObjectDataCache')
20 ->disableOriginalConstructor()
23 $objectDataCache->method(
'lookUpType')->willReturn(
'crs');
25 $database->method(
'nextId')
28 $database->method(
'insert')
32 'id' => array(
'integer', 10),
33 'obj_id' => array(
'integer', 100),
34 'obj_type' => array(
'text',
'crs'),
35 'certificate_content' => array(
'clob',
'<xml>Some Content</xml>'),
36 'certificate_hash' => array(
'text', md5(
'<xml>Some Content</xml>')),
37 'template_values' => array(
'clob',
'[]'),
38 'version' => array(
'integer', 1),
39 'ilias_version' => array(
'text',
'v5.4.0'),
40 'created_timestamp' => array(
'integer', 123456789),
41 'currently_active' => array(
'integer',
true),
42 'background_image_path' => array(
'text',
'/some/where/background.jpg'),
43 'deleted' => array(
'integer', 0),
44 'thumbnail_image_path' => array(
'text',
'some/path/test.svg')
48 $logger->expects($this->atLeastOnce())
54 '<xml>Some Content</xml>',
55 md5(
'<xml>Some Content</xml>'),
61 $backgroundImagePath =
'/some/where/background.jpg',
72 $database = $this->getMockBuilder(
'ilDBInterface')
73 ->disableOriginalConstructor()
76 $logger = $this->getMockBuilder(
'ilLogger')
77 ->disableOriginalConstructor()
80 $database->method(
'fetchAssoc')
81 ->willReturnOnConsecutiveCalls(
86 'certificate_content' =>
'<xml>Some Content</xml>',
87 'certificate_hash' => md5(
'<xml>Some Content</xml>'),
88 'template_values' =>
'[]',
90 'ilias_version' =>
'v5.4.0',
91 'created_timestamp' => 123456789,
92 'currently_active' =>
true,
93 'background_image_path' =>
'/some/where/background.jpg',
94 'thumbnail_image_path' =>
'some/path/test.svg' 100 'certificate_content' =>
'<xml>Some Other Content</xml>',
101 'certificate_hash' => md5(
'<xml>Some Content</xml>'),
102 'template_values' =>
'[]',
104 'ilias_version' =>
'v5.3.0',
105 'created_timestamp' => 123456789,
106 'currently_active' =>
false,
107 'background_image_path' =>
'/some/where/else/background.jpg',
108 'thumbnail_image_path' =>
'some/path/test.svg' 112 $objectDataCache = $this->getMockBuilder(
'ilObjectDataCache')
113 ->disableOriginalConstructor()
116 $objectDataCache->method(
'lookUpType')->willReturn(
'crs');
120 $templates = $repository->fetchCertificateTemplatesByObjId(10);
122 $this->assertEquals(1, $templates[0]->getId());
123 $this->assertEquals(30, $templates[1]->getId());
128 $database = $this->getMockBuilder(
'ilDBInterface')
129 ->disableOriginalConstructor()
132 $logger = $this->getMockBuilder(
'ilLogger')
133 ->disableOriginalConstructor()
136 $database->method(
'fetchAssoc')
137 ->willReturnOnConsecutiveCalls(
142 'certificate_content' =>
'<xml>Some Content</xml>',
143 'certificate_hash' => md5(
'<xml>Some Content</xml>'),
144 'template_values' =>
'[]',
146 'ilias_version' =>
'v5.4.0',
147 'created_timestamp' => 123456789,
148 'currently_active' =>
true,
149 'background_image_path' =>
'/some/where/background.jpg',
150 'thumbnail_image_path' =>
'some/path/test.svg' 156 'certificate_content' =>
'<xml>Some Other Content</xml>',
157 'certificate_hash' => md5(
'<xml>Some Content</xml>'),
158 'template_values' =>
'[]',
160 'ilias_version' =>
'v5.3.0',
161 'created_timestamp' => 123456789,
162 'currently_active' =>
false,
163 'background_image_path' =>
'/some/where/else/background.jpg',
164 'thumbnail_image_path' =>
'some/path/test.svg' 168 $objectDataCache = $this->getMockBuilder(
'ilObjectDataCache')
169 ->disableOriginalConstructor()
172 $objectDataCache->method(
'lookUpType')->willReturn(
'crs');
176 $template = $repository->fetchCurrentlyActiveCertificate(10);
178 $this->assertEquals(1,
$template->getId());
183 $database = $this->getMockBuilder(
'ilDBInterface')
184 ->disableOriginalConstructor()
187 $logger = $this->getMockBuilder(
'ilLogger')
188 ->disableOriginalConstructor()
191 $database->method(
'fetchAssoc')
192 ->willReturnOnConsecutiveCalls(
197 'certificate_content' =>
'<xml>Some Content</xml>',
198 'certificate_hash' => md5(
'<xml>Some Content</xml>'),
199 'template_values' =>
'[]',
201 'ilias_version' =>
'v5.4.0',
202 'created_timestamp' => 123456789,
203 'currently_active' =>
true,
204 'background_image_path' =>
'/some/where/background.jpg',
205 'thumbnail_image_path' =>
'some/path/test.svg' 211 'certificate_content' =>
'<xml>Some Other Content</xml>',
212 'certificate_hash' => md5(
'<xml>Some Content</xml>'),
213 'template_values' =>
'[]',
215 'ilias_version' =>
'v5.3.0',
216 'created_timestamp' => 123456789,
217 'currently_active' =>
false,
218 'background_image_path' =>
'/some/where/else/background.jpg',
219 'thumbnail_image_path' =>
'some/path/test.svg' 223 $objectDataCache = $this->getMockBuilder(
'ilObjectDataCache')
224 ->disableOriginalConstructor()
227 $objectDataCache->method(
'lookUpType')->willReturn(
'crs');
231 $template = $repository->fetchPreviousCertificate(10);
233 $this->assertEquals(30,
$template->getId());
238 $database = $this->getMockBuilder(
'ilDBInterface')
239 ->disableOriginalConstructor()
242 $logger = $this->getMockBuilder(
'ilLogger')
243 ->disableOriginalConstructor()
246 $database->method(
'quote')
247 ->withConsecutive(array(10,
'integer'), array(200,
'integer'))
248 ->willReturnOnConsecutiveCalls(10, 200);
250 $database->method(
'query')
252 DELETE FROM il_cert_template 256 $objectDataCache = $this->getMockBuilder(
'ilObjectDataCache')
257 ->disableOriginalConstructor()
260 $objectDataCache->method(
'lookUpType')->willReturn(
'crs');
264 $repository->deleteTemplate(10, 200);
269 $database = $this->getMockBuilder(
'ilDBInterface')
270 ->disableOriginalConstructor()
273 $logger = $this->getMockBuilder(
'ilLogger')
274 ->disableOriginalConstructor()
277 $database->method(
'quote')
278 ->withConsecutive(array(10,
'integer'), array(30,
'integer'))
279 ->willReturnOnConsecutiveCalls(10, 30);
281 $database->method(
'fetchAssoc')->willReturnOnConsecutiveCalls(
286 'certificate_content' =>
'<xml>Some Content</xml>',
287 'certificate_hash' => md5(
'<xml>Some Content</xml>'),
288 'template_values' =>
'[]',
290 'ilias_version' =>
'v5.4.0',
291 'created_timestamp' => 123456789,
292 'currently_active' =>
true,
293 'background_image_path' =>
'/some/where/background.jpg',
294 'thumbnail_image_path' =>
'some/path/test.svg' 300 'certificate_content' =>
'<xml>Some Other Content</xml>',
301 'certificate_hash' => md5(
'<xml>Some Content</xml>'),
302 'template_values' =>
'[]',
304 'ilias_version' =>
'v5.3.0',
305 'created_timestamp' => 123456789,
306 'currently_active' =>
false,
307 'background_image_path' =>
'/some/where/else/background.jpg',
308 'thumbnail_image_path' =>
'some/path/test.svg' 312 $database->method(
'query')
314 array($this->anything()),
315 array(
'UPDATE il_cert_template 316 SET currently_active = 1 320 $objectDataCache = $this->getMockBuilder(
'ilObjectDataCache')
321 ->disableOriginalConstructor()
324 $objectDataCache->method(
'lookUpType')->willReturn(
'crs');
328 $template = $repository->activatePreviousCertificate(10, 200);
330 $this->assertEquals(30,
$template->getId());
335 $database = $this->getMockBuilder(
'ilDBInterface')
336 ->disableOriginalConstructor()
339 $logger = $this->getMockBuilder(
'ilLogger')
340 ->disableOriginalConstructor()
343 $database->method(
'quote')
347 $objectDataCache = $this->getMockBuilder(
'ilObjectDataCache')
348 ->disableOriginalConstructor()
351 $database->method(
'fetchAssoc')->willReturnOnConsecutiveCalls(
356 'certificate_content' =>
'<xml>Some Content</xml>',
357 'certificate_hash' => md5(
'<xml>Some Content</xml>'),
358 'template_values' =>
'[]',
360 'ilias_version' =>
'v5.4.0',
361 'created_timestamp' => 123456789,
362 'currently_active' =>
true,
363 'background_image_path' =>
'/some/where/background.jpg',
364 'thumbnail_image_path' =>
'/some/where/thumbnail.svg' 370 'certificate_content' =>
'<xml>Some Other Content</xml>',
371 'certificate_hash' => md5(
'<xml>Some Content</xml>'),
372 'template_values' =>
'[]',
374 'ilias_version' =>
'v5.3.0',
375 'created_timestamp' => 123456789,
376 'currently_active' =>
false,
377 'background_image_path' =>
'/some/where/else/background.jpg',
378 'thumbnail_image_path' =>
'/some/where/thumbnail.svg' 384 $templates = $repository->fetchActiveTemplatesByType(
'crs');
386 $this->assertEquals(10, $templates[0]->getObjId());
387 $this->assertEquals(30, $templates[1]->getObjId());
395 $database = $this->getMockBuilder(
'ilDBInterface')
396 ->disableOriginalConstructor()
399 $logger = $this->getMockBuilder(
'ilLogger')
400 ->disableOriginalConstructor()
403 $database->method(
'quote')
404 ->with(10,
'integer')
407 $objectDataCache = $this->getMockBuilder(
'ilObjectDataCache')
408 ->disableOriginalConstructor()
411 $database->method(
'fetchAssoc')
412 ->willReturn(array());
414 $database->method(
'fetchAssoc')
415 ->willReturn(array());
419 $repository->fetchFirstCreatedTemplate(10);
426 $database = $this->getMockBuilder(
'ilDBInterface')
427 ->disableOriginalConstructor()
430 $logger = $this->getMockBuilder(
'ilLogger')
431 ->disableOriginalConstructor()
434 $database->method(
'quote')
435 ->with(10,
'integer')
438 $objectDataCache = $this->getMockBuilder(
'ilObjectDataCache')
439 ->disableOriginalConstructor()
442 $database->method(
'fetchAssoc')
443 ->willReturn(array());
445 $database->method(
'fetchAssoc')->willReturn(
450 'certificate_content' =>
'<xml>Some Content</xml>',
451 'certificate_hash' => md5(
'<xml>Some Content</xml>'),
452 'template_values' =>
'[]',
454 'ilias_version' =>
'v5.4.0',
455 'created_timestamp' => 123456789,
456 'currently_active' =>
true,
457 'background_image_path' =>
'/some/where/background.jpg' 463 $firstTemplate = $repository->fetchFirstCreatedTemplate(10);
465 $this->assertEquals(1, $firstTemplate->getId());
testFetchPreviousCertificate()
testActivatePreviousCertificate()
testFetchAllObjectIdsByType()
testDeleteTemplateFromDatabase()
testFetchFirstCreatedTemplateFailsBecauseNothingWasSaved()
ilException
testFetchCertificateTemplatesByObjId()
fetchFirstCreateTemplate()
testFetchCurrentlyActiveCertificate()
testCertificateWillBeSavedToTheDatabase()