ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
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 ()
 
 testOnLogout ()
 
 testLoginPageHTML ()
 
 testLogoutText ()
 
 testModifyFooter ()
 
 testAgree (string $gui, string $key)
 agreeTypes More...
 
 testAgreeContent (string $gui, string $key)
 agreeTypes More...
 
 testRedirectAgreeContent ()
 
 testWithdraw ()
 
 testUsersWithHiddenOnlineStatus ()
 
 testUserCanReadInternalMail ()
 
 testCanUseSoapApi ()
 
 testAfterLogin ()
 
 testFindGotoLink ()
 
 testIntercepting ()
 
 testSelfRegistration ()
 
 testUserManagementFields ()
 
 agreeTypes ()
 

Private Member Functions

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

Detailed Description

Definition at line 57 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 342 of file ConductorTest.php.

References $container.

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

343  {
344  $constraint = $this->mock(Constraint::class);
345 
346  $ctrl = $this->mock(ilCtrl::class);
347  $ctrl->expects(self::once())->method('setParameterByClass')->with($gui, 'id', 'foo');
348 
349  $container = $this->mockTree(Container::class, [
350  'refinery' => ['to' => ['string' => $constraint]],
351  'http' => ['wrapper' => ['query' => $this->mockMethod(ArrayBasedRequestWrapper::class, 'retrieve', ['id', $constraint], 'foo')]],
352  'ui' => [
353  'mainTemplate' => $main_template ?? $this->mock(ilGlobalTemplateInterface::class),
354  'renderer' => $this->mock(Renderer::class),
355  ],
356  'ctrl' => $ctrl,
357  ]);
358 
359  $fragment = $this->mockMethod(PageFragment::class, 'render', [$container->ui()->mainTemplate(), $container->ui()->renderer()], 'rendered');
360 
361  $internal = $this->mockMethod(Internal::class, 'get', [$key, 'foo'], function (string $g, string $cmd) use ($fragment, $gui): Result {
362  $this->assertSame($gui, $g);
363  $this->assertSame('some cmd', $cmd);
364  return new Ok($fragment);
365  });
366 
367  $instance = new Conductor($container, $internal, $this->mock(Routing::class));
368 
369  return $instance->$method($gui, 'some cmd');
370  }
$container
Definition: wac.php:14
string $key
Consumer key/client ID value.
Definition: System.php:193
+ Here is the caller graph for this function:

◆ agreeTypes()

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

Definition at line 334 of file ConductorTest.php.

334  : array
335  {
336  return [
337  'Form type' => [ilLegalDocumentsAgreementGUI::class, 'agreement-form'],
338  'Public type' => ['foo', 'public-page'],
339  ];
340  }

◆ testAfterLogin()

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

Definition at line 258 of file ConductorTest.php.

258  : void
259  {
260  $called = [false, false];
261 
262  $internal = $this->mockMethod(Internal::class, 'all', ['after-login'], [
263  function () use (&$called): void {
264  $called[0] = true;
265  },
266  function () use (&$called): void {
267  $called[1] = true;
268  }
269  ]);
270 
271  $instance = new Conductor($this->mock(Container::class), $internal, $this->mock(Routing::class));
272 
273  $instance->afterLogin();
274 
275  $this->assertSame([true, true], $called);
276  }

◆ testAgree()

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

agreeTypes

Definition at line 163 of file ConductorTest.php.

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

163  : void
164  {
165  $main_template = $this->mock(ilGlobalTemplateInterface::class);
166  $main_template->expects(self::once())->method('setContent')->with('rendered');
167  $this->agreement('agree', $gui, $key, $main_template);
168  }
agreement(string $method, string $gui, string $key, ?ilGlobalTemplateInterface $main_template=null)
string $key
Consumer key/client ID value.
Definition: System.php:193
+ Here is the call graph for this function:

◆ testAgreeContent()

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

agreeTypes

Definition at line 173 of file ConductorTest.php.

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

173  : void
174  {
175  $this->assertSame('rendered', $this->agreement('agreeContent', $gui, $key));
176  }
agreement(string $method, string $gui, string $key, ?ilGlobalTemplateInterface $main_template=null)
string $key
Consumer key/client ID value.
Definition: System.php:193
+ Here is the call graph for this function:

◆ testCanUseSoapApi()

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

Definition at line 241 of file ConductorTest.php.

References $container.

241  : void
242  {
243  $constraints = [
244  'foo' => $this->mock(Constraint::class),
245  'bar' => $this->mock(Constraint::class),
246  ];
247 
248  $container = $this->mockTree(Container::class, [
249  'refinery' => ['in' => $this->mockMethod(InGroup::class, 'series', [array_values($constraints)], $this->mock(Transformation::class))]
250  ]);
251 
252  $internal = $this->mockMethod(Internal::class, 'all', ['use-soap-api'], $constraints);
253 
254  $instance = new Conductor($container, $internal, $this->mock(Routing::class));
255  $this->assertInstanceOf(Transformation::class, $instance->canUseSoapApi());
256  }
$container
Definition: wac.php:14

◆ testConstruct()

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

Definition at line 61 of file ConductorTest.php.

61  : void
62  {
63  $this->assertInstanceOf(Conductor::class, new Conductor($this->mock(Container::class), $this->mock(Internal::class), $this->mock(Routing::class)));
64  }

◆ testFindGotoLink()

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

Definition at line 278 of file ConductorTest.php.

References Vendor\Package\$foo.

278  : void
279  {
280  $foo = $this->mock(Target::class);
281  $internal = $this->mockMethod(Internal::class, 'all', ['goto'], [
282  $this->mockTree(GotoLink::class, ['name' => 'bar']),
283  $this->mockTree(GotoLink::class, ['name' => 'foo', 'target' => $foo]),
284  ]);
285 
286  $instance = new Conductor($this->mock(Container::class), $internal, $this->mock(Routing::class));
287 
288  $target = $instance->findGotoLink('foo');
289  $this->assertTrue($target->isOk());
290  $this->assertSame($foo, $target->value());
291  }

◆ testIntercepting()

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

Definition at line 294 of file ConductorTest.php.

294  : void
295  {
296  $intercepting = [
297  'foo' => $this->mock(Intercept::class),
298  'bar' => $this->mock(Intercept::class)
299  ];
300 
301  $internal = $this->mockMethod(Internal::class, 'all', ['intercept'], $intercepting);
302 
303  $instance = new Conductor($this->mock(Container::class), $internal, $this->mock(Routing::class));
304  $this->assertSame($intercepting, $instance->intercepting());
305  }

◆ testLoginPageHTML()

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

Definition at line 96 of file ConductorTest.php.

References $container, and $space.

96  : void
97  {
98  $components = [
99  $this->mock(Component::class),
100  $this->mock(Component::class),
101  ];
102 
103  $space = $this->mock(Legacy::class);
104 
105  $container = $this->mockTree(Container::class, [
106  'ui' => [
107  'renderer' => $this->mockMethod(Renderer::class, 'render', [
108  $components,
109  ], 'rendered'),
110  ],
111  ]);
112 
113  $internal = $this->mockMethod(Internal::class, 'get', ['show-on-login-page', 'foo'], fn() => $components);
114 
115  $instance = new Conductor($container, $internal, $this->mock(Routing::class));
116 
117  $this->assertSame('rendered', $instance->loginPageHTML('foo'));
118  }
$space
Definition: Sanitizer.php:43
$container
Definition: wac.php:14

◆ testLogoutText()

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

Definition at line 120 of file ConductorTest.php.

References $container.

120  : void
121  {
122  $constraint = $this->mock(Constraint::class);
123  $component = $this->mock(Component::class);
124 
125  $container = $this->mockTree(Container::class, [
126  'refinery' => ['to' => ['string' => $constraint]],
127  'http' => ['wrapper' => ['query' => $this->mockMethod(ArrayBasedRequestWrapper::class, 'retrieve', ['withdraw_from', $constraint], 'foo')]],
128  'ui' => ['renderer' => $this->mockMethod(Renderer::class, 'render', [$component], 'rendered')],
129  ]);
130 
131  $internal = $this->mockMethod(Internal::class, 'get', ['logout-text', 'foo'], static function () use ($component): Component {
132  return $component;
133  });
134 
135  $instance = new Conductor($container, $internal, $this->mock(Routing::class));
136 
137  $this->assertSame('rendered', $instance->logoutText());
138  ;
139  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$container
Definition: wac.php:14

◆ testModifyFooter()

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

Definition at line 141 of file ConductorTest.php.

References $container, and Vendor\Package\$f.

141  : void
142  {
143  $footer = $this->mock(Footer::class);
144  $new_footer = $this->mock(Footer::class);
145 
146  $modify_footer = function ($f) {
147  $this->assertInstanceOf(Closure::class, $f);
148  return $f;
149  };
150 
151  $container = $this->mockTree(Container::class, ['ui' => ['factory' => ['mainControls' => ['footer' => $new_footer]]]]);
152  $instance = new Conductor($container, $this->mockMethod(Internal::class, 'all', ['footer'], [
153  $modify_footer,
154  $modify_footer,
155  ]), $this->mock(Routing::class));
156 
157  $this->assertSame($new_footer, $instance->modifyFooter($footer));
158  }
$container
Definition: wac.php:14

◆ testOnLogout()

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

Definition at line 72 of file ConductorTest.php.

References $container.

72  : void
73  {
74  $constraint = $this->mock(Constraint::class);
75  $called = false;
76 
77  $ctrl = $this->mock(ilCtrl::class);
78  $ctrl->expects(self::once())->method('setParameterByClass')->with('dummy gui', 'withdraw_from', 'foo');
79 
80  $container = $this->mockTree(Container::class, [
81  'refinery' => ['to' => ['string' => $constraint]],
82  'http' => ['wrapper' => ['query' => $this->mockMethod(ArrayBasedRequestWrapper::class, 'retrieve', ['withdraw_consent', $constraint], 'foo')]],
83  'ctrl' => $ctrl,
84  ]);
85 
86  $internal = $this->mockMethod(Internal::class, 'get', ['logout', 'foo'], static function () use (&$called): void {
87  $called = true;
88  });
89 
90  $instance = new Conductor($container, $internal, $this->mock(Routing::class));
91 
92  $instance->onLogout('dummy gui');
93  $this->assertTrue($called);
94  }
$container
Definition: wac.php:14

◆ testProvide()

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

Definition at line 66 of file ConductorTest.php.

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

◆ testRedirectAgreeContent()

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

Definition at line 178 of file ConductorTest.php.

References $container.

178  : void
179  {
180  $this->expectExceptionMessage('Not available.');
181  $routing = $this->mock(Routing::class);
182  $routing->expects(self::once())->method('redirectToOriginalTarget');
183  $constraint = $this->mock(Constraint::class);
184  $container = $this->mockTree(Container::class, [
185  'refinery' => ['to' => ['string' => $constraint]],
186  'http' => ['wrapper' => ['query' => $this->mockMethod(ArrayBasedRequestWrapper::class, 'retrieve', ['id', $constraint], 'foo')]],
187  ]);
188  $internal = $this->mock(Internal::class);
189  $internal = $this->mockMethod(Internal::class, 'get', ['agreement-form', 'foo'], function (string $g, string $cmd): Result {
190  return new Error('Not available.');
191  });
192  $instance = new Conductor($container, $internal, $routing);
193  $instance->agreeContent(ilLegalDocumentsAgreementGUI::class, 'foo');
194  }
$container
Definition: wac.php:14

◆ testSelfRegistration()

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

Definition at line 307 of file ConductorTest.php.

307  : void
308  {
309  $internal = $this->mockMethod(Internal::class, 'all', ['self-registration'], [
310  $this->mock(SelfRegistration::class),
311  ]);
312 
313  $instance = new Conductor($this->mock(Container::class), $internal, $this->mock(Routing::class));
314 
315  $this->assertInstanceOf(Bundle::class, $instance->selfRegistration());
316  }

◆ testUserCanReadInternalMail()

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

Definition at line 217 of file ConductorTest.php.

References $container.

217  : void
218  {
219  $constraints = [
220  'foo' => $this->mock(Constraint::class),
221  'bar' => $this->mock(Constraint::class),
222  ];
223 
224  $series = $this->mock(Transformation::class);
225 
226  $container = $this->mockTree(Container::class, [
227  'refinery' => ['in' => $this->mockMethod(
228  InGroup::class,
229  'series',
230  [array_values($constraints)],
231  $series
232  )],
233  ]);
234 
235  $internal = $this->mockMethod(Internal::class, 'all', ['constrain-internal-mail'], $constraints);
236 
237  $instance = new Conductor($container, $internal, $this->mock(Routing::class));
238  $this->assertSame($series, $instance->userCanReadInternalMail());
239  }
$container
Definition: wac.php:14

◆ testUserManagementFields()

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

Definition at line 318 of file ConductorTest.php.

318  : void
319  {
320  $internal = $this->mockMethod(Internal::class, 'all', ['user-management-fields'], [
321  fn() => ['foo' => 'bar', 'baz' => 'hej'],
322  fn() => ['hoo' => 'har'],
323  ]);
324 
325  $instance = new Conductor($this->mock(Container::class), $internal, $this->mock(Routing::class));
326 
327  $this->assertSame([
328  'foo' => 'bar',
329  'baz' => 'hej',
330  'hoo' => 'har',
331  ], $instance->userManagementFields($this->mock(ilObjUser::class)));
332  }

◆ testUsersWithHiddenOnlineStatus()

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

Definition at line 203 of file ConductorTest.php.

203  : void
204  {
205  $internal = $this->mockMethod(Internal::class, 'all', ['filter-online-users'], [
206  fn() => [4, 5, 6],
207  fn() => [5, 6],
208  ]);
209  $instance = new Conductor($this->mock(Container::class), $internal, $this->mock(Routing::class));
210 
211  $this->assertSame(
212  [1, 2, 3, 4, 7, 8, 9],
213  $instance->usersWithHiddenOnlineStatus([1, 2, 3, 4, 5, 6, 7, 8, 9])
214  );
215  }

◆ testWithdraw()

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

Definition at line 196 of file ConductorTest.php.

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

196  : void
197  {
198  $main_template = $this->mock(ilGlobalTemplateInterface::class);
199  $main_template->expects(self::once())->method('setContent')->with('rendered');
200  $this->agreement('withdraw', 'foo', 'withdraw', $main_template);
201  }
agreement(string $method, string $gui, string $key, ?ilGlobalTemplateInterface $main_template=null)
+ Here is the call graph for this function:

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