1 <?php declare(strict_types=1);
17 $dataGatewayFactory = $this->getMockBuilder(ilTermsOfServiceDataGatewayFactory::class)->getMock();
19 ->getMockBuilder(ilTermsOfServiceAcceptanceDataGateway::class)
23 ->expects($this->once())
24 ->method(
'trackAcceptance')
25 ->with($this->isInstanceOf(ilTermsOfServiceAcceptanceEntity::class));
28 ->expects($this->any())
30 ->willReturn($dataGateway);
33 $this->getMockBuilder(ilDBInterface::class)->getMock(),
38 ->getMockBuilder(ilObjUser::class)
39 ->disableOriginalConstructor()
40 ->setMethods([
'getLanguage',
'getId',
'getLogin',
'writeAccepted',
'hasToAcceptTermsOfServiceInSession'])
44 ->expects($this->any())
49 ->expects($this->any())
51 ->willReturn(
'phpunit');
54 ->expects($this->once())
55 ->method(
'writeAccepted');
58 ->expects($this->once())
59 ->method(
'hasToAcceptTermsOfServiceInSession')
63 ->getMockBuilder(ilTermsOfServiceDocument::class)
64 ->disableOriginalConstructor()
65 ->setMethods([
'content',
'id',
'criteria',
'title'])
69 ->expects($this->atLeast(1))
71 ->willReturn(
'phpunit');
74 ->expects($this->atLeast(1))
76 ->willReturn(
'phpunit');
79 ->expects($this->atLeast(1))
84 ->expects($this->atLeast(1))
88 $helper->trackAcceptance($user, $document);
97 $dataGatewayFactory = $this->getMockBuilder(ilTermsOfServiceDataGatewayFactory::class)->getMock();
99 ->getMockBuilder(ilTermsOfServiceAcceptanceDataGateway::class)
103 ->expects($this->once())
104 ->method(
'deleteAcceptanceHistoryByUser')
105 ->with($this->isInstanceOf(ilTermsOfServiceAcceptanceEntity::class));
108 ->expects($this->any())
109 ->method(
'getByName')
110 ->willReturn($dataGateway);
113 $this->getMockBuilder(ilDBInterface::class)->getMock(),
118 ->getMockBuilder(ilObjUser::class)
119 ->disableOriginalConstructor()
120 ->setMethods([
'getId',
'getLogin'])
124 ->expects($this->any())
129 ->expects($this->any())
131 ->willReturn(
'phpunit');
133 $helper->deleteAcceptanceHistoryByUser($user->getId());
142 $dataGatewayFactory = $this->getMockBuilder(ilTermsOfServiceDataGatewayFactory::class)->getMock();
144 ->getMockBuilder(ilTermsOfServiceAcceptanceDataGateway::class)
148 $entity->withId(4711);
151 ->expects($this->atLeast(1))
152 ->method(
'loadCurrentAcceptanceOfUser')
153 ->with($this->isInstanceOf(ilTermsOfServiceAcceptanceEntity::class))
154 ->willReturn($entity);
157 ->expects($this->any())
158 ->method(
'getByName')
159 ->willReturn($dataGateway);
162 $this->getMockBuilder(ilDBInterface::class)->getMock(),
167 ->getMockBuilder(ilObjUser::class)
168 ->disableOriginalConstructor()
169 ->setMethods([
'getId',
'getLogin'])
173 ->expects($this->any())
178 ->expects($this->any())
180 ->willReturn(
'phpunit');
182 $this->assertInstanceOf(ilTermsOfServiceAcceptanceEntity::class, $helper->getCurrentAcceptanceForUser($user));
183 $this->assertEquals($entity, $helper->getCurrentAcceptanceForUser($user));
192 $dataGatewayFactory = $this->getMockBuilder(ilTermsOfServiceDataGatewayFactory::class)->getMock();
194 ->getMockBuilder(ilTermsOfServiceAcceptanceDataGateway::class)
198 $entity->withId(4711);
201 ->expects($this->atLeast(1))
203 ->willReturn($entity);
206 ->expects($this->any())
207 ->method(
'getByName')
208 ->willReturn($dataGateway);
211 $this->getMockBuilder(ilDBInterface::class)->getMock(),
216 ->getMockBuilder(ilObjUser::class)
217 ->disableOriginalConstructor()
218 ->setMethods([
'getId',
'getLogin'])
222 ->expects($this->any())
227 ->expects($this->any())
229 ->willReturn(
'phpunit');
231 $this->assertInstanceOf(ilTermsOfServiceAcceptanceEntity::class, $helper->getById($entity->getId()));
232 $this->assertEquals($entity, $helper->getById($entity->getId()));
testAcceptanceHistoryCanBeDeleted()
testLatestAcceptanceHistoryEntityCanBeLoadedForUser()
Class ilTermsOfServiceHelperTest.
Class ilTermsOfServiceBaseTest.
testAcceptanceHistoryEntityCanBeLoadedById()
Class ilTermsOfServiceHelper.
Class ilTermsOfServiceAcceptanceEntity.
testDocumentCanBeAccepted()