19 declare(strict_types=1);
36 require_once __DIR__ .
'/../../ContainerMock.php';
44 $this->assertInstanceOf(Agreement::class,
new Agreement(
45 $this->mock(User::class),
46 $this->mock(Settings::class),
47 $this->mock(UI::class),
48 $this->mock(Routing::class),
56 $this->mockTree(User::class, [
'matchingDocument' =>
new Ok($this->mock(Document::class))]),
57 $this->mock(Settings::class),
58 $this->mock(UI::class),
59 $this->mock(Routing::class),
63 $this->assertInstanceOf(ShowOnScreenMessage::class, $instance->showAgreement(
'foo',
'bar'));
69 $this->mockTree(User::class, [
'matchingDocument' =>
new Ok($this->mock(Document::class))]),
70 $this->mock(Settings::class),
71 $this->mock(UI::class),
72 $this->mock(Routing::class),
73 fn() => $this->mock(Component::class)
76 $this->assertInstanceOf(ShowOnScreenMessage::class, $instance->showAgreementForm(
'foo',
'bar'));
82 $this->mockTree(User::class, [
83 'cannotAgree' =>
false,
84 'neverAgreed' =>
false,
85 'didNotAcceptCurrentVersion' =>
false,
87 $this->mock(Settings::class),
88 $this->mock(UI::class),
89 $this->mock(Routing::class),
93 $this->assertFalse($instance->needsToAgree());
99 $this->mockTree(User::class, [
100 'cannotAgree' =>
true,
101 'didNotAcceptCurrentVersion' =>
true,
103 $this->mock(Settings::class),
104 $this->mock(UI::class),
105 $this->mock(Routing::class),
109 $this->assertFalse($instance->needsToAgree());
115 $this->mockTree(User::class, [
116 'cannotAgree' =>
false,
117 'needsToAcceptNewDocument' =>
true,
119 $this->mock(Settings::class),
120 $this->mock(UI::class),
121 $this->mock(Routing::class),
125 $this->assertTrue($instance->needsToAgree());
A result encapsulates a value or an error and simplifies the handling of those.