19 declare(strict_types=1);
35 require_once __DIR__ .
'/bootstrap.php';
43 $this->assertInstanceOf(UserSettings::class,
new UserSettings(
44 $this->mock(ilObjUser::class),
45 $this->mock(SelectSetting::class),
46 $this->mock(Refinery::class)
52 $setting = $this->mock(Setting::class);
53 $convert = $this->mock(Convert::class);
55 $marshal = $this->mockMethod(Marshal::class,
'boolean', [], $convert);
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));
65 $this->mock(ilObjUser::class),
67 $this->mock(Refinery::class)
70 $this->assertSame(
$setting, $instance->withdrawalRequested());
78 $by_trying = $this->mock(ByTrying::class);
80 [
'agree date', $return_date],
81 [$date,
'another date']
83 $by_trying->expects(self::exactly(2))
86 function ($in) use (&$consecutive) {
87 [$expected, $ret] = array_shift($consecutive);
88 $this->assertEquals($expected, $in);
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');
98 $refinery = $this->mockTree(Refinery::class, [
'byTrying' => $by_trying]);
102 $this->mock(SelectSetting::class),
107 $this->assertSame($return_date,
$setting->value());
testWithdrawalRequested()