19 declare(strict_types=1);
34 require_once __DIR__ .
'/../../ContainerMock.php';
44 $this->mock(UI::class),
45 $this->mock(User::class),
46 $this->mock(Provide::class),
56 $this->mock(UI::class),
57 $this->mockTree(User::class, [
'matchingDocument' =>
new Ok($this->mock(Document::class))]),
58 $this->mock(Provide::class),
64 $guis = $instance->legacyInputGUIs();
65 $this->assertSame(3, count($guis));
72 $this->mock(UI::class),
73 $this->mockTree(User::class, [
'matchingDocument' =>
new Ok($this->mock(Document::class))]),
74 $this->mock(Provide::class),
80 $this->assertTrue($instance->saveLegacyForm($this->mockTree(ilPropertyFormGUI::class, [
'getInput' =>
true])));
87 $this->mock(UI::class),
88 $this->mockTree(User::class, [
'matchingDocument' =>
new Ok($this->mock(Document::class))]),
89 $this->mock(Provide::class),
95 $checkbox = $this->mock(ilCheckboxInputGUI::class);
96 $checkbox->expects(self::once())->method(
'setAlert');
98 $form = $this->mockTree(ilPropertyFormGUI::class, [
'getInput' =>
false]);
99 $form->expects(self::once())->method(
'getItemByPostVar')->with(
'accept_foo')->willReturn($checkbox);
101 $this->assertFalse($instance->saveLegacyForm($form));
106 $user = $this->mock(ilObjUser::class);
107 $ldoc_user = $this->mock(User::class);
108 $ldoc_user->expects(self::once())->method(
'acceptMatchingDocument');
112 $this->mock(UI::class),
113 $this->mock(User::class),
114 $this->mock(Provide::class),
117 $this->assertSame($user, $u);
128 $user = $this->mock(ilObjUser::class);
129 $ldoc_user = $this->mock(User::class);
130 $ldoc_user->expects(self::once())->method(
'acceptMatchingDocument')->willReturnCallback(
function () {
131 throw new \ILIAS\Data\NotOKException(
'This is not ok.');
134 $ldoc_user->expects(self::once())->method(
'acceptAnyDocument');
138 $this->mock(UI::class),
139 $this->mock(User::class),
140 $this->mock(Provide::class),
143 $this->assertSame($user, $u);
A result encapsulates a value or an error and simplifies the handling of those.