ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilTermsOfServiceRequestTargetAdjustmentCaseTest.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2018 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
9 {
14  {
15  $ctrl = $this
16  ->getMockBuilder(\ilCtrl::class)
17  ->disableOriginalConstructor()
18  ->setMethods(['redirectToURL', 'getCmdClass', 'getCmd'])
19  ->getMock();
20 
21  $ctrl
22  ->expects($this->any())
23  ->method('getCmdClass')
24  ->willReturn('ilPersonalDesktopGUI');
25 
26  $ctrl
27  ->expects($this->any())
28  ->method('getCmd')
29  ->willReturn('');
30 
31  $ctrl
32  ->expects($this->once())
33  ->method('redirectToURL');
34 
35  $user = $this
36  ->getMockBuilder(\ilObjUser::class)
37  ->disableOriginalConstructor()
38  ->setMethods(['hasToAcceptTermsOfService', 'checkTimeLimit', 'hasToAcceptTermsOfServiceInSession'])
39  ->getMock();
40 
41  $user
42  ->expects($this->atLeast(1))
43  ->method('hasToAcceptTermsOfService')
44  ->willReturn(true);
45 
46  $user
47  ->expects($this->atLeast(1))
48  ->method('checkTimeLimit')
49  ->willReturn(true);
50 
51  $user
52  ->expects($this->atLeast(1))
53  ->method('hasToAcceptTermsOfServiceInSession')
54  ->willReturn(true);
55 
56  $requestInterceptor = new \ilTermsOfServiceRequestTargetAdjustmentCase($user, $ctrl);
57 
58  $this->assertTrue($requestInterceptor->shouldAdjustRequest());
59  $this->assertTrue($requestInterceptor->shouldStoreRequestTarget());
60  $requestInterceptor->adjust();
61  }
62 
67  {
68  $ctrl = $this
69  ->getMockBuilder(\ilCtrl::class)
70  ->disableOriginalConstructor()
71  ->setMethods(['getCmdClass', 'getCmd'])
72  ->getMock();
73 
74  $ctrl
75  ->expects($this->atLeast(1))
76  ->method('getCmdClass')
77  ->willReturn('ilstartupgui');
78 
79  $ctrl
80  ->expects($this->atLeast(1))
81  ->method('getCmd')
82  ->willReturn('getacceptance');
83 
84  $user = $this
85  ->getMockBuilder(\ilObjUser::class)
86  ->disableOriginalConstructor()
87  ->setMethods(['hasToAcceptTermsOfService', 'checkTimeLimit', 'hasToAcceptTermsOfServiceInSession'])
88  ->getMock();
89 
90  $user
91  ->expects($this->any())
92  ->method('hasToAcceptTermsOfService')
93  ->willReturn(true);
94 
95  $user
96  ->expects($this->any())
97  ->method('checkTimeLimit')
98  ->willReturn(true);
99 
100  $user
101  ->expects($this->any())
102  ->method('hasToAcceptTermsOfServiceInSession')
103  ->willReturn(true);
104 
105  $requestInterceptor = new \ilTermsOfServiceRequestTargetAdjustmentCase($user, $ctrl);
106 
107  $this->assertFalse($requestInterceptor->shouldAdjustRequest());
108  }
109 
113  public function userProvider() : array
114  {
115  $user1 = $this
116  ->getMockBuilder(\ilObjUser::class)
117  ->disableOriginalConstructor()
118  ->setMethods(['hasToAcceptTermsOfService', 'checkTimeLimit', 'hasToAcceptTermsOfServiceInSession'])
119  ->getMock();
120 
121  $user1
122  ->expects($this->any())
123  ->method('hasToAcceptTermsOfService')
124  ->willReturn(false);
125 
126  $user1
127  ->expects($this->any())
128  ->method('checkTimeLimit')
129  ->willReturn(true);
130 
131  $user1
132  ->expects($this->any())
133  ->method('hasToAcceptTermsOfServiceInSession')
134  ->willReturn(true);
135 
136  $user2 = $this
137  ->getMockBuilder(\ilObjUser::class)
138  ->disableOriginalConstructor()
139  ->setMethods(['hasToAcceptTermsOfService', 'checkTimeLimit', 'hasToAcceptTermsOfServiceInSession'])
140  ->getMock();
141 
142  $user2
143  ->expects($this->any())
144  ->method('hasToAcceptTermsOfService')
145  ->willReturn(true);
146 
147  $user2
148  ->expects($this->any())
149  ->method('checkTimeLimit')
150  ->willReturn(false);
151 
152  $user2
153  ->expects($this->any())
154  ->method('hasToAcceptTermsOfServiceInSession')
155  ->willReturn(true);
156 
157  $user3 = $this
158  ->getMockBuilder(\ilObjUser::class)
159  ->disableOriginalConstructor()
160  ->setMethods(['hasToAcceptTermsOfService', 'checkTimeLimit', 'hasToAcceptTermsOfServiceInSession'])
161  ->getMock();
162 
163  $user3
164  ->expects($this->any())
165  ->method('hasToAcceptTermsOfService')
166  ->willReturn(true);
167 
168  $user3
169  ->expects($this->any())
170  ->method('checkTimeLimit')
171  ->willReturn(true);
172 
173  $user3
174  ->expects($this->any())
175  ->method('hasToAcceptTermsOfServiceInSession')
176  ->willReturn(false);
177 
178  return [
179  [$user1],
180  [$user2],
181  [$user3],
182  ];
183  }
184 
190  {
191  $ctrl = $this
192  ->getMockBuilder(\ilCtrl::class)
193  ->disableOriginalConstructor()
194  ->setMethods(['getCmdClass', 'getCmd'])
195  ->getMock();
196 
197  $ctrl
198  ->expects($this->any())
199  ->method('getCmdClass')
200  ->willReturn('ilPersonalDesktopGUI');
201 
202  $ctrl
203  ->expects($this->any())
204  ->method('getCmd')
205  ->willReturn('');
206 
207  $requestInterceptor = new \ilTermsOfServiceRequestTargetAdjustmentCase($user, $ctrl);
208 
209  $this->assertFalse($requestInterceptor->shouldAdjustRequest());
210  }
211 }
Class ilTermsOfServiceBaseTest.
once($eventName, callable $callBack, $priority=100)
Subscribe to an event exactly once.
$user
Definition: migrateto20.php:57
Class ilTermsOfServiceRequestTargetAdjustmentCaseTest.