ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ILIAS\LegalDocuments\test\ConductorTest Class Reference
+ Inheritance diagram for ILIAS\LegalDocuments\test\ConductorTest:
+ Collaboration diagram for ILIAS\LegalDocuments\test\ConductorTest:

Public Member Functions

 testConstruct ()
 
 testProvide ()
 
 testLoginPageHTML ()
 
 testLogoutText ()
 
 testModifyFooter ()
 
 testAgree (string $gui, string $key)
 
 testAgreeContent (string $gui, string $key)
 
 testRedirectAgreeContent ()
 
 testWithdraw ()
 
 testUsersWithHiddenOnlineStatus ()
 
 testUserCanReadInternalMail ()
 
 testCanUseSoapApi ()
 
 testAfterLogin ()
 
 testFindGotoLink ()
 
 testIntercepting ()
 
 testSelfRegistration ()
 
 testUserManagementFields ()
 

Static Public Member Functions

static agreeTypes ()
 

Private Member Functions

 agreement (string $method, string $gui, string $key, ?ilGlobalTemplateInterface $main_template=null)
 

Detailed Description

Definition at line 54 of file ConductorTest.php.

Member Function Documentation

◆ agreement()

ILIAS\LegalDocuments\test\ConductorTest::agreement ( string  $method,
string  $gui,
string  $key,
?ilGlobalTemplateInterface  $main_template = null 
)
private

Definition at line 318 of file ConductorTest.php.

319 {
320 $constraint = $this->mock(Constraint::class);
321
322 $ctrl = $this->mock(ilCtrl::class);
323 $ctrl->expects(self::once())->method('setParameterByClass')->with($gui, 'id', 'foo');
324
325 $container = $this->mockTree(Container::class, [
326 'refinery' => ['to' => ['string' => $constraint]],
327 'http' => ['wrapper' => ['query' => $this->mockMethod(ArrayBasedRequestWrapper::class, 'retrieve', ['id', $constraint], 'foo')]],
328 'ui' => [
329 'mainTemplate' => $main_template ?? $this->mock(ilGlobalTemplateInterface::class),
330 'renderer' => $this->mock(Renderer::class),
331 ],
332 'ctrl' => $ctrl,
333 ]);
334
335 $fragment = $this->mockMethod(PageFragment::class, 'render', [$container->ui()->mainTemplate(), $container->ui()->renderer()], 'rendered');
336
337 $internal = $this->mockMethod(Internal::class, 'get', [$key, 'foo'], function (string $g, string $cmd) use ($fragment, $gui): Result {
338 $this->assertSame($gui, $g);
339 $this->assertSame('some cmd', $cmd);
340 return new Ok($fragment);
341 });
342
343 $instance = new Conductor($container, $internal, $this->mock(Routing::class));
344
345 return $instance->$method($gui, 'some cmd');
346 }
$container
@noRector
Definition: wac.php:37

References $container.

Referenced by ILIAS\LegalDocuments\test\ConductorTest\testAgree(), ILIAS\LegalDocuments\test\ConductorTest\testAgreeContent(), and ILIAS\LegalDocuments\test\ConductorTest\testWithdraw().

+ Here is the caller graph for this function:

◆ agreeTypes()

static ILIAS\LegalDocuments\test\ConductorTest::agreeTypes ( )
static

Definition at line 310 of file ConductorTest.php.

310 : array
311 {
312 return [
313 'Form type' => [ilLegalDocumentsAgreementGUI::class, 'agreement-form'],
314 'Public type' => ['foo', 'public-page'],
315 ];
316 }

◆ testAfterLogin()

ILIAS\LegalDocuments\test\ConductorTest::testAfterLogin ( )

Definition at line 234 of file ConductorTest.php.

234 : void
235 {
236 $called = [false, false];
237
238 $internal = $this->mockMethod(Internal::class, 'all', ['after-login'], [
239 function () use (&$called): void {
240 $called[0] = true;
241 },
242 function () use (&$called): void {
243 $called[1] = true;
244 }
245 ]);
246
247 $instance = new Conductor($this->mock(Container::class), $internal, $this->mock(Routing::class));
248
249 $instance->afterLogin();
250
251 $this->assertSame([true, true], $called);
252 }

◆ testAgree()

ILIAS\LegalDocuments\test\ConductorTest::testAgree ( string  $gui,
string  $key 
)

Definition at line 141 of file ConductorTest.php.

141 : void
142 {
143 $main_template = $this->mock(ilGlobalTemplateInterface::class);
144 $main_template->expects(self::once())->method('setContent')->with('rendered');
145 $this->agreement('agree', $gui, $key, $main_template);
146 }
agreement(string $method, string $gui, string $key, ?ilGlobalTemplateInterface $main_template=null)

References ILIAS\LegalDocuments\test\ConductorTest\agreement().

+ Here is the call graph for this function:

◆ testAgreeContent()

ILIAS\LegalDocuments\test\ConductorTest::testAgreeContent ( string  $gui,
string  $key 
)

Definition at line 149 of file ConductorTest.php.

149 : void
150 {
151 $this->assertSame('rendered', $this->agreement('agreeContent', $gui, $key));
152 }

References ILIAS\LegalDocuments\test\ConductorTest\agreement().

+ Here is the call graph for this function:

◆ testCanUseSoapApi()

ILIAS\LegalDocuments\test\ConductorTest::testCanUseSoapApi ( )

Definition at line 217 of file ConductorTest.php.

217 : void
218 {
219 $constraints = [
220 'foo' => $this->mock(Constraint::class),
221 'bar' => $this->mock(Constraint::class),
222 ];
223
224 $container = $this->mockTree(Container::class, [
225 'refinery' => ['in' => $this->mockMethod(InGroup::class, 'series', [array_values($constraints)], $this->mock(Transformation::class))]
226 ]);
227
228 $internal = $this->mockMethod(Internal::class, 'all', ['use-soap-api'], $constraints);
229
230 $instance = new Conductor($container, $internal, $this->mock(Routing::class));
231 $this->assertInstanceOf(Transformation::class, $instance->canUseSoapApi());
232 }

References $container.

◆ testConstruct()

ILIAS\LegalDocuments\test\ConductorTest::testConstruct ( )

Definition at line 58 of file ConductorTest.php.

58 : void
59 {
60 $this->assertInstanceOf(Conductor::class, new Conductor($this->mock(Container::class), $this->mock(Internal::class), $this->mock(Routing::class)));
61 }

◆ testFindGotoLink()

ILIAS\LegalDocuments\test\ConductorTest::testFindGotoLink ( )

Definition at line 254 of file ConductorTest.php.

254 : void
255 {
256 $foo = $this->mock(Target::class);
257 $internal = $this->mockMethod(Internal::class, 'all', ['goto'], [
258 $this->mockTree(GotoLink::class, ['name' => 'bar']),
259 $this->mockTree(GotoLink::class, ['name' => 'foo', 'target' => $foo]),
260 ]);
261
262 $instance = new Conductor($this->mock(Container::class), $internal, $this->mock(Routing::class));
263
264 $target = $instance->findGotoLink('foo');
265 $this->assertTrue($target->isOk());
266 $this->assertSame($foo, $target->value());
267 }

References Vendor\Package\$foo.

◆ testIntercepting()

ILIAS\LegalDocuments\test\ConductorTest::testIntercepting ( )

Definition at line 270 of file ConductorTest.php.

270 : void
271 {
272 $intercepting = [
273 'foo' => $this->mock(Intercept::class),
274 'bar' => $this->mock(Intercept::class)
275 ];
276
277 $internal = $this->mockMethod(Internal::class, 'all', ['intercept'], $intercepting);
278
279 $instance = new Conductor($this->mock(Container::class), $internal, $this->mock(Routing::class));
280 $this->assertSame($intercepting, $instance->intercepting());
281 }

◆ testLoginPageHTML()

ILIAS\LegalDocuments\test\ConductorTest::testLoginPageHTML ( )

Definition at line 69 of file ConductorTest.php.

69 : void
70 {
71 $components = [
72 $this->mock(Component::class),
73 $this->mock(Component::class),
74 ];
75
76 $space = $this->mock(Content::class);
77
78 $container = $this->mockTree(Container::class, [
79 'ui' => [
80 'renderer' => $this->mockMethod(Renderer::class, 'render', [
82 ], 'rendered'),
83 ],
84 ]);
85
86 $internal = $this->mockMethod(Internal::class, 'get', ['show-on-login-page', 'foo'], fn() => $components);
87
88 $instance = new Conductor($container, $internal, $this->mock(Routing::class));
89
90 $this->assertSame('rendered', $instance->loginPageHTML('foo'));
91 }
$space
Definition: Sanitizer.php:35
$components

References $components, $container, and $space.

◆ testLogoutText()

ILIAS\LegalDocuments\test\ConductorTest::testLogoutText ( )

Definition at line 93 of file ConductorTest.php.

93 : void
94 {
95 $constraint = $this->mock(Constraint::class);
96 $component = $this->mock(Component::class);
97
98 $container = $this->mockTree(Container::class, [
99 'refinery' => ['to' => ['string' => $constraint]],
100 'http' => ['wrapper' => ['query' => $this->mockMethod(ArrayBasedRequestWrapper::class, 'retrieve', ['withdraw_consent', $constraint], 'foo')]],
101 'ui' => ['renderer' => $this->mockMethod(Renderer::class, 'render', [$component], 'rendered')],
102 ]);
103
104
105 $internal = $this->mock(Internal::class);
106 $internal->method('get')->willReturnCallback(function ($param1, $param2) use (&$called, $component) {
107 if ($param1 === 'logout-text' && $param2 === 'foo') {
108 return static function () use ($component): Component {
109 return $component;
110 };
111 }
112
113 return null;
114 });
115
116 $instance = new Conductor($container, $internal, $this->mock(Routing::class));
117
118 $logoutText = $instance->logoutText();
119
120 $this->assertSame('rendered', $logoutText);
121 }

References $container.

◆ testModifyFooter()

ILIAS\LegalDocuments\test\ConductorTest::testModifyFooter ( )

Definition at line 123 of file ConductorTest.php.

123 : void
124 {
125 $footer = fn() => null;
126
127 $modify_footer = function (Closure $f) use ($footer) {
128 $this->assertSame($footer, $f);
129 return $f;
130 };
131
132 $instance = new Conductor($this->mock(Container::class), $this->mockMethod(Internal::class, 'all', ['footer'], [
133 $modify_footer,
134 $modify_footer,
135 ]), $this->mock(Routing::class));
136
137 $this->assertSame($footer, $instance->modifyFooter($footer));
138 }

References Vendor\Package\$f.

◆ testProvide()

ILIAS\LegalDocuments\test\ConductorTest::testProvide ( )

Definition at line 63 of file ConductorTest.php.

63 : void
64 {
65 $instance = new Conductor($this->mock(Container::class), $this->mock(Internal::class), $this->mock(Routing::class));
66 $this->assertInstanceOf(Provide::class, $instance->provide('foo'));
67 }

◆ testRedirectAgreeContent()

ILIAS\LegalDocuments\test\ConductorTest::testRedirectAgreeContent ( )

Definition at line 154 of file ConductorTest.php.

154 : void
155 {
156 $this->expectExceptionMessage('Not available.');
157 $routing = $this->mock(Routing::class);
158 $routing->expects(self::once())->method('redirectToOriginalTarget');
159 $constraint = $this->mock(Constraint::class);
160 $container = $this->mockTree(Container::class, [
161 'refinery' => ['to' => ['string' => $constraint]],
162 'http' => ['wrapper' => ['query' => $this->mockMethod(ArrayBasedRequestWrapper::class, 'retrieve', ['id', $constraint], 'foo')]],
163 ]);
164 $internal = $this->mock(Internal::class);
165 $internal = $this->mockMethod(Internal::class, 'get', ['agreement-form', 'foo'], function (string $g, string $cmd): Result {
166 return new Error('Not available.');
167 });
168 $instance = new Conductor($container, $internal, $routing);
169 $instance->agreeContent(ilLegalDocumentsAgreementGUI::class, 'foo');
170 }

References $container.

◆ testSelfRegistration()

ILIAS\LegalDocuments\test\ConductorTest::testSelfRegistration ( )

Definition at line 283 of file ConductorTest.php.

283 : void
284 {
285 $internal = $this->mockMethod(Internal::class, 'all', ['self-registration'], [
286 $this->mock(SelfRegistration::class),
287 ]);
288
289 $instance = new Conductor($this->mock(Container::class), $internal, $this->mock(Routing::class));
290
291 $this->assertInstanceOf(Bundle::class, $instance->selfRegistration());
292 }

◆ testUserCanReadInternalMail()

ILIAS\LegalDocuments\test\ConductorTest::testUserCanReadInternalMail ( )

Definition at line 193 of file ConductorTest.php.

193 : void
194 {
195 $constraints = [
196 'foo' => $this->mock(Constraint::class),
197 'bar' => $this->mock(Constraint::class),
198 ];
199
200 $series = $this->mock(Transformation::class);
201
202 $container = $this->mockTree(Container::class, [
203 'refinery' => ['in' => $this->mockMethod(
204 InGroup::class,
205 'series',
206 [array_values($constraints)],
207 $series
208 )],
209 ]);
210
211 $internal = $this->mockMethod(Internal::class, 'all', ['constrain-internal-mail'], $constraints);
212
213 $instance = new Conductor($container, $internal, $this->mock(Routing::class));
214 $this->assertSame($series, $instance->userCanReadInternalMail());
215 }

References $container.

◆ testUserManagementFields()

ILIAS\LegalDocuments\test\ConductorTest::testUserManagementFields ( )

Definition at line 294 of file ConductorTest.php.

294 : void
295 {
296 $internal = $this->mockMethod(Internal::class, 'all', ['user-management-fields'], [
297 fn() => ['foo' => 'bar', 'baz' => 'hej'],
298 fn() => ['hoo' => 'har'],
299 ]);
300
301 $instance = new Conductor($this->mock(Container::class), $internal, $this->mock(Routing::class));
302
303 $this->assertSame([
304 'foo' => 'bar',
305 'baz' => 'hej',
306 'hoo' => 'har',
307 ], $instance->userManagementFields($this->mock(ilObjUser::class)));
308 }

◆ testUsersWithHiddenOnlineStatus()

ILIAS\LegalDocuments\test\ConductorTest::testUsersWithHiddenOnlineStatus ( )

Definition at line 179 of file ConductorTest.php.

179 : void
180 {
181 $internal = $this->mockMethod(Internal::class, 'all', ['filter-online-users'], [
182 fn() => [4, 5, 6],
183 fn() => [5, 6],
184 ]);
185 $instance = new Conductor($this->mock(Container::class), $internal, $this->mock(Routing::class));
186
187 $this->assertSame(
188 [1, 2, 3, 4, 7, 8, 9],
189 $instance->usersWithHiddenOnlineStatus([1, 2, 3, 4, 5, 6, 7, 8, 9])
190 );
191 }

◆ testWithdraw()

ILIAS\LegalDocuments\test\ConductorTest::testWithdraw ( )

Definition at line 172 of file ConductorTest.php.

172 : void
173 {
174 $main_template = $this->mock(ilGlobalTemplateInterface::class);
175 $main_template->expects(self::once())->method('setContent')->with('rendered');
176 $this->agreement('withdraw', 'foo', 'withdraw', $main_template);
177 }

References ILIAS\LegalDocuments\test\ConductorTest\agreement().

+ Here is the call graph for this function:

The documentation for this class was generated from the following file: