ILIAS  trunk Revision v11.0_alpha-1769-g99a433fe2dc
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
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)
 agreeTypes More...
 
 testAgreeContent (string $gui, string $key)
 agreeTypes More...
 
 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 55 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 323 of file ConductorTest.php.

References $container.

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

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

◆ agreeTypes()

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

Definition at line 315 of file ConductorTest.php.

315  : array
316  {
317  return [
318  'Form type' => [ilLegalDocumentsAgreementGUI::class, 'agreement-form'],
319  'Public type' => ['foo', 'public-page'],
320  ];
321  }

◆ testAfterLogin()

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

Definition at line 239 of file ConductorTest.php.

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

◆ testAgree()

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

agreeTypes

Definition at line 144 of file ConductorTest.php.

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

144  : void
145  {
146  $main_template = $this->mock(ilGlobalTemplateInterface::class);
147  $main_template->expects(self::once())->method('setContent')->with('rendered');
148  $this->agreement('agree', $gui, $key, $main_template);
149  }
agreement(string $method, string $gui, string $key, ?ilGlobalTemplateInterface $main_template=null)
+ Here is the call graph for this function:

◆ testAgreeContent()

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

agreeTypes

Definition at line 154 of file ConductorTest.php.

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

154  : void
155  {
156  $this->assertSame('rendered', $this->agreement('agreeContent', $gui, $key));
157  }
agreement(string $method, string $gui, string $key, ?ilGlobalTemplateInterface $main_template=null)
+ Here is the call graph for this function:

◆ testCanUseSoapApi()

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

Definition at line 222 of file ConductorTest.php.

References $container.

222  : void
223  {
224  $constraints = [
225  'foo' => $this->mock(Constraint::class),
226  'bar' => $this->mock(Constraint::class),
227  ];
228 
229  $container = $this->mockTree(Container::class, [
230  'refinery' => ['in' => $this->mockMethod(InGroup::class, 'series', [array_values($constraints)], $this->mock(Transformation::class))]
231  ]);
232 
233  $internal = $this->mockMethod(Internal::class, 'all', ['use-soap-api'], $constraints);
234 
235  $instance = new Conductor($container, $internal, $this->mock(Routing::class));
236  $this->assertInstanceOf(Transformation::class, $instance->canUseSoapApi());
237  }
$container
Definition: wac.php:36

◆ testConstruct()

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

Definition at line 59 of file ConductorTest.php.

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

◆ testFindGotoLink()

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

Definition at line 259 of file ConductorTest.php.

References Vendor\Package\$foo.

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

◆ testIntercepting()

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

Definition at line 275 of file ConductorTest.php.

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

◆ testLoginPageHTML()

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

Definition at line 70 of file ConductorTest.php.

References $components, $container, and $space.

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

◆ testLogoutText()

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

Definition at line 94 of file ConductorTest.php.

References $container, and null.

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

◆ testModifyFooter()

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

Definition at line 124 of file ConductorTest.php.

References Vendor\Package\$f, and null.

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

◆ testProvide()

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

Definition at line 64 of file ConductorTest.php.

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

◆ testRedirectAgreeContent()

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

Definition at line 159 of file ConductorTest.php.

References $container.

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

◆ testSelfRegistration()

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

Definition at line 288 of file ConductorTest.php.

288  : void
289  {
290  $internal = $this->mockMethod(Internal::class, 'all', ['self-registration'], [
291  $this->mock(SelfRegistration::class),
292  ]);
293 
294  $instance = new Conductor($this->mock(Container::class), $internal, $this->mock(Routing::class));
295 
296  $this->assertInstanceOf(Bundle::class, $instance->selfRegistration());
297  }

◆ testUserCanReadInternalMail()

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

Definition at line 198 of file ConductorTest.php.

References $container.

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

◆ testUserManagementFields()

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

Definition at line 299 of file ConductorTest.php.

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

◆ testUsersWithHiddenOnlineStatus()

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

Definition at line 184 of file ConductorTest.php.

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

◆ testWithdraw()

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

Definition at line 177 of file ConductorTest.php.

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

177  : void
178  {
179  $main_template = $this->mock(ilGlobalTemplateInterface::class);
180  $main_template->expects(self::once())->method('setContent')->with('rendered');
181  $this->agreement('withdraw', 'foo', 'withdraw', $main_template);
182  }
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: