ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
UserSettingsTest.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
26use ILIAS\LegalDocuments\test\ContainerMock;
29use PHPUnit\Framework\TestCase;
30
31require_once __DIR__ . '/bootstrap.php';
32
33class UserSettingsTest extends TestCase
34{
35 use ContainerMock;
36
37 public function testConstruct(): void
38 {
39 $this->assertInstanceOf(UserSettings::class, new UserSettings($this->mock(SelectSetting::class)));
40 }
41
42 public function testWithdrawalRequested(): void
43 {
44 $setting = $this->mock(Setting::class);
45 $convert = $this->mock(Convert::class);
46
47 $marshal = $this->mockMethod(Marshal::class, 'boolean', [], $convert);
48
49 $settings = $this->mock(SelectSetting::class);
50 $settings->expects(self::once())->method('typed')->willReturnCallback(function (string $key, callable $select) use ($marshal, $convert, $setting) {
51 $this->assertSame('dpro_withdrawal_requested', $key);
52 $this->assertSame($convert, $select($marshal));
53 return $setting;
54 });
55
56 $this->assertSame($setting, (new UserSettings($settings))->withdrawalRequested());
57 }
58
59 public function testAgreeDate(): void
60 {
61 $setting = $this->mock(Setting::class);
62 $convert = $this->mock(Convert::class);
63
64 $date = $this->mock(Convert::class);
65
66 $marshal = $this->mockMethod(Marshal::class, 'nullable', [$date], $convert);
67 $marshal->expects(self::once())->method('dateTime')->willReturn($date);
68
69 $settings = $this->mock(SelectSetting::class);
70 $settings->expects(self::once())->method('typed')->willReturnCallback(function (string $key, callable $select) use ($marshal, $convert, $setting) {
71 $this->assertSame('dpro_agree_date', $key);
72 $this->assertSame($convert, $select($marshal));
73 return $setting;
74 });
75
76 $this->assertSame($setting, (new UserSettings($settings))->agreeDate());
77 }
78}
ilSetting $setting
Definition: class.ilias.php:68