Class ilTermsOfServiceHelperTest.
More...
◆ testAcceptanceHistoryCanBeDeleted()
ilTermsOfServiceHelperTest::testAcceptanceHistoryCanBeDeleted |
( |
| ) |
|
Definition at line 92 of file ilTermsOfServiceHelperTest.php.
References $user, and Sabre\Event\once().
94 $dataGatewayFactory = $this->getMockBuilder(\ilTermsOfServiceDataGatewayFactory::class)->getMock();
96 ->getMockBuilder(\ilTermsOfServiceAcceptanceDataGateway::class)
100 ->expects($this->
once())
101 ->method(
'deleteAcceptanceHistoryByUser')
102 ->with($this->isInstanceOf(\ilTermsOfServiceAcceptanceEntity::class));
105 ->expects($this->any())
106 ->method(
'getByName')
107 ->willReturn($dataGateway);
109 $helper = new \ilTermsOfServiceHelper(
110 $this->getMockBuilder(\ilDBInterface::class)->getMock(),
115 ->getMockBuilder(\ilObjUser::class)
116 ->disableOriginalConstructor()
117 ->setMethods([
'getId',
'getLogin'])
121 ->expects($this->any())
126 ->expects($this->any())
128 ->willReturn(
'phpunit');
130 $helper->deleteAcceptanceHistoryByUser(
$user->getId());
once($eventName, callable $callBack, $priority=100)
Subscribe to an event exactly once.
◆ testAcceptanceHistoryEntityCanBeLoadedById()
ilTermsOfServiceHelperTest::testAcceptanceHistoryEntityCanBeLoadedById |
( |
| ) |
|
Definition at line 185 of file ilTermsOfServiceHelperTest.php.
References $user.
187 $dataGatewayFactory = $this->getMockBuilder(\ilTermsOfServiceDataGatewayFactory::class)->getMock();
189 ->getMockBuilder(\ilTermsOfServiceAcceptanceDataGateway::class)
192 $entity = new \ilTermsOfServiceAcceptanceEntity();
193 $entity->withId(4711);
196 ->expects($this->atLeast(1))
198 ->willReturn($entity);
201 ->expects($this->any())
202 ->method(
'getByName')
203 ->willReturn($dataGateway);
205 $helper = new \ilTermsOfServiceHelper(
206 $this->getMockBuilder(\ilDBInterface::class)->getMock(),
211 ->getMockBuilder(\ilObjUser::class)
212 ->disableOriginalConstructor()
213 ->setMethods([
'getId',
'getLogin'])
217 ->expects($this->any())
222 ->expects($this->any())
224 ->willReturn(
'phpunit');
226 $this->assertInstanceOf(\ilTermsOfServiceAcceptanceEntity::class, $helper->getById($entity->getId()));
227 $this->assertEquals($entity, $helper->getById($entity->getId()));
◆ testDocumentCanBeAccepted()
ilTermsOfServiceHelperTest::testDocumentCanBeAccepted |
( |
| ) |
|
Definition at line 13 of file ilTermsOfServiceHelperTest.php.
References $user, and Sabre\Event\once().
15 $dataGatewayFactory = $this->getMockBuilder(\ilTermsOfServiceDataGatewayFactory::class)->getMock();
17 ->getMockBuilder(\ilTermsOfServiceAcceptanceDataGateway::class)
21 ->expects($this->
once())
22 ->method(
'trackAcceptance')
23 ->with($this->isInstanceOf(\ilTermsOfServiceAcceptanceEntity::class));
26 ->expects($this->any())
28 ->willReturn($dataGateway);
30 $helper = new \ilTermsOfServiceHelper(
31 $this->getMockBuilder(\ilDBInterface::class)->getMock(),
36 ->getMockBuilder(\ilObjUser::class)
37 ->disableOriginalConstructor()
38 ->setMethods([
'getLanguage',
'getId',
'getLogin',
'writeAccepted',
'hasToAcceptTermsOfServiceInSession'])
42 ->expects($this->any())
47 ->expects($this->any())
49 ->willReturn(
'phpunit');
52 ->expects($this->
once())
53 ->method(
'writeAccepted');
56 ->expects($this->
once())
57 ->method(
'hasToAcceptTermsOfServiceInSession')
61 ->getMockBuilder(\ilTermsOfServiceDocument::class)
62 ->disableOriginalConstructor()
63 ->setMethods([
'content',
'id',
'criteria',
'title'])
67 ->expects($this->atLeast(1))
69 ->willReturn(
'phpunit');
72 ->expects($this->atLeast(1))
74 ->willReturn(
'phpunit');
77 ->expects($this->atLeast(1))
82 ->expects($this->atLeast(1))
86 $helper->trackAcceptance(
$user, $document);
once($eventName, callable $callBack, $priority=100)
Subscribe to an event exactly once.
◆ testLatestAcceptanceHistoryEntityCanBeLoadedForUser()
ilTermsOfServiceHelperTest::testLatestAcceptanceHistoryEntityCanBeLoadedForUser |
( |
| ) |
|
Definition at line 136 of file ilTermsOfServiceHelperTest.php.
References $user.
138 $dataGatewayFactory = $this->getMockBuilder(\ilTermsOfServiceDataGatewayFactory::class)->getMock();
140 ->getMockBuilder(\ilTermsOfServiceAcceptanceDataGateway::class)
143 $entity = new \ilTermsOfServiceAcceptanceEntity();
144 $entity->withId(4711);
147 ->expects($this->atLeast(1))
148 ->method(
'loadCurrentAcceptanceOfUser')
149 ->with($this->isInstanceOf(\ilTermsOfServiceAcceptanceEntity::class))
150 ->willReturn($entity);
153 ->expects($this->any())
154 ->method(
'getByName')
155 ->willReturn($dataGateway);
157 $helper = new \ilTermsOfServiceHelper(
158 $this->getMockBuilder(\ilDBInterface::class)->getMock(),
163 ->getMockBuilder(\ilObjUser::class)
164 ->disableOriginalConstructor()
165 ->setMethods([
'getId',
'getLogin'])
169 ->expects($this->any())
174 ->expects($this->any())
176 ->willReturn(
'phpunit');
178 $this->assertInstanceOf(\ilTermsOfServiceAcceptanceEntity::class, $helper->getCurrentAcceptanceForUser(
$user));
179 $this->assertEquals($entity, $helper->getCurrentAcceptanceForUser(
$user));
The documentation for this class was generated from the following file: