ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ConsumerTest.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
23use ilCtrl;
27use ilSetting;
29use ILIAS\LegalDocuments\test\ContainerMock;
32use PHPUnit\Framework\TestCase;
33
34require_once __DIR__ . '/bootstrap.php';
35
36class ConsumerTest extends TestCase
37{
38 use ContainerMock;
39
40 public function testConstruct(): void
41 {
42 $this->assertInstanceOf(Consumer::class, new Consumer($this->mock(Container::class)));
43 }
44
45 public function testId(): void
46 {
47 $this->assertSame(Consumer::ID, (new Consumer($this->mock(Container::class)))->id());
48 }
49
50 public function testDisabledUses(): void
51 {
52 $by_trying = $this->mockTree(ByTrying::class, ['transform' => false]);
53 $settings = $this->mockMethod(ilSetting::class, 'get', ['tos_status', ''], 'false');
54
55 $container = $this->mockTree(Container::class, [
56 'settings' => $settings,
57 'refinery' => ['byTrying' => $by_trying],
58 ]);
59 $container->method('offsetGet')->with('ilObjDataCache')->willReturn($this->mock(ilObjectDataCache::class));
60
61 $slot = $this->mock(UseSlot::class);
62 $slot->expects(self::once())->method('hasDocuments')->willReturn($slot);
63 $slot->expects(self::once())->method('hasHistory')->willReturn($slot);
64 $slot->expects(self::once())->method('hasPublicApi')->willReturn($slot);
65 $slot->expects(self::once())->method('hasPublicPage')->willReturn($slot);
66
67 $instance = new Consumer($container);
68
69 $this->assertSame($slot, $instance->uses($slot, $this->mock(LazyProvide::class)));
70 }
71
72 public function testUses(): void
73 {
74 $by_trying = $this->mockTree(ByTrying::class, ['transform' => true]);
75 $settings = $this->mockMethod(ilSetting::class, 'get', ['tos_status', ''], 'true');
76
77 $container = $this->mockTree(Container::class, [
78 'settings' => $settings,
79 'refinery' => ['byTrying' => $by_trying],
80 'ctrl' => $this->mock(ilCtrl::class),
81 ]);
82 $container->method('offsetGet')->with('ilObjDataCache')->willReturn($this->mock(ilObjectDataCache::class));
83
84 $slot = $this->mock(UseSlot::class);
85 $slot->expects(self::once())->method('hasDocuments')->willReturn($slot);
86 $slot->expects(self::once())->method('hasHistory')->willReturn($slot);
87 $slot->expects(self::once())->method('canWithdraw')->willReturn($slot);
88 $slot->expects(self::once())->method('hasAgreement')->willReturn($slot);
89 $slot->expects(self::once())->method('showInFooter')->willReturn($slot);
90 $slot->expects(self::once())->method('showOnLoginPage')->willReturn($slot);
91 $slot->expects(self::once())->method('onSelfRegistration')->willReturn($slot);
92 $slot->expects(self::once())->method('hasOnlineStatusFilter')->willReturn($slot);
93 $slot->expects(self::once())->method('hasUserManagementFields')->willReturn($slot);
94 $slot->expects(self::once())->method('hasPublicApi')->willReturn($slot);
95 $slot->expects(self::once())->method('canReadInternalMails')->willReturn($slot);
96 $slot->expects(self::once())->method('canUseSoapApi')->willReturn($slot);
97
98 $instance = new Consumer($container);
99
100 $this->assertSame($slot, $instance->uses($slot, $this->mock(LazyProvide::class)));
101 }
102}
Customizing of pimple-DIC for ILIAS.
Definition: Container.php:36
Class ilCtrl provides processing control methods.
class ilObjectDataCache
ILIAS Setting Class.
$container
@noRector
Definition: wac.php:37