ILIAS  trunk Revision v11.0_alpha-1689-g66c127b4ae8
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilCertificateObjectsForUserPreloaderTest.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
25 {
27  {
28  $userCertificateRepository = $this->getMockBuilder(ilUserCertificateRepository::class)
29  ->disableOriginalConstructor()
30  ->getMock();
31 
32  $userCertificateRepository->method('fetchObjectIdsWithCertificateForUser')
33  ->willReturn([1, 2, 3]);
34 
35  $preloader = new ilCertificateObjectsForUserPreloader($userCertificateRepository);
36 
37  $preloader->preLoad(100, [500, 200]);
38 
39  $result = $preloader->isPreloaded(100, 1);
40 
41  $this->assertTrue($result);
42  }
43 
44  public function testUserWithCertificateIsNotPreloaded(): void
45  {
46  $userCertificateRepository = $this->getMockBuilder(ilUserCertificateRepository::class)
47  ->disableOriginalConstructor()
48  ->getMock();
49 
50  $userCertificateRepository->method('fetchObjectIdsWithCertificateForUser')
51  ->willReturn([1, 2, 3]);
52 
53  $preloader = new ilCertificateObjectsForUserPreloader($userCertificateRepository);
54 
55  $preloader->preLoad(100, [500, 200]);
56 
57  $result = $preloader->isPreloaded(100, 5);
58 
59  $this->assertFalse($result);
60  }
61 
62  public function testUserIsNoProloaded(): void
63  {
64  $userCertificateRepository = $this->getMockBuilder(ilUserCertificateRepository::class)
65  ->disableOriginalConstructor()
66  ->getMock();
67 
68  $userCertificateRepository->method('fetchObjectIdsWithCertificateForUser')
69  ->willReturn([1, 2, 3]);
70 
71  $preloader = new ilCertificateObjectsForUserPreloader($userCertificateRepository);
72 
73  $preloader->preLoad(100, [500, 200]);
74 
75  $result = $preloader->isPreloaded(200, 1);
76 
77  $this->assertFalse($result);
78  }
79 }
Class ilCertificateBaseTestCase.