19 declare(strict_types=1);
55 require_once __DIR__ .
'/ContainerMock.php';
63 $this->assertInstanceOf(Conductor::class,
new Conductor($this->mock(Container::class), $this->mock(Internal::class), $this->mock(Routing::class)));
68 $instance =
new Conductor($this->mock(Container::class), $this->mock(Internal::class), $this->mock(Routing::class));
69 $this->assertInstanceOf(Provide::class, $instance->provide(
'foo'));
74 $constraint = $this->mock(Constraint::class);
77 $ctrl = $this->mock(ilCtrl::class);
78 $ctrl->expects(self::once())->method(
'setParameterByClass')->with(
'dummy gui',
'withdraw_from',
'foo');
80 $container = $this->mockTree(Container::class, [
81 'refinery' => [
'to' => [
'string' => $constraint]],
82 'http' => [
'wrapper' => [
'query' => $this->mockMethod(ArrayBasedRequestWrapper::class,
'retrieve', [
'withdraw_consent', $constraint],
'foo')]],
86 $internal = $this->mockMethod(Internal::class,
'get', [
'logout',
'foo'],
static function () use (&$called):
void {
92 $instance->onLogout(
'dummy gui');
93 $this->assertTrue($called);
99 $this->mock(Component::class),
100 $this->mock(Component::class),
103 $space = $this->mock(Legacy::class);
105 $container = $this->mockTree(Container::class, [
107 'renderer' => $this->mockMethod(Renderer::class,
'render', [
113 $internal = $this->mockMethod(Internal::class,
'get', [
'show-on-login-page',
'foo'], fn() => $components);
117 $this->assertSame(
'rendered', $instance->loginPageHTML(
'foo'));
122 $constraint = $this->mock(Constraint::class);
123 $component = $this->mock(Component::class);
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')],
131 $internal = $this->mockMethod(Internal::class,
'get', [
'logout-text',
'foo'],
static function () use ($component):
Component {
137 $this->assertSame(
'rendered', $instance->logoutText());
143 $footer = $this->mock(Footer::class);
144 $new_footer = $this->mock(Footer::class);
146 $modify_footer =
function (
$f) {
147 $this->assertInstanceOf(Closure::class,
$f);
151 $container = $this->mockTree(Container::class, [
'ui' => [
'factory' => [
'mainControls' => [
'footer' => $new_footer]]]]);
152 $instance =
new Conductor(
$container, $this->mockMethod(Internal::class,
'all', [
'footer'], [
155 ]), $this->mock(Routing::class));
157 $this->assertSame($new_footer, $instance->modifyFooter($footer));
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);
175 $this->assertSame(
'rendered', $this->
agreement(
'agreeContent', $gui, $key));
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')]],
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.');
193 $instance->agreeContent(ilLegalDocumentsAgreementGUI::class,
'foo');
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);
205 $internal = $this->mockMethod(Internal::class,
'all', [
'filter-online-users'], [
209 $instance =
new Conductor($this->mock(Container::class), $internal, $this->mock(Routing::class));
212 [1, 2, 3, 4, 7, 8, 9],
213 $instance->usersWithHiddenOnlineStatus([1, 2, 3, 4, 5, 6, 7, 8, 9])
220 'foo' => $this->mock(Constraint::class),
221 'bar' => $this->mock(Constraint::class),
224 $series = $this->mock(Transformation::class);
226 $container = $this->mockTree(Container::class, [
227 'refinery' => [
'in' => $this->mockMethod(
230 [array_values($constraints)],
235 $internal = $this->mockMethod(Internal::class,
'all', [
'constrain-internal-mail'], $constraints);
238 $this->assertSame($series, $instance->userCanReadInternalMail());
244 'foo' => $this->mock(Constraint::class),
245 'bar' => $this->mock(Constraint::class),
248 $container = $this->mockTree(Container::class, [
249 'refinery' => [
'in' => $this->mockMethod(InGroup::class,
'series', [array_values($constraints)], $this->mock(Transformation::class))]
252 $internal = $this->mockMethod(Internal::class,
'all', [
'use-soap-api'], $constraints);
255 $this->assertInstanceOf(Transformation::class, $instance->canUseSoapApi());
260 $called = [
false,
false];
262 $internal = $this->mockMethod(Internal::class,
'all', [
'after-login'], [
263 function () use (&$called):
void {
266 function () use (&$called):
void {
271 $instance =
new Conductor($this->mock(Container::class), $internal, $this->mock(Routing::class));
273 $instance->afterLogin();
275 $this->assertSame([
true,
true], $called);
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]),
286 $instance =
new Conductor($this->mock(Container::class), $internal, $this->mock(Routing::class));
288 $target = $instance->findGotoLink(
'foo');
289 $this->assertTrue($target->isOk());
290 $this->assertSame(
$foo, $target->value());
297 'foo' => $this->mock(Intercept::class),
298 'bar' => $this->mock(Intercept::class)
301 $internal = $this->mockMethod(Internal::class,
'all', [
'intercept'], $intercepting);
303 $instance =
new Conductor($this->mock(Container::class), $internal, $this->mock(Routing::class));
304 $this->assertSame($intercepting, $instance->intercepting());
309 $internal = $this->mockMethod(Internal::class,
'all', [
'self-registration'], [
310 $this->mock(SelfRegistration::class),
313 $instance =
new Conductor($this->mock(Container::class), $internal, $this->mock(Routing::class));
315 $this->assertInstanceOf(Bundle::class, $instance->selfRegistration());
320 $internal = $this->mockMethod(Internal::class,
'all', [
'user-management-fields'], [
321 fn() => [
'foo' =>
'bar',
'baz' =>
'hej'],
322 fn() => [
'hoo' =>
'har'],
325 $instance =
new Conductor($this->mock(Container::class), $internal, $this->mock(Routing::class));
331 ], $instance->userManagementFields($this->mock(ilObjUser::class)));
337 'Form type' => [ilLegalDocumentsAgreementGUI::class,
'agreement-form'],
338 'Public type' => [
'foo',
'public-page'],
344 $constraint = $this->mock(Constraint::class);
346 $ctrl = $this->mock(ilCtrl::class);
347 $ctrl->expects(self::once())->method(
'setParameterByClass')->with($gui,
'id',
'foo');
349 $container = $this->mockTree(Container::class, [
350 'refinery' => [
'to' => [
'string' => $constraint]],
351 'http' => [
'wrapper' => [
'query' => $this->mockMethod(ArrayBasedRequestWrapper::class,
'retrieve', [
'id', $constraint],
'foo')]],
353 'mainTemplate' => $main_template ?? $this->mock(ilGlobalTemplateInterface::class),
354 'renderer' => $this->mock(Renderer::class),
359 $fragment = $this->mockMethod(PageFragment::class,
'render', [
$container->ui()->mainTemplate(),
$container->ui()->renderer()],
'rendered');
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);
369 return $instance->$method($gui,
'some cmd');
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
A result encapsulates a value or an error and simplifies the handling of those.
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)
agreeTypes
testUserManagementFields()
testRedirectAgreeContent()
testUsersWithHiddenOnlineStatus()
testUserCanReadInternalMail()
testAgreeContent(string $gui, string $key)
agreeTypes