19 declare(strict_types=1);
    46         $templateRepository = $this->getMockBuilder(ilCertificateTemplateRepository::class)->getMock();
    48         $templateRepository->method(
'fetchActiveCertificateTemplatesForCoursesWithDisabledLearningProgress')
    54                         '<xml>Some Content</xml>',
    55                         md5(
'<xml>Some Content</xml>'),
    61                         '/some/where/background.jpg',
    62                         '/some/where/thumbnail.svg',
    70                         '<xml>Some Content</xml>',
    71                         md5(
'<xml>Some Content</xml>'),
    77                         '/some/where/background.jpg',
    78                         '/some/where/thumbnail.svg',
    86         $setting = $this->getMockBuilder(ilSetting::class)
    87             ->disableOriginalConstructor()
    91             [
'cert_subitems_5', 
'[10,20]'],
    92             [
'cert_subitems_6', 
'[10,50]'],
    97                 function (
string $k) use (&$consecutive_get): 
string {
    98                     list($expected, $ret) = array_shift($consecutive_get);
    99                     $this->assertEquals($expected, $k);
   104         $objectHelper = $this->getMockBuilder(ilCertificateObjectHelper::class)
   107         $consecutive_lookup = [10, 20, 10, 50];
   109             ->method(
'lookupObjId')
   110             ->willReturnCallback(
   111                 function (
int $id) use (&$consecutive_lookup): 
int {
   112                     $expected = array_shift($consecutive_lookup);
   113                     $this->assertEquals($expected, $id);
   119         $statusHelper = $this->getMockBuilder(ilCertificateLPStatusHelper::class)
   122         $consecutive_status = [
   129             ->method(
'lookUpStatus')
   130             ->willReturnCallback(
   131                 function (
int $id) use (&$consecutive_status): 
int {
   132                     list($expected, $ret) = array_shift($consecutive_status);
   133                     $this->assertEquals($expected, $id);
   139         $trackingHelper = $this->getMockBuilder(ilCertificateObjUserTrackingHelper::class)
   141         $trackingHelper->method(
'enabledLearningProgress')->willReturn(
true);
   151         $completedCourses = $evaluation->evaluate(10, 200);
   153         $this->assertSame(5, $completedCourses[0]->getObjId());
   158         $templateRepository = $this->getMockBuilder(ilCertificateTemplateRepository::class)->getMock();
   160         $templateRepository->method(
'fetchActiveCertificateTemplatesForCoursesWithDisabledLearningProgress')
   166                         '<xml>Some Content</xml>',
   167                         md5(
'<xml>Some Content</xml>'),
   173                         '/some/where/background.jpg',
   174                         '/some/where/thumbnail.svg',
   182                         '<xml>Some Content</xml>',
   183                         md5(
'<xml>Some Content</xml>'),
   189                         '/some/where/background.jpg',
   190                         '/some/where/thumbnail.svg',
   198         $setting = $this->getMockBuilder(ilSetting::class)
   199             ->disableOriginalConstructor()
   202         $setting = $this->getMockBuilder(ilSetting::class)
   203             ->disableOriginalConstructor()
   207             [
'cert_subitems_5', 
'[10,20]'],
   208             [
'cert_subitems_6', 
'[10,500]'],
   212             ->willReturnCallback(
   213                 function (
string $k) use (&$consecutive_get): 
string {
   214                     list($expected, $ret) = array_shift($consecutive_get);
   215                     $this->assertEquals($expected, $k);
   220         $objectHelper = $this->getMockBuilder(ilCertificateObjectHelper::class)
   223         $consecutive_lookup = [
   230             ->method(
'lookupObjId')
   231             ->willReturnCallback(
   232                 function (
int $id) use (&$consecutive_lookup): 
int {
   233                     list($expected, $ret) = array_shift($consecutive_lookup);
   234                     $this->assertEquals($expected, $id);
   240         $statusHelper = $this->getMockBuilder(ilCertificateLPStatusHelper::class)
   243         $consecutive_status = [
   251             ->method(
'lookUpStatus')
   252             ->willReturnCallback(
   253                 function (
int $id) use (&$consecutive_status): 
int {
   254                     list($expected, $ret) = array_shift($consecutive_status);
   255                     $this->assertEquals($expected, $id);
   261         $trackingHelper = $this->getMockBuilder(ilCertificateObjUserTrackingHelper::class)
   263         $trackingHelper->method(
'enabledLearningProgress')->willReturn(
false);
   273         $completedCourses = $evaluation->evaluate(10, 200);
   275         $this->assertSame(5, $completedCourses[0]->getObjId());
   276         $this->assertSame(6, $completedCourses[1]->getObjId());
   281         $templateRepository = $this->getMockBuilder(ilCertificateTemplateRepository::class)->getMock();
   283         $templateRepository->method(
'fetchActiveCertificateTemplatesForCoursesWithDisabledLearningProgress')
   289                         '<xml>Some Content</xml>',
   290                         md5(
'<xml>Some Content</xml>'),
   296                         '/some/where/background.jpg',
   297                         '/some/where/thumbnail.svg',
   305                         '<xml>Some Content</xml>',
   306                         md5(
'<xml>Some Content</xml>'),
   312                         '/some/where/background.jpg',
   313                         '/some/where/thumbnail.svg',
   321         $setting = $this->getMockBuilder(ilSetting::class)
   322             ->disableOriginalConstructor()
   331             ->willReturnCallback(
   332                 function (
string $k) use (&$consecutive_get) {
   333                     $expected = array_shift($consecutive_get);
   334                     $this->assertEquals($expected, $k);
   340         $objectHelper = $this->getMockBuilder(ilCertificateObjectHelper::class)
   343         $statusHelper = $this->getMockBuilder(ilCertificateLPStatusHelper::class)
   346         $trackingHelper = $this->getMockBuilder(ilCertificateObjUserTrackingHelper::class)
   348         $trackingHelper->method(
'enabledLearningProgress')->willReturn(
false);
   358         $completedCourses = $evaluation->evaluate(10, 200);
   360         $this->assertSame([], $completedCourses);
   366             'LP globally enabled' => [
true, []],
   367             'LP globally disabled' => [
true, [
   372                     'certificate_content' => 
'<xml>Some Content</xml>',
   373                     'certificate_hash' => md5(
'<xml>Some Content</xml>'),
   374                     'template_values' => 
'[]',
   376                     'ilias_version' => 
'v5.4.0',
   377                     'created_timestamp' => 123_456_789,
   378                     'currently_active' => 
true,
   379                     'background_image_path' => 
'/some/where/background.jpg',
   380                     'thumbnail_image_path' => 
'some/path/test.svg',
   381                     'background_image_ident' => 
'-',
   382                     'thumbnail_image_ident' => 
'-'   388                     'certificate_content' => 
'<xml>Some Other Content</xml>',
   389                     'certificate_hash' => md5(
'<xml>Some Content</xml>'),
   390                     'template_values' => 
'[]',
   392                     'ilias_version' => 
'v5.3.0',
   393                     'created_timestamp' => 123_456_789,
   394                     'currently_active' => 
false,
   395                     'background_image_path' => 
'/some/where/else/background.jpg',
   396                     'thumbnail_image_path' => 
'some/path/test.svg',
   397                     'background_image_ident' => 
'-',
   398                     'thumbnail_image_ident' => 
'-'   409         bool $isGlobalLpEnabled,
   410         array $template_recods
   412         $statement = $database = $this->getMockBuilder(ilDBStatement::class)->getMock();
   414         $database->method(
'fetch')->willReturnCallback(
static function () use (&$i, $template_recods): ?array {
   415             $result = $template_recods[$i] ?? null;
   421         $database = $this->createMock(ilDBInterface::class);
   422         $database->expects($this->once())->method(
'queryF')->with(
   425                     $this->stringContains(
'LEFT JOIN ut_lp_settings', 
false),
   426                     $this->stringContains(
'uls.u_mode', 
false),
   427                 ) : $this->logicalAnd(
   428                     $this->logicalNot($this->stringContains(
'LEFT JOIN ut_lp_settings', 
false)),
   429                     $this->logicalNot($this->stringContains(
'uls.u_mode', 
false)),
   431         )->willReturn($statement);
   432         $database->expects($this->exactly(count($template_recods) + 1))
   433             ->method(
'fetchAssoc')
   435             ->willReturnCallback(
static function (
ilDBStatement $statement) {
   436                 return $statement->
fetch(PDO::FETCH_ASSOC);
   439         $logger = $this->getMockBuilder(ilLogger::class)
   440             ->disableOriginalConstructor()
   443         $objectDataCache = $this->getMockBuilder(ilObjectDataCache::class)
   444             ->disableOriginalConstructor()
   453         $templates = $repository->fetchActiveCertificateTemplatesForCoursesWithDisabledLearningProgress(
   456         $this->assertCount(count($template_recods), $templates);
   461         $wrappedTemplateRepository = $this->getMockBuilder(ilCertificateTemplateRepository::class)->getMock();
   462         $wrappedTemplateRepository
   463             ->expects($this->exactly(2))
   464             ->method(
'fetchActiveCertificateTemplatesForCoursesWithDisabledLearningProgress')
   465             ->willReturnCallback(
static function (
bool $isGlobalLpEnabled): array {
   466                 if ($isGlobalLpEnabled) {
   474                         '<xml>Some Content</xml>',
   475                         md5(
'<xml>Some Content</xml>'),
   481                         '/some/where/background.jpg',
   482                         '/some/where/thumbnail.svg',
   490                         '<xml>Some Content</xml>',
   491                         md5(
'<xml>Some Content</xml>'),
   497                         '/some/where/background.jpg',
   498                         '/some/where/thumbnail.svg',
   507         $result1 = $templateRepository->fetchActiveCertificateTemplatesForCoursesWithDisabledLearningProgress(
true);
   509         $result2 = $templateRepository->fetchActiveCertificateTemplatesForCoursesWithDisabledLearningProgress(
true);
   511         $result3 = $templateRepository->fetchActiveCertificateTemplatesForCoursesWithDisabledLearningProgress(
false);
   513         $result4 = $templateRepository->fetchActiveCertificateTemplatesForCoursesWithDisabledLearningProgress(
false);
   515         $result5 = $templateRepository->fetchActiveCertificateTemplatesForCoursesWithDisabledLearningProgress(
true);
   517         $this->assertSame($result1, $result2);
   518         $this->assertSame($result1, $result5);
   519         $this->assertCount(0, $result1);
   521         $this->assertNotSame($result1, $result3);
   522         $this->assertSame($result3, $result4);
   523         $this->assertCount(2, $result3);
 const LP_STATUS_COMPLETED_NUM
 
testRetrievingCertificateTemplatesForCoursesWorksAsExpectedWhenUsingNonCachingRepository(bool $isGlobalLpEnabled, array $template_recods)
globalLearningProgressStateProvder 
 
testNoSubitemDefinedForEvaluation()
 
const LP_STATUS_IN_PROGRESS_NUM
 
testOnlyOneCourseIsCompletedOnLPChange()
 
testAllCoursesAreCompletedOnLPChange()
 
fetch(int $fetch_mode=ilDBConstants::FETCHMODE_ASSOC)
 
static globalLearningProgressStateProvder()
 
testRetrievingCertificateTemplatesForCoursesWillBeCachedWhenCachingRepositoryIsUsed()
 
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins