ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ILIAS\Badge\test\BadgeParentTest Class Reference
+ Inheritance diagram for ILIAS\Badge\test\BadgeParentTest:
+ Collaboration diagram for ILIAS\Badge\test\BadgeParentTest:

Public Member Functions

 testConstruct ()
 
 testShowWithParentReadRight ()
 
 testShowWithoutParentReadRight ()
 

Detailed Description

Definition at line 38 of file BadgeParentTest.php.

Member Function Documentation

◆ testConstruct()

ILIAS\Badge\test\BadgeParentTest::testConstruct ( )

Definition at line 40 of file BadgeParentTest.php.

40 : void
41 {
42 $container = $this->getMockBuilder(Container::class)->disableOriginalConstructor()->getMock();
43 $parent = new BadgeParent($container);
44 $this->assertInstanceOf(BadgeParent::class, $parent);
45 }
$container
@noRector
Definition: wac.php:37

References $container.

◆ testShowWithoutParentReadRight()

ILIAS\Badge\test\BadgeParentTest::testShowWithoutParentReadRight ( )

Definition at line 113 of file BadgeParentTest.php.

113 : void
114 {
115 $rendered = 'Rendered components';
116
117 $access = $this->getMockBuilder(ilAccess::class)->disableOriginalConstructor()->getMock();
118 $badge = $this->getMockBuilder(ilBadge::class)->disableOriginalConstructor()->getMock();
119 $container = $this->getMockBuilder(Container::class)->disableOriginalConstructor()->getMock();
120 $descriptive = $this->getMockBuilder(Descriptive::class)->getMock();
121 $factory = $this->getMockBuilder(UI::class)->disableOriginalConstructor()->getMock();
122 $language = $this->getMockBuilder(ilLanguage::class)->disableOriginalConstructor()->getMock();
123 $legacy = $this->getMockBuilder(Legacy\Content::class)->disableOriginalConstructor()->getMock();
124 $legacy_factory = $this->getMockBuilder(Legacy\Factory::class)->disableOriginalConstructor()->getMock();
125 $listing = $this->getMockBuilder(Listing::class)->disableOriginalConstructor()->getMock();
126 $parent_link = $this->getMockBuilder(Content::class)->disableOriginalConstructor()->getMock();
127 $renderer = $this->getMockBuilder(Renderer::class)->disableOriginalConstructor()->getMock();
128 $ui = $this->getMockBuilder(UIServices::class)->disableOriginalConstructor()->getMock();
129
130 $language->method('txt')->willReturnCallback(static fn(string $name): string => $name . ' translated');
131
132 $listing->expects(self::once())->method('descriptive')->with([
133 'object translated' => $legacy,
134 ])->willReturn($descriptive);
135
136 $factory->method('listing')->willReturn($listing);
137 $legacy_factory->method('content')->willReturn($legacy);
138 $factory->method('legacy')->willReturn($legacy_factory);
139
140 $renderer->expects(self::once())->method('render')->willReturn($rendered);
141
142 $ui->method('factory')->willReturn($factory);
143 $ui->method('renderer')->willReturn($renderer);
144
145 $access->expects(self::once())->method('checkAccess')->with('read', '', 89)->willReturn(false);
146
147 $container->method('ui')->willReturn($ui);
148 $container->method('language')->willReturn($language);
149 $container->method('access')->willReturn($access);
150
151 $parent_id = 6879;
152 $badge->method('getParentId')->willReturn($parent_id);
153 $badge->method('getParentMeta')->willReturn([
154 'id' => $parent_id,
155 'type' => 'crs',
156 'title' => 'Lorem',
157 ]);
158
159 $icon = function (int $id, string $size, string $type): string {
160 $this->assertSame([6879, 'big', 'crs'], [$id, $size, $type]);
161 return 'Some image path.';
162 };
163
164 $references_of = static fn(): array => [89];
165
166 $link_to = function (int $ref_id): string {
167 $this->assertSame(89, $ref_id);
168 return 'Some URL.';
169 };
170
171 $parent = new BadgeParent($container, $icon, $references_of, $link_to);
172 $this->assertSame($descriptive, $parent->asComponent($badge));
173 }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
$renderer
$ref_id
Definition: ltiauth.php:66

References $container, $id, $ref_id, and $renderer.

◆ testShowWithParentReadRight()

ILIAS\Badge\test\BadgeParentTest::testShowWithParentReadRight ( )

Definition at line 47 of file BadgeParentTest.php.

47 : void
48 {
49 $rendered = 'Rendered components';
50
51 $access = $this->getMockBuilder(ilAccess::class)->disableOriginalConstructor()->getMock();
52 $badge = $this->getMockBuilder(ilBadge::class)->disableOriginalConstructor()->getMock();
53 $container = $this->getMockBuilder(Container::class)->disableOriginalConstructor()->getMock();
54 $descriptive = $this->getMockBuilder(Descriptive::class)->getMock();
55 $factory = $this->getMockBuilder(UI::class)->disableOriginalConstructor()->getMock();
56 $language = $this->getMockBuilder(ilLanguage::class)->disableOriginalConstructor()->getMock();
57 $legacy = $this->getMockBuilder(Legacy\Content::class)->disableOriginalConstructor()->getMock();
58 $legacy_factory = $this->getMockBuilder(Legacy\Factory::class)->disableOriginalConstructor()->getMock();
59 $link = $this->getMockBuilder(Link::class)->disableOriginalConstructor()->getMock();
60 $listing = $this->getMockBuilder(Listing::class)->disableOriginalConstructor()->getMock();
61 $renderer = $this->getMockBuilder(Renderer::class)->disableOriginalConstructor()->getMock();
62 $standard_link = $this->getMockBuilder(StandardLink::class)->disableOriginalConstructor()->getMock();
63 $ui = $this->getMockBuilder(UIServices::class)->disableOriginalConstructor()->getMock();
64
65 $language->method('txt')->willReturnCallback(static fn(string $name): string => $name . ' translated');
66
67 $listing->expects(self::once())->method('descriptive')->with([
68 'object translated' => $legacy,
69 ])->willReturn($descriptive);
70
71 $link->method('standard')->with('Lorem', 'Some URL.')->willReturn($standard_link);
72
73 $factory->method('listing')->willReturn($listing);
74 $factory->method('link')->willReturn($link);
75 $legacy_factory->expects(self::once())->method('content')->with($rendered)->willReturn($legacy);
76 $factory->expects(self::once())->method('legacy')->willReturn($legacy_factory);
77
78 $renderer->expects(self::once())->method('render')->willReturn($rendered);
79
80 $ui->method('factory')->willReturn($factory);
81 $ui->method('renderer')->willReturn($renderer);
82
83 $access->expects(self::once())->method('checkAccess')->with('read', '', 89)->willReturn(true);
84
85 $container->method('ui')->willReturn($ui);
86 $container->method('language')->willReturn($language);
87 $container->method('access')->willReturn($access);
88
89 $parent_id = 6879;
90 $badge->method('getParentId')->willReturn($parent_id);
91 $badge->method('getParentMeta')->willReturn([
92 'id' => $parent_id,
93 'type' => 'crs',
94 'title' => 'Lorem',
95 ]);
96
97 $icon = function (int $id, string $size, string $type): string {
98 $this->assertSame([6879, 'big', 'crs'], [$id, $size, $type]);
99 return 'Some image path.';
100 };
101
102 $references_of = static fn(): array => [89];
103
104 $link_to = function (int $ref_id): string {
105 $this->assertSame(89, $ref_id);
106 return 'Some URL.';
107 };
108
109 $parent = new BadgeParent($container, $icon, $references_of, $link_to);
110 $this->assertSame($descriptive, $parent->asComponent($badge));
111 }

References $container, $id, $ref_id, and $renderer.


The documentation for this class was generated from the following file: