19 declare(strict_types=1);
36 require_once __DIR__ .
'/ContainerMock.php';
44 $this->assertInstanceOf(Wiring::class,
new Wiring($this->mock(SlotConstructor::class), $this->mock(Map::class)));
49 $map = $this->mock(Map::class);
50 $proc = $this->fail(...);
52 $instance =
new Wiring($this->mock(SlotConstructor::class), $this->mockMethod(Map::class,
'add', [
'after-login', $proc], $map));
53 $this->assertSame($map, $instance->afterLogin($proc)->map());
58 $map = $this->mock(Map::class);
59 $proc = $this->fail(...);
61 $instance =
new Wiring($this->mockTree(SlotConstructor::class, [
'id' =>
'foo']), $this->mockMethod(Map::class,
'set', [
'footer',
'foo', $proc], $map));
62 $this->assertSame($map, $instance->showInFooter($proc)->map());
67 $withdraw_process = $this->mock(WithdrawProcess::class);
69 $instance =
new Wiring($this->mock(SlotConstructor::class),
new Map());
71 $map = $instance->canWithdraw($withdraw_process)->map()->value();
80 $this->assertTrue(array_is_list($map[
'intercept']));
81 $this->assertTrue(array_is_list($map[
'show-on-login-page']));
82 $this->assertFalse(array_is_list($map[
'withdraw']));
83 $this->assertFalse(array_is_list($map[
'logout-text']));
88 $proc = $this->fail(...);
89 $instance =
new Wiring($this->mockTree(SlotConstructor::class, [
'id' =>
'foo']),
new Map());
90 $this->assertSame([
'show-on-login-page' => [
'foo' => $proc]], $instance->showOnLoginPage($proc)->map()->value());
95 $instance =
new Wiring($this->mock(SlotConstructor::class),
new Map());
96 $map = $instance->hasAgreement($this->mock(Agreement::class),
'bar')->map()->value();
103 ], array_keys($map));
105 $this->assertFalse(array_is_list($map[
'public-page']));
106 $this->assertFalse(array_is_list($map[
'agreement-form']));
107 $this->assertTrue(array_is_list($map[
'intercept']));
108 $this->assertTrue(array_is_list($map[
'goto']));
113 $document = $this->mock(ProvideDocument::class);
114 $history = $this->mock(ProvideHistory::class);
115 $slot = $this->mockMethod(SlotConstructor::class,
'history', [$document], $history);
116 $slot->method(
'id')->willReturn(
'foo');
117 $map = $this->mockTree(Map::class, [
'value' => [
'document' => [
'foo' => $document]]]);
118 $map->expects(self::once())->method(
'set')->with(
'history',
'foo', $history)->willReturn($map);
120 $instance =
new Wiring($slot, $map);
121 $this->assertSame($map, $instance->hasHistory()->map());
126 $map = $this->mock(Map::class);
127 $self_registration = $this->mock(SelfRegistration::class);
129 $instance =
new Wiring($this->mock(SlotConstructor::class), $this->mockMethod(Map::class,
'add', [
'self-registration', $self_registration], $map));
130 $this->assertSame($map, $instance->onSelfRegistration($self_registration)->map());
135 $map = $this->mock(Map::class);
136 $proc = $this->fail(...);
138 $instance =
new Wiring($this->mock(SlotConstructor::class), $this->mockMethod(Map::class,
'add', [
'filter-online-users', $proc], $map));
139 $this->assertSame($map, $instance->hasOnlineStatusFilter($proc)->map());
144 $map = $this->mock(Map::class);
145 $constraint = $this->mock(Constraint::class);
147 $instance =
new Wiring($this->mock(SlotConstructor::class), $this->mockMethod(Map::class,
'add', [
'constrain-internal-mail', $constraint], $map));
148 $this->assertSame($map, $instance->canReadInternalMails($constraint)->map());
153 $map = $this->mock(Map::class);
154 $constraint = $this->mock(Constraint::class);
156 $instance =
new Wiring($this->mock(SlotConstructor::class), $this->mockMethod(Map::class,
'add', [
'use-soap-api', $constraint], $map));
157 $this->assertSame($map, $instance->canUseSoapApi($constraint)->map());
162 $instance =
new Wiring($this->mock(SlotConstructor::class),
new Map());
163 $map = $instance->hasDocuments([],
new SelectionMap())->map()->value();
168 ], array_keys($map));
170 $this->assertFalse(array_is_list($map[
'document']));
171 $this->assertFalse(array_is_list($map[
'writable-document']));
176 $map = $this->mock(Map::class);
177 $proc = $this->fail(...);
180 $this->mockTree(SlotConstructor::class, [
'id' =>
'foo']),
181 $this->mockMethod(Map::class,
'set', [
'user-management-fields',
'foo', $proc], $map)
184 $this->assertSame($map, $instance->hasUserManagementFields($proc)->map());
189 $map = $this->mock(Map::class);
190 $public_api = $this->mock(PublicApi::class);
193 $this->mockTree(SlotConstructor::class, [
'id' =>
'foo']),
194 $this->mockMethod(Map::class,
'set', [
'public-api',
'foo', $public_api], $map)
197 $this->assertSame($map, $instance->hasPublicApi($public_api)->map());
202 $map = $this->mock(Map::class);
203 $public_page = fn() =>
null;
206 $this->mockTree(SlotConstructor::class, [
'id' =>
'foo']),
207 $this->mockMethod(Map::class,
'set', [
'public-page',
'foo', $public_page], $map)
210 $this->assertSame($map, $instance->hasPublicPage($public_page)->map());
215 $m = $this->mock(Map::class);
216 $map = $this->mockMethod(Map::class,
'add', [
'goto'], $m);
217 $public_page = fn() =>
null;
220 $this->mockTree(SlotConstructor::class, [
'id' =>
'foo']),
221 $this->mockMethod(Map::class,
'set', [
'public-page',
'foo', $public_page], $map)
224 $this->assertSame($m, $instance->hasPublicPage($public_page,
'foo')->map());
229 $map = $this->mock(Map::class);
230 $this->assertSame($map, (
new Wiring($this->mock(SlotConstructor::class), $map))->map());
testHasUserManagementFields()
testHasPublicPageWithGotoLink()
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
testCanReadInternalMails()
testHasOnlineStatusFilter()