Definition at line 44 of file UserTest.php.
◆ ensureDefined()
ILIAS\LegalDocuments\test\ConsumerToolbox\UserTest::ensureDefined |
( |
string |
$name, |
|
|
|
$value |
|
) |
| |
|
private |
◆ externalAuthModes()
static ILIAS\LegalDocuments\test\ConsumerToolbox\UserTest::externalAuthModes |
( |
| ) |
|
|
static |
◆ testAcceptAnyDocument()
ILIAS\LegalDocuments\test\ConsumerToolbox\UserTest::testAcceptAnyDocument |
( |
| ) |
|
Definition at line 384 of file UserTest.php.
386 $user = $this->mock(ilObjUser::class);
387 $history = $this->mock(ProvideHistory::class);
388 $doc = $this->mock(Document::class);
389 $history->expects(self::once())->method(
'acceptDocument')->with($user, $doc);
391 $instance =
new User(
393 $this->mock(Settings::class),
394 $this->mock(UserSettings::class),
395 $this->mockTree(Provide::class, [
396 'document' => [
'repository' => [
'all' => [$doc]]],
397 'history' => $history,
399 $this->mock(Clock::class)
402 $instance->acceptAnyDocument();
◆ testAcceptedVersion()
ILIAS\LegalDocuments\test\ConsumerToolbox\UserTest::testAcceptedVersion |
( |
| ) |
|
Definition at line 258 of file UserTest.php.
References ILIAS\LegalDocuments\test\ConsumerToolbox\UserTest\ensureDefined().
263 $result = $this->mock(Result::class);
265 $user = $this->mockTree(ilObjUser::class, [
'getId' => 67]);
267 $instance =
new User(
269 $this->mock(Settings::class),
270 $this->mockTree(UserSettings::class, [
'agreeDate' => [
'value' =>
new DateTimeImmutable()]]),
271 $this->mockTree(Provide::class, [
'history' => $this->mockMethod(ProvideHistory::class,
'acceptedVersion', [$user], $result)]),
272 $this->mock(Clock::class)
275 $this->assertSame($result, $instance->acceptedVersion());
◆ testAcceptMatchingDocument()
ILIAS\LegalDocuments\test\ConsumerToolbox\UserTest::testAcceptMatchingDocument |
( |
| ) |
|
Definition at line 298 of file UserTest.php.
References ILIAS\$setting.
300 $user = $this->mock(ilObjUser::class);
301 $document = $this->mock(Document::class);
304 $history = $this->mock(ProvideHistory::class);
305 $history->expects(self::once())->method(
'acceptDocument')->with($user, $document);
307 $setting = $this->mock(Setting::class);
308 $setting->expects(self::once())->method(
'update')->with($date);
310 $instance =
new User(
312 $this->mock(Settings::class),
313 $this->mockTree(UserSettings::class, [
'agreeDate' =>
$setting]),
314 $this->mockTree(Provide::class, [
315 'document' => $this->mockMethod(ProvideDocument::class,
'chooseDocumentFor', [$user],
new Ok($document)),
316 'history' => $history,
318 $this->mockTree(Clock::class, [
'now' => $date])
321 $instance->acceptMatchingDocument();
◆ testAcceptVersionError()
ILIAS\LegalDocuments\test\ConsumerToolbox\UserTest::testAcceptVersionError |
( |
| ) |
|
Definition at line 278 of file UserTest.php.
References ILIAS\LegalDocuments\test\ConsumerToolbox\UserTest\ensureDefined(), and null.
283 $user = $this->mockTree(ilObjUser::class, [
'getId' => 67]);
285 $instance =
new User(
287 $this->mock(Settings::class),
288 $this->mockTree(UserSettings::class, [
'agreeDate' => [
'value' =>
null]]),
289 $this->mock(Provide::class),
290 $this->mock(Clock::class)
293 $result = $instance->acceptedVersion();
294 $this->assertFalse($result->isOk());
295 $this->assertSame(
'User never agreed.', $result->error());
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
◆ testAgreeDate()
ILIAS\LegalDocuments\test\ConsumerToolbox\UserTest::testAgreeDate |
( |
| ) |
|
Definition at line 139 of file UserTest.php.
References ILIAS\$setting.
141 $setting = $this->mock(Setting::class);
143 $instance =
new User(
144 $this->mock(ilObjUser::class),
145 $this->mock(Settings::class),
146 $this->mockMethod(UserSettings::class,
'agreeDate', [],
$setting),
147 $this->mock(Provide::class),
148 $this->mock(Clock::class)
151 $this->assertSame(
$setting, $instance->agreeDate());
◆ testCannotAgree()
ILIAS\LegalDocuments\test\ConsumerToolbox\UserTest::testCannotAgree |
( |
| ) |
|
Definition at line 81 of file UserTest.php.
References ANONYMOUS_USER_ID, ILIAS\LegalDocuments\test\ConsumerToolbox\UserTest\ensureDefined(), and SYSTEM_USER_ID.
86 $user = $this->mock(ilObjUser::class);
91 $this->mock(Settings::class),
92 $this->mock(UserSettings::class),
93 $this->mock(Provide::class),
94 $this->mock(Clock::class)
97 $this->assertTrue($instance->cannotAgree());
98 $this->assertTrue($instance->cannotAgree());
99 $this->assertTrue($instance->cannotAgree());
100 $this->assertFalse($instance->cannotAgree());
101 $this->assertFalse($instance->cannotAgree());
const SYSTEM_USER_ID
This file contains constants for PHPStan analyis, see: https://phpstan.org/config-reference#constants...
◆ testConstruct()
ILIAS\LegalDocuments\test\ConsumerToolbox\UserTest::testConstruct |
( |
| ) |
|
Definition at line 48 of file UserTest.php.
50 $this->assertInstanceOf(User::class,
new User(
51 $this->mock(ilObjUser::class),
52 $this->mock(Settings::class),
53 $this->mock(UserSettings::class),
54 $this->mock(Provide::class),
55 $this->mock(Clock::class)
◆ testDidNotAcceptCurrentVersion()
ILIAS\LegalDocuments\test\ConsumerToolbox\UserTest::testDidNotAcceptCurrentVersion |
( |
| ) |
|
Definition at line 154 of file UserTest.php.
156 $user = $this->mock(ilObjUser::class);
157 $document = $this->mock(Document::class);
159 $instance =
new User(
161 $this->mockTree(Settings::class, [
'validateOnLogin' => [
'value' =>
true]]),
162 $this->mock(UserSettings::class),
163 $this->mockTree(Provide::class, [
164 'document' => $this->mockMethod(ProvideDocument::class,
'chooseDocumentFor', [$user],
new Ok($document)),
165 'history' => $this->mockMethod(ProvideHistory::class,
'alreadyAccepted', [$user, $document],
false),
167 $this->mock(Clock::class)
170 $this->assertTrue($instance->didNotAcceptCurrentVersion());
◆ testDoesntMatch()
ILIAS\LegalDocuments\test\ConsumerToolbox\UserTest::testDoesntMatch |
( |
| ) |
|
Definition at line 222 of file UserTest.php.
224 $document = $this->mock(Document::class);
225 $user = $this->mock(ilObjUser::class);
227 $instance =
new User(
229 $this->mock(Settings::class),
230 $this->mock(UserSettings::class),
231 $this->mockTree(Provide::class, [
232 'document' => $this->mockMethod(ProvideDocument::class,
'documentMatches', [$document, $user],
true),
234 $this->mock(Clock::class)
237 $this->assertFalse($instance->doesntMatch($document));
◆ testFormat()
ILIAS\LegalDocuments\test\ConsumerToolbox\UserTest::testFormat |
( |
| ) |
|
Definition at line 351 of file UserTest.php.
353 $instance =
new User(
354 $this->mockTree(ilObjUser::class, [
355 'getFullname' =>
'foo',
357 'getExternalAccount' =>
'baz',
359 $this->mock(Settings::class),
360 $this->mock(UserSettings::class),
361 $this->mock(Provide::class),
362 $this->mock(Clock::class)
365 $this->assertSame(
'', $instance->format(
''));
366 $this->assertSame(
"hej foo bar\nbaz", $instance->format(
'hej %s %s[BR]%s'));
◆ testIsExternalUser()
ILIAS\LegalDocuments\test\ConsumerToolbox\UserTest::testIsExternalUser |
( |
int |
$auth_mode, |
|
|
bool |
$is_external_account |
|
) |
| |
Definition at line 338 of file UserTest.php.
340 $instance =
new User(
341 $this->mockTree(ilObjUser::class, [
'getAuthMode' =>
'default']),
342 $this->mockTree(Settings::class, [
'authMode' => [
'value' => (
string) $auth_mode]]),
343 $this->mock(UserSettings::class),
344 $this->mock(Provide::class),
345 $this->mock(Clock::class)
348 $this->assertSame($is_external_account, $instance->isExternalAccount());
◆ testIsLDAPUser()
ILIAS\LegalDocuments\test\ConsumerToolbox\UserTest::testIsLDAPUser |
( |
| ) |
|
Definition at line 324 of file UserTest.php.
References ilAuthUtils\AUTH_LDAP.
326 $instance =
new User(
327 $this->mockTree(ilObjUser::class, [
'getAuthMode' =>
'default']),
329 $this->mock(UserSettings::class),
330 $this->mock(Provide::class),
331 $this->mock(Clock::class)
334 $this->assertTrue($instance->isLDAPUser());
◆ testIsLoggedIn()
ILIAS\LegalDocuments\test\ConsumerToolbox\UserTest::testIsLoggedIn |
( |
| ) |
|
Definition at line 59 of file UserTest.php.
References ANONYMOUS_USER_ID, and ILIAS\LegalDocuments\test\ConsumerToolbox\UserTest\ensureDefined().
63 $user = $this->mock(ilObjUser::class);
64 $user->expects(self::exactly(5))->method(
'getId')->willReturnOnConsecutiveCalls(0,
ANONYMOUS_USER_ID, 9, 1, 68);
68 $this->mock(Settings::class),
69 $this->mock(UserSettings::class),
70 $this->mock(Provide::class),
71 $this->mock(Clock::class)
74 $this->assertFalse($instance->isLoggedIn());
75 $this->assertFalse($instance->isLoggedIn());
76 $this->assertTrue($instance->isLoggedIn());
77 $this->assertTrue($instance->isLoggedIn());
78 $this->assertTrue($instance->isLoggedIn());
◆ testMatchingDocument()
ILIAS\LegalDocuments\test\ConsumerToolbox\UserTest::testMatchingDocument |
( |
| ) |
|
Definition at line 240 of file UserTest.php.
242 $user = $this->mock(ilObjUser::class);
243 $result = $this->mock(Result::class);
245 $instance =
new User(
247 $this->mock(Settings::class),
248 $this->mock(UserSettings::class),
249 $this->mockTree(Provide::class, [
250 'document' => $this->mockMethod(ProvideDocument::class,
'chooseDocumentFor', [$user], $result),
252 $this->mock(Clock::class)
255 $this->assertSame($result, $instance->matchingDocument());
◆ testNeedsToAcceptNewDocumentReturnsFalse()
ILIAS\LegalDocuments\test\ConsumerToolbox\UserTest::testNeedsToAcceptNewDocumentReturnsFalse |
( |
| ) |
|
Definition at line 202 of file UserTest.php.
204 $user = $this->mock(ilObjUser::class);
205 $document = $this->mock(Document::class);
206 $history = $this->mockMethod(ProvideHistory::class,
'currentDocumentOfAcceptedVersion', [$user],
new Ok($document));
208 $instance =
new User(
210 $this->mockTree(Settings::class, [
'validateOnLogin' => [
'value' =>
true]]),
211 $this->mockTree(UserSettings::class, [
'agreeDate' => [
'value' =>
new DateTimeImmutable()]]),
212 $this->mockTree(Provide::class, [
213 'document' => $this->mockMethod(ProvideDocument::class,
'documentMatches', [$document, $user],
true),
214 'history' => $history,
216 $this->mock(Clock::class)
219 $this->assertFalse($instance->needsToAcceptNewDocument());
◆ testNeedsToAcceptNewDocumentReturnsTrue()
ILIAS\LegalDocuments\test\ConsumerToolbox\UserTest::testNeedsToAcceptNewDocumentReturnsTrue |
( |
| ) |
|
Definition at line 186 of file UserTest.php.
188 $user = $this->mock(ilObjUser::class);
189 $history = $this->mockMethod(ProvideHistory::class,
'currentDocumentOfAcceptedVersion', [$user],
new Error(
'Not found.'));
191 $instance =
new User(
193 $this->mockTree(Settings::class, [
'validateOnLogin' => [
'value' =>
true]]),
194 $this->mockTree(UserSettings::class, [
'agreeDate' => [
'value' =>
new DateTimeImmutable()]]),
195 $this->mockTree(Provide::class, [
'history' => $history]),
196 $this->mock(Clock::class)
199 $this->assertTrue($instance->needsToAcceptNewDocument());
◆ testNeedsToAcceptNewDocumentWhereNeverAgreed()
ILIAS\LegalDocuments\test\ConsumerToolbox\UserTest::testNeedsToAcceptNewDocumentWhereNeverAgreed |
( |
| ) |
|
Definition at line 173 of file UserTest.php.
References null.
175 $instance =
new User(
176 $this->mock(ilObjUser::class),
177 $this->mock(Settings::class),
178 $this->mockTree(UserSettings::class, [
'agreeDate' => [
'value' =>
null]]),
179 $this->mock(Provide::class),
180 $this->mock(Clock::class)
183 $this->assertTrue($instance->needsToAcceptNewDocument());
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
◆ testNeverAgreed()
ILIAS\LegalDocuments\test\ConsumerToolbox\UserTest::testNeverAgreed |
( |
| ) |
|
Definition at line 104 of file UserTest.php.
References ILIAS\$setting, and null.
106 $setting = $this->mock(Setting::class);
109 $user_settings = $this->mock(UserSettings::class);
110 $user_settings->expects(self::exactly(2))->method(
'agreeDate')->willReturn(
$setting);
112 $instance =
new User(
113 $this->mock(ilObjUser::class),
114 $this->mock(Settings::class),
116 $this->mock(Provide::class),
117 $this->mock(Clock::class)
120 $this->assertTrue($instance->neverAgreed());
121 $this->assertFalse($instance->neverAgreed());
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
◆ testRaw()
ILIAS\LegalDocuments\test\ConsumerToolbox\UserTest::testRaw |
( |
| ) |
|
Definition at line 369 of file UserTest.php.
371 $user = $this->mock(ilObjUser::class);
373 $instance =
new User(
375 $this->mock(Settings::class),
376 $this->mock(UserSettings::class),
377 $this->mock(Provide::class),
378 $this->mock(Clock::class)
381 $this->assertSame($user, $instance->raw());
◆ testWithdrawalRequested()
ILIAS\LegalDocuments\test\ConsumerToolbox\UserTest::testWithdrawalRequested |
( |
| ) |
|
Definition at line 124 of file UserTest.php.
References ILIAS\$setting.
126 $setting = $this->mock(Setting::class);
128 $instance =
new User(
129 $this->mock(ilObjUser::class),
130 $this->mock(Settings::class),
131 $this->mockMethod(UserSettings::class,
'withdrawalRequested', [],
$setting),
132 $this->mock(Provide::class),
133 $this->mock(Clock::class)
136 $this->assertSame(
$setting, $instance->withdrawalRequested());
The documentation for this class was generated from the following file:
- components/ILIAS/LegalDocuments/tests/ConsumerToolbox/UserTest.php