ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
WithdrawProcessTest.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
32use ILIAS\LegalDocuments\test\ContainerMock;
33use PHPUnit\Framework\TestCase;
34
35require_once __DIR__ . '/../../ContainerMock.php';
36
37class WithdrawProcessTest extends TestCase
38{
39 use ContainerMock;
40
41 public function testConstruct(): void
42 {
43 $this->assertInstanceOf(WithdrawProcess::class, new WithdrawProcess(
44 $this->mock(User::class),
45 $this->mock(UI::class),
46 $this->mock(Routing::class),
47 $this->mock(Settings::class),
48 $this->fail(...),
49 $this->mock(Provide::class),
50 $this->fail(...)
51 ));
52 }
53
54 public function testShowValidatePasswordMessage(): void
55 {
56 $instance = new WithdrawProcess(
57 $this->mock(User::class),
58 $this->mock(UI::class),
59 $this->mock(Routing::class),
60 $this->mock(Settings::class),
61 fn() => 'internal',
62 $this->mock(Provide::class),
63 $this->fail(...)
64 );
65
66 $array = $instance->showValidatePasswordMessage();
67 $this->assertSame(2, count($array));
68 $this->assertInstanceOf(Component::class, $array[0]);
69 $this->assertInstanceOf(Component::class, $array[1]);
70 }
71
72 public function testIsOnGoing(): void
73 {
74 $instance = new WithdrawProcess(
75 $this->mockTree(User::class, ['withdrawalRequested' => ['value' => true]]),
76 $this->mock(UI::class),
77 $this->mock(Routing::class),
78 $this->mock(Settings::class),
79 $this->fail(...),
80 $this->mock(Provide::class),
81 $this->fail(...)
82 );
83
84 $this->assertTrue($instance->isOnGoing());
85 }
86
87 public function testWithdrawalRequested(): void
88 {
89 $setting = $this->mock(Setting::class);
90 $setting->expects(self::once())->method('update')->with(true);
91
92 $instance = new WithdrawProcess(
93 $this->mockTree(User::class, ['cannotAgree' => false, 'neverAgreed' => false, 'withdrawalRequested' => $setting]),
94 $this->mock(UI::class),
95 $this->mock(Routing::class),
96 $this->mock(Settings::class),
97 $this->fail(...),
98 $this->mock(Provide::class),
99 $this->fail(...)
100 );
101
102 $reflection = new \ReflectionClass($instance);
103 $method = $reflection->getMethod('withdrawalRequested');
104 $method->invoke($instance);
105 }
106
108 {
109 $instance = new WithdrawProcess(
110 $this->mockTree(User::class, ['cannotAgree' => true, 'neverAgreed' => false]),
111 $this->mock(UI::class),
112 $this->mock(Routing::class),
113 $this->mock(Settings::class),
114 $this->fail(...),
115 $this->mock(Provide::class),
116 $this->fail(...)
117 );
118
119 $reflection = new \ReflectionClass($instance);
120 $method = $reflection->getMethod('withdrawalRequested');
121 $method->invoke($instance);
122 $this->assertTrue(true);
123 }
124
125 public function testWithdrawalFinished(): void
126 {
127 $main_template = $this->mock(ilGlobalTemplateInterface::class);
128 $main_template->expects(self::once())->method('setOnScreenMessage');
129
130 $instance = new WithdrawProcess(
131 $this->mock(User::class),
132 $this->mockTree(UI::class, ['mainTemplate' => $main_template]),
133 $this->mock(Routing::class),
134 $this->mock(Settings::class),
135 fn() => null,
136 $this->mock(Provide::class),
137 $this->fail(...)
138 );
139
140 $instance->withdrawalFinished();
141 }
142
143 public function testShowWithdraw(): void
144 {
145 $instance = new WithdrawProcess(
146 $this->mock(User::class),
147 $this->mock(UI::class),
148 $this->mock(Routing::class),
149 $this->mock(Settings::class),
150 $this->fail(...),
151 $this->mock(Provide::class),
152 $this->fail(...)
153 );
154
155 $this->assertInstanceOf(PageFragment::class, $instance->showWithdraw('foo', ''));
156 }
157}
ilSetting $setting
Definition: class.ilias.php:68
A component is the most general form of an entity in the UI.
Definition: Component.php:28