ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
ilTermsOfServiceHelperTest Class Reference

Class ilTermsOfServiceHelperTest. More...

+ Inheritance diagram for ilTermsOfServiceHelperTest:
+ Collaboration diagram for ilTermsOfServiceHelperTest:

Public Member Functions

 testDocumentCanBeAccepted ()
 
 testAcceptanceHistoryCanBeDeleted ()
 
 testLatestAcceptanceHistoryEntityCanBeLoadedForUser ()
 
 testAcceptanceHistoryEntityCanBeLoadedById ()
 

Additional Inherited Members

- Protected Member Functions inherited from ilTermsOfServiceBaseTest
 setUp ()
 
 getLanguageMock ()
 
 getUiFactoryMock ()
 
 setGlobalVariable (string $name, $value)
 
 getCriterionConfig ($value=null)
 
- Protected Attributes inherited from ilTermsOfServiceBaseTest
 $dic
 

Detailed Description

Member Function Documentation

◆ testAcceptanceHistoryCanBeDeleted()

ilTermsOfServiceHelperTest::testAcceptanceHistoryCanBeDeleted ( )
Exceptions
ilTermsOfServiceMissingDatabaseAdapterException
ReflectionException

Definition at line 95 of file ilTermsOfServiceHelperTest.php.

95 : void
96 {
97 $dataGatewayFactory = $this->getMockBuilder(ilTermsOfServiceDataGatewayFactory::class)->getMock();
98 $dataGateway = $this
99 ->getMockBuilder(ilTermsOfServiceAcceptanceDataGateway::class)
100 ->getMock();
101
102 $dataGateway
103 ->expects($this->once())
104 ->method('deleteAcceptanceHistoryByUser')
105 ->with($this->isInstanceOf(ilTermsOfServiceAcceptanceEntity::class));
106
107 $dataGatewayFactory
108 ->expects($this->any())
109 ->method('getByName')
110 ->willReturn($dataGateway);
111
112 $helper = new ilTermsOfServiceHelper(
113 $this->getMockBuilder(ilDBInterface::class)->getMock(),
114 $dataGatewayFactory
115 );
116
117 $user = $this
118 ->getMockBuilder(ilObjUser::class)
119 ->disableOriginalConstructor()
120 ->setMethods(['getId', 'getLogin'])
121 ->getMock();
122
123 $user
124 ->expects($this->any())
125 ->method('getId')
126 ->willReturn(-1);
127
128 $user
129 ->expects($this->any())
130 ->method('getLogin')
131 ->willReturn('phpunit');
132
133 $helper->deleteAcceptanceHistoryByUser($user->getId());
134 }
Class ilTermsOfServiceHelper.

◆ testAcceptanceHistoryEntityCanBeLoadedById()

ilTermsOfServiceHelperTest::testAcceptanceHistoryEntityCanBeLoadedById ( )
Exceptions
ilTermsOfServiceMissingDatabaseAdapterException
ReflectionException

Definition at line 190 of file ilTermsOfServiceHelperTest.php.

190 : void
191 {
192 $dataGatewayFactory = $this->getMockBuilder(ilTermsOfServiceDataGatewayFactory::class)->getMock();
193 $dataGateway = $this
194 ->getMockBuilder(ilTermsOfServiceAcceptanceDataGateway::class)
195 ->getMock();
196
197 $entity = new ilTermsOfServiceAcceptanceEntity();
198 $entity->withId(4711);
199
200 $dataGateway
201 ->expects($this->atLeast(1))
202 ->method('loadById')
203 ->willReturn($entity);
204
205 $dataGatewayFactory
206 ->expects($this->any())
207 ->method('getByName')
208 ->willReturn($dataGateway);
209
210 $helper = new ilTermsOfServiceHelper(
211 $this->getMockBuilder(ilDBInterface::class)->getMock(),
212 $dataGatewayFactory
213 );
214
215 $user = $this
216 ->getMockBuilder(ilObjUser::class)
217 ->disableOriginalConstructor()
218 ->setMethods(['getId', 'getLogin'])
219 ->getMock();
220
221 $user
222 ->expects($this->any())
223 ->method('getId')
224 ->willReturn(-1);
225
226 $user
227 ->expects($this->any())
228 ->method('getLogin')
229 ->willReturn('phpunit');
230
231 $this->assertInstanceOf(ilTermsOfServiceAcceptanceEntity::class, $helper->getById($entity->getId()));
232 $this->assertEquals($entity, $helper->getById($entity->getId()));
233 }
Class ilTermsOfServiceAcceptanceEntity.

◆ testDocumentCanBeAccepted()

ilTermsOfServiceHelperTest::testDocumentCanBeAccepted ( )
Exceptions
ReflectionException
ilTermsOfServiceMissingDatabaseAdapterException
ilTermsOfServiceUnexpectedCriteriaBagContentException

Definition at line 15 of file ilTermsOfServiceHelperTest.php.

15 : void
16 {
17 $dataGatewayFactory = $this->getMockBuilder(ilTermsOfServiceDataGatewayFactory::class)->getMock();
18 $dataGateway = $this
19 ->getMockBuilder(ilTermsOfServiceAcceptanceDataGateway::class)
20 ->getMock();
21
22 $dataGateway
23 ->expects($this->once())
24 ->method('trackAcceptance')
25 ->with($this->isInstanceOf(ilTermsOfServiceAcceptanceEntity::class));
26
27 $dataGatewayFactory
28 ->expects($this->any())
29 ->method('getByName')
30 ->willReturn($dataGateway);
31
32 $helper = new ilTermsOfServiceHelper(
33 $this->getMockBuilder(ilDBInterface::class)->getMock(),
34 $dataGatewayFactory
35 );
36
37 $user = $this
38 ->getMockBuilder(ilObjUser::class)
39 ->disableOriginalConstructor()
40 ->setMethods(['getLanguage', 'getId', 'getLogin', 'writeAccepted', 'hasToAcceptTermsOfServiceInSession'])
41 ->getMock();
42
43 $user
44 ->expects($this->any())
45 ->method('getId')
46 ->willReturn(-1);
47
48 $user
49 ->expects($this->any())
50 ->method('getLogin')
51 ->willReturn('phpunit');
52
53 $user
54 ->expects($this->once())
55 ->method('writeAccepted');
56
57 $user
58 ->expects($this->once())
59 ->method('hasToAcceptTermsOfServiceInSession')
60 ->with(false);
61
62 $document = $this
63 ->getMockBuilder(ilTermsOfServiceDocument::class)
64 ->disableOriginalConstructor()
65 ->setMethods(['content', 'id', 'criteria', 'title'])
66 ->getMock();
67
68 $document
69 ->expects($this->atLeast(1))
70 ->method('content')
71 ->willReturn('phpunit');
72
73 $document
74 ->expects($this->atLeast(1))
75 ->method('title')
76 ->willReturn('phpunit');
77
78 $document
79 ->expects($this->atLeast(1))
80 ->method('id')
81 ->willReturn(1);
82
83 $document
84 ->expects($this->atLeast(1))
85 ->method('criteria')
86 ->willReturn([]);
87
88 $helper->trackAcceptance($user, $document);
89 }

◆ testLatestAcceptanceHistoryEntityCanBeLoadedForUser()

ilTermsOfServiceHelperTest::testLatestAcceptanceHistoryEntityCanBeLoadedForUser ( )
Exceptions
ilTermsOfServiceMissingDatabaseAdapterException
ReflectionException

Definition at line 140 of file ilTermsOfServiceHelperTest.php.

140 : void
141 {
142 $dataGatewayFactory = $this->getMockBuilder(ilTermsOfServiceDataGatewayFactory::class)->getMock();
143 $dataGateway = $this
144 ->getMockBuilder(ilTermsOfServiceAcceptanceDataGateway::class)
145 ->getMock();
146
147 $entity = new ilTermsOfServiceAcceptanceEntity();
148 $entity->withId(4711);
149
150 $dataGateway
151 ->expects($this->atLeast(1))
152 ->method('loadCurrentAcceptanceOfUser')
153 ->with($this->isInstanceOf(ilTermsOfServiceAcceptanceEntity::class))
154 ->willReturn($entity);
155
156 $dataGatewayFactory
157 ->expects($this->any())
158 ->method('getByName')
159 ->willReturn($dataGateway);
160
161 $helper = new ilTermsOfServiceHelper(
162 $this->getMockBuilder(ilDBInterface::class)->getMock(),
163 $dataGatewayFactory
164 );
165
166 $user = $this
167 ->getMockBuilder(ilObjUser::class)
168 ->disableOriginalConstructor()
169 ->setMethods(['getId', 'getLogin'])
170 ->getMock();
171
172 $user
173 ->expects($this->any())
174 ->method('getId')
175 ->willReturn(-1);
176
177 $user
178 ->expects($this->any())
179 ->method('getLogin')
180 ->willReturn('phpunit');
181
182 $this->assertInstanceOf(ilTermsOfServiceAcceptanceEntity::class, $helper->getCurrentAcceptanceForUser($user));
183 $this->assertEquals($entity, $helper->getCurrentAcceptanceForUser($user));
184 }

The documentation for this class was generated from the following file: