19 declare(strict_types=1);
29 $dataGatewayFactory = $this->getMockBuilder(ilTermsOfServiceDataGatewayFactory::class)->getMock();
30 $dataGateway = $this->createMock(ilTermsOfServiceAcceptanceDataGateway::class);
33 ->expects($this->once())
34 ->method(
'trackAcceptance')
35 ->with($this->isInstanceOf(ilTermsOfServiceAcceptanceEntity::class));
39 ->willReturn($dataGateway);
43 $this->createMock(ilTermsOfServiceDocumentEvaluation::class),
44 $this->createMock(ilTermsOfServiceCriterionTypeFactoryInterface::class),
45 $this->getMockBuilder(ilObjTermsOfService::class)->disableOriginalConstructor()->getMock()
49 ->getMockBuilder(ilObjUser::class)
50 ->disableOriginalConstructor()
51 ->onlyMethods([
'getLanguage',
'getId',
'getLogin',
'writeAccepted',
'hasToAcceptTermsOfServiceInSession'])
60 ->willReturn(
'phpunit');
63 ->expects($this->once())
64 ->method(
'writeAccepted');
67 ->expects($this->once())
68 ->method(
'hasToAcceptTermsOfServiceInSession')
72 ->getMockBuilder(ilTermsOfServiceDocument::class)
73 ->disableOriginalConstructor()
74 ->onlyMethods([
'content',
'id',
'criteria',
'title'])
78 ->expects($this->atLeast(1))
80 ->willReturn(
'phpunit');
83 ->expects($this->atLeast(1))
85 ->willReturn(
'phpunit');
88 ->expects($this->atLeast(1))
93 ->expects($this->atLeast(1))
97 $helper->trackAcceptance($user, $document);
102 $dataGatewayFactory = $this->getMockBuilder(ilTermsOfServiceDataGatewayFactory::class)->getMock();
103 $dataGateway = $this->createMock(ilTermsOfServiceAcceptanceDataGateway::class);
106 ->expects($this->once())
107 ->method(
'deleteAcceptanceHistoryByUser')
108 ->with($this->isInstanceOf(ilTermsOfServiceAcceptanceEntity::class));
111 ->method(
'getByName')
112 ->willReturn($dataGateway);
116 $this->createMock(ilTermsOfServiceDocumentEvaluation::class),
117 $this->createMock(ilTermsOfServiceCriterionTypeFactoryInterface::class),
118 $this->getMockBuilder(ilObjTermsOfService::class)->disableOriginalConstructor()->getMock()
122 ->getMockBuilder(ilObjUser::class)
123 ->disableOriginalConstructor()
124 ->onlyMethods([
'getId',
'getLogin'])
133 ->willReturn(
'phpunit');
135 $helper->deleteAcceptanceHistoryByUser($user->getId());
140 $dataGatewayFactory = $this->getMockBuilder(ilTermsOfServiceDataGatewayFactory::class)->getMock();
141 $dataGateway = $this->createMock(ilTermsOfServiceAcceptanceDataGateway::class);
144 $entity = $entity->withId(4711);
147 ->expects($this->atLeast(1))
148 ->method(
'loadCurrentAcceptanceOfUser')
149 ->with($this->isInstanceOf(ilTermsOfServiceAcceptanceEntity::class))
150 ->willReturn($entity);
153 ->method(
'getByName')
154 ->willReturn($dataGateway);
158 $this->createMock(ilTermsOfServiceDocumentEvaluation::class),
159 $this->createMock(ilTermsOfServiceCriterionTypeFactoryInterface::class),
160 $this->getMockBuilder(ilObjTermsOfService::class)->disableOriginalConstructor()->getMock()
164 ->getMockBuilder(ilObjUser::class)
165 ->disableOriginalConstructor()
166 ->onlyMethods([
'getId',
'getLogin'])
175 ->willReturn(
'phpunit');
177 $this->assertInstanceOf(ilTermsOfServiceAcceptanceEntity::class, $helper->getCurrentAcceptanceForUser($user));
178 $this->assertSame($entity, $helper->getCurrentAcceptanceForUser($user));
183 $dataGatewayFactory = $this->getMockBuilder(ilTermsOfServiceDataGatewayFactory::class)->getMock();
184 $dataGateway = $this->createMock(ilTermsOfServiceAcceptanceDataGateway::class);
187 $entity = $entity->withId(4711);
190 ->expects($this->atLeast(1))
192 ->willReturn($entity);
195 ->method(
'getByName')
196 ->willReturn($dataGateway);
200 $this->createMock(ilTermsOfServiceDocumentEvaluation::class),
201 $this->createMock(ilTermsOfServiceCriterionTypeFactoryInterface::class),
202 $this->getMockBuilder(ilObjTermsOfService::class)->disableOriginalConstructor()->getMock()
206 ->getMockBuilder(ilObjUser::class)
207 ->disableOriginalConstructor()
208 ->onlyMethods([
'getId',
'getLogin'])
217 ->willReturn(
'phpunit');
219 $this->assertInstanceOf(ilTermsOfServiceAcceptanceEntity::class, $helper->getById($entity->getId()));
220 $this->assertSame($entity, $helper->getById($entity->getId()));
225 $dataGatewayFactory = $this->getMockBuilder(ilTermsOfServiceDataGatewayFactory::class)->getMock();
226 $dataGateway = $this->createMock(ilTermsOfServiceAcceptanceDataGateway::class);
231 ->withSerializedCriteria(
233 '{"id":"usr_language","value":{"lng":"de"}}',
234 '{"id":"usr_global_role","value":{"role_id":4711}}' 238 $entity2 = $entity1->withId(0);
241 ->expects($this->exactly(3))
242 ->method(
'loadCurrentAcceptanceOfUser')
243 ->willReturnOnConsecutiveCalls($entity1, $entity2, $entity1);
245 ->method(
'getByName')
246 ->willReturn($dataGateway);
248 $tos_object = $this->getMockBuilder(ilObjTermsOfService::class)->disableOriginalConstructor()->getMock();
249 $tos_object->method(
'getStatus')->willReturn(
true);
250 $tos_object->method(
'shouldReevaluateOnLogin')->willReturn(
true);
253 ->getMockBuilder(ilObjUser::class)
254 ->disableOriginalConstructor()
255 ->onlyMethods([
'getId',
'getLogin',
'isAnonymous',
'getAgreeDate'])
262 ->willReturn(
'phpunit');
264 ->method(
'isAnonymous')
267 ->method(
'getAgreeDate')
268 ->willReturn((
new ILIAS\Data\
Factory())->clock()->system()->now()->format(
'Y-m-d H:i:s'));
270 $logger = $logger = $this
271 ->getMockBuilder(ilLogger::class)
272 ->disableOriginalConstructor()
275 $document_evaluation = $this->createMock(ilTermsOfServiceDocumentEvaluation::class);
276 $document_evaluation->expects($this->exactly(4))
277 ->method(
'hasDocument')
278 ->willReturnOnConsecutiveCalls(
true,
false,
true,
true);
279 $document_evaluation->method(
'withContextUser')->with($user)->willReturn($document_evaluation);
280 $document_evaluation->expects($this->exactly(2))->method(
'evaluateDocument')
281 ->with($this->isInstanceOf(ilTermsOfServiceHistorizedDocument::class))
282 ->willReturnOnConsecutiveCalls(
false,
true);
286 $document_evaluation,
287 $this->createMock(ilTermsOfServiceCriterionTypeFactoryInterface::class),
291 $this->assertTrue($helper->hasToResignAcceptance($user, $logger));
292 $this->assertFalse($helper->hasToResignAcceptance($user, $logger));
293 $this->assertFalse($helper->hasToResignAcceptance($user, $logger));
294 $this->assertFalse($helper->hasToResignAcceptance($user, $logger));
testAcceptanceHistoryCanBeDeleted()
Class ChatMainBarProvider .
testLatestAcceptanceHistoryEntityCanBeLoadedForUser()
Class ilTermsOfServiceHelperTest.
Class ilTermsOfServiceBaseTest.
Class ilTermsOfServiceAcceptanceHistoryCriteriaBag.
testAcceptanceHistoryEntityCanBeLoadedById()
Class ilTermsOfServiceHelper.
Class ilTermsOfServiceAcceptanceEntity.
testDocumentMustBeResigned()
testDocumentCanBeAccepted()