19 declare(strict_types=1);
52 require_once __DIR__ .
'/ContainerMock.php';
60 $this->assertInstanceOf(Conductor::class,
new Conductor($this->mock(Container::class), $this->mock(Internal::class), $this->mock(Routing::class)));
65 $instance =
new Conductor($this->mock(Container::class), $this->mock(Internal::class), $this->mock(Routing::class));
66 $this->assertInstanceOf(Provide::class, $instance->provide(
'foo'));
72 $this->mock(Component::class),
73 $this->mock(Component::class),
76 $space = $this->mock(Content::class);
78 $container = $this->mockTree(Container::class, [
80 'renderer' => $this->mockMethod(Renderer::class,
'render', [
86 $internal = $this->mockMethod(Internal::class,
'get', [
'show-on-login-page',
'foo'], fn() =>
$components);
90 $this->assertSame(
'rendered', $instance->loginPageHTML(
'foo'));
95 $constraint = $this->mock(Constraint::class);
96 $component = $this->mock(Component::class);
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')],
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 {
118 $logoutText = $instance->logoutText();
120 $this->assertSame(
'rendered', $logoutText);
125 $footer = fn() =>
null;
127 $modify_footer =
function (
Closure $f) use ($footer) {
128 $this->assertSame($footer,
$f);
132 $instance =
new Conductor($this->mock(Container::class), $this->mockMethod(Internal::class,
'all', [
'footer'], [
135 ]), $this->mock(Routing::class));
137 $this->assertSame($footer, $instance->modifyFooter($footer));
140 #[DataProvider('agreeTypes')] 141 public function testAgree(
string $gui,
string $key): void
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);
148 #[DataProvider('agreeTypes')] 151 $this->assertSame(
'rendered', $this->
agreement(
'agreeContent', $gui, $key));
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')]],
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.');
169 $instance->agreeContent(ilLegalDocumentsAgreementGUI::class,
'foo');
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);
181 $internal = $this->mockMethod(Internal::class,
'all', [
'filter-online-users'], [
185 $instance =
new Conductor($this->mock(Container::class), $internal, $this->mock(Routing::class));
188 [1, 2, 3, 4, 7, 8, 9],
189 $instance->usersWithHiddenOnlineStatus([1, 2, 3, 4, 5, 6, 7, 8, 9])
196 'foo' => $this->mock(Constraint::class),
197 'bar' => $this->mock(Constraint::class),
200 $series = $this->mock(Transformation::class);
202 $container = $this->mockTree(Container::class, [
203 'refinery' => [
'in' => $this->mockMethod(
206 [array_values($constraints)],
211 $internal = $this->mockMethod(Internal::class,
'all', [
'constrain-internal-mail'], $constraints);
214 $this->assertSame($series, $instance->userCanReadInternalMail());
220 'foo' => $this->mock(Constraint::class),
221 'bar' => $this->mock(Constraint::class),
224 $container = $this->mockTree(Container::class, [
225 'refinery' => [
'in' => $this->mockMethod(InGroup::class,
'series', [array_values($constraints)], $this->mock(Transformation::class))]
228 $internal = $this->mockMethod(Internal::class,
'all', [
'use-soap-api'], $constraints);
231 $this->assertInstanceOf(Transformation::class, $instance->canUseSoapApi());
236 $called = [
false,
false];
238 $internal = $this->mockMethod(Internal::class,
'all', [
'after-login'], [
239 function () use (&$called):
void {
242 function () use (&$called):
void {
247 $instance =
new Conductor($this->mock(Container::class), $internal, $this->mock(Routing::class));
249 $instance->afterLogin();
251 $this->assertSame([
true,
true], $called);
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]),
262 $instance =
new Conductor($this->mock(Container::class), $internal, $this->mock(Routing::class));
264 $target = $instance->findGotoLink(
'foo');
265 $this->assertTrue($target->isOk());
266 $this->assertSame(
$foo, $target->value());
273 'foo' => $this->mock(Intercept::class),
274 'bar' => $this->mock(Intercept::class)
277 $internal = $this->mockMethod(Internal::class,
'all', [
'intercept'], $intercepting);
279 $instance =
new Conductor($this->mock(Container::class), $internal, $this->mock(Routing::class));
280 $this->assertSame($intercepting, $instance->intercepting());
285 $internal = $this->mockMethod(Internal::class,
'all', [
'self-registration'], [
286 $this->mock(SelfRegistration::class),
289 $instance =
new Conductor($this->mock(Container::class), $internal, $this->mock(Routing::class));
291 $this->assertInstanceOf(Bundle::class, $instance->selfRegistration());
296 $internal = $this->mockMethod(Internal::class,
'all', [
'user-management-fields'], [
297 fn() => [
'foo' =>
'bar',
'baz' =>
'hej'],
298 fn() => [
'hoo' =>
'har'],
301 $instance =
new Conductor($this->mock(Container::class), $internal, $this->mock(Routing::class));
307 ], $instance->userManagementFields($this->mock(ilObjUser::class)));
313 'Form type' => [ilLegalDocumentsAgreementGUI::class,
'agreement-form'],
314 'Public type' => [
'foo',
'public-page'],
320 $constraint = $this->mock(Constraint::class);
322 $ctrl = $this->mock(ilCtrl::class);
323 $ctrl->expects(self::once())->method(
'setParameterByClass')->with($gui,
'id',
'foo');
325 $container = $this->mockTree(Container::class, [
326 'refinery' => [
'to' => [
'string' => $constraint]],
327 'http' => [
'wrapper' => [
'query' => $this->mockMethod(ArrayBasedRequestWrapper::class,
'retrieve', [
'id', $constraint],
'foo')]],
329 'mainTemplate' => $main_template ?? $this->mock(ilGlobalTemplateInterface::class),
330 'renderer' => $this->mock(Renderer::class),
335 $fragment = $this->mockMethod(PageFragment::class,
'render', [
$container->ui()->mainTemplate(),
$container->ui()->renderer()],
'rendered');
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);
345 return $instance->$method($gui,
'some cmd');
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
agreement(string $method, string $gui, string $key, ?ilGlobalTemplateInterface $main_template=null)
A result encapsulates a value or an error and simplifies the handling of those.
testAgree(string $gui, string $key)
testUserManagementFields()
testRedirectAgreeContent()
testUsersWithHiddenOnlineStatus()
testUserCanReadInternalMail()
testAgreeContent(string $gui, string $key)