ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ILIAS\TermsOfService\test\UserSettingsTest Class Reference
+ Inheritance diagram for ILIAS\TermsOfService\test\UserSettingsTest:
+ Collaboration diagram for ILIAS\TermsOfService\test\UserSettingsTest:

Public Member Functions

 testConstruct ()
 
 testWithdrawalRequested ()
 
 testAgreeDate ()
 

Detailed Description

Definition at line 37 of file UserSettingsTest.php.

Member Function Documentation

◆ testAgreeDate()

ILIAS\TermsOfService\test\UserSettingsTest::testAgreeDate ( )

Definition at line 73 of file UserSettingsTest.php.

73 : void
74 {
75 $date = new DateTimeImmutable();
76 $return_date = new DateTimeImmutable();
77
78 $by_trying = $this->mock(ByTrying::class);
79 $consecutive = [
80 ['agree date', $return_date],
81 [$date, 'another date']
82 ];
83 $by_trying->expects(self::exactly(2))
84 ->method('transform')
85 ->willReturnCallback(
86 function ($in) use (&$consecutive) {
87 [$expected, $ret] = array_shift($consecutive);
88 $this->assertEquals($expected, $in);
89 return $ret;
90 }
91 );
92
93 $user = $this->mock(ilObjUser::class);
94 $user->expects(self::once())->method('getAgreeDate')->willReturn('agree date');
95 $user->expects(self::once())->method('setAgreeDate')->with('another date');
96 $user->expects(self::once())->method('update');
97
98 $refinery = $this->mockTree(Refinery::class, ['byTrying' => $by_trying]);
99
100 $instance = new UserSettings(
101 $user,
102 $this->mock(SelectSetting::class),
104 );
105
106 $setting = $instance->agreeDate();
107 $this->assertSame($return_date, $setting->value());
108 $setting->update($date);
109 }
ilSetting $setting
Definition: class.ilias.php:68

References ILIAS\UI\examples\Layout\Page\Standard\$refinery, and ILIAS\$setting.

◆ testConstruct()

ILIAS\TermsOfService\test\UserSettingsTest::testConstruct ( )

Definition at line 41 of file UserSettingsTest.php.

41 : void
42 {
43 $this->assertInstanceOf(UserSettings::class, new UserSettings(
44 $this->mock(ilObjUser::class),
45 $this->mock(SelectSetting::class),
46 $this->mock(Refinery::class)
47 ));
48 }

◆ testWithdrawalRequested()

ILIAS\TermsOfService\test\UserSettingsTest::testWithdrawalRequested ( )

Definition at line 50 of file UserSettingsTest.php.

50 : void
51 {
52 $setting = $this->mock(Setting::class);
53 $convert = $this->mock(Convert::class);
54
55 $marshal = $this->mockMethod(Marshal::class, 'boolean', [], $convert);
56
57 $settings = $this->mock(SelectSetting::class);
58 $settings->expects(self::once())->method('typed')->willReturnCallback(function (string $key, callable $select) use ($marshal, $convert, $setting) {
59 $this->assertSame('consent_withdrawal_requested', $key);
60 $this->assertSame($convert, $select($marshal));
61 return $setting;
62 });
63
64 $instance = new UserSettings(
65 $this->mock(ilObjUser::class),
66 $settings,
67 $this->mock(Refinery::class)
68 );
69
70 $this->assertSame($setting, $instance->withdrawalRequested());
71 }

References ILIAS\$setting.


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