ILIAS  trunk Revision v12.0_alpha-377-g3641b37b9db
ILIAS\MetaData\Services\CopyrightHelper\CopyrightTest Class Reference
+ Inheritance diagram for ILIAS\MetaData\Services\CopyrightHelper\CopyrightTest:
+ Collaboration diagram for ILIAS\MetaData\Services\CopyrightHelper\CopyrightTest:

Public Member Functions

 testIsDefaultTrue ()
 
 testIsDefaultFalse ()
 
 testIsOutdatedTrue ()
 
 testIsOutdatedFalse ()
 
 testIdentifier ()
 
 testTitle ()
 
 testDescription ()
 
 testPresentAsUIComponents ()
 
 testPresentAsImageOnly ()
 
 testPresentAsLinkOnly ()
 
 testPresentAsString ()
 

Protected Member Functions

 getIcon ()
 
 getLink ()
 
 getRenderer (?Icon $icon=null, ?Link $link=null)
 
 getIdentifierHandler ()
 
 getEntry (bool $is_default, bool $is_outdated, int $id, string $title, string $description, string $cp_data)
 

Detailed Description

Definition at line 41 of file CopyrightTest.php.

Member Function Documentation

◆ getEntry()

ILIAS\MetaData\Services\CopyrightHelper\CopyrightTest::getEntry ( bool  $is_default,
bool  $is_outdated,
int  $id,
string  $title,
string  $description,
string  $cp_data 
)
protected

Definition at line 112 of file CopyrightTest.php.

119 : EntryInterface {
120 return new class ($is_default, $is_outdated, $id, $title, $description, $cp_data) extends NullEntry {
121 public function __construct(
122 protected bool $is_default,
123 protected bool $is_outdated,
124 protected int $id,
125 protected string $title,
126 protected string $description,
127 protected string $cp_data
128 ) {
129 }
130
131 public function id(): int
132 {
133 return $this->id;
134 }
135
136 public function title(): string
137 {
138 return $this->title;
139 }
140
141 public function description(): string
142 {
143 return $this->description;
144 }
145
146 public function isDefault(): bool
147 {
148 return $this->is_default;
149 }
150
151 public function isOutdated(): bool
152 {
153 return $this->is_outdated;
154 }
155
156 public function copyrightData(): CopyrightDataInterface
157 {
158 return new class ($this->cp_data) extends NullCopyrightData {
159 public function __construct(public string $exposed_data)
160 {
161 }
162 };
163 }
164 };
165 }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
__construct(SettingsInterface $settings, PathFactory $path_factory, CopyrightRepository $copyright_repo, IdentifierHandler $identifier_handler, RendererInterface $renderer, SearchClauseFactory $search_clause_factory)

◆ getIcon()

ILIAS\MetaData\Services\CopyrightHelper\CopyrightTest::getIcon ( )
protected

Definition at line 43 of file CopyrightTest.php.

43 : Icon
44 {
45 return $this->getMockBuilder(IIcon::class)
46 ->disableOriginalConstructor()
47 ->getMock();
48 }

◆ getIdentifierHandler()

ILIAS\MetaData\Services\CopyrightHelper\CopyrightTest::getIdentifierHandler ( )
protected

Definition at line 102 of file CopyrightTest.php.

102 : IdentifierHandler
103 {
104 return new class () extends NullHandler {
105 public function buildIdentifierFromEntryID(int $entry_id): string
106 {
107 return 'identifier_' . $entry_id;
108 }
109 };
110 }

◆ getLink()

ILIAS\MetaData\Services\CopyrightHelper\CopyrightTest::getLink ( )
protected

Definition at line 50 of file CopyrightTest.php.

50 : Link
51 {
52 return $this->getMockBuilder(ILink::class)
53 ->disableOriginalConstructor()
54 ->getMock();
55 }

◆ getRenderer()

ILIAS\MetaData\Services\CopyrightHelper\CopyrightTest::getRenderer ( ?Icon  $icon = null,
?Link  $link = null 
)
protected

Definition at line 57 of file CopyrightTest.php.

60 : RendererInterface {
61 return new class ($icon, $link) extends NullRenderer {
62 public ?string $exposed_copyright_data = null;
63
64 public function __construct(
65 protected ?Icon $icon,
66 protected ?Link $link
67 ) {
68 }
69
70 public function toUIComponents(CopyrightDataInterface $copyright): array
71 {
72 $this->exposed_copyright_data = $copyright->exposed_data;
73 $res = [];
74 if ($this->icon !== null) {
75 $res[] = $this->icon;
76 }
77 if ($this->link !== null) {
78 $res[] = $this->link;
79 }
80 return $res;
81 }
82
83 public function toImageOnly(CopyrightDataInterface $copyright): ?Icon
84 {
85 $this->exposed_copyright_data = $copyright->exposed_data;
86 return $this->icon;
87 }
88
89 public function toLinkOnly(CopyrightDataInterface $copyright): ?Link
90 {
91 $this->exposed_copyright_data = $copyright->exposed_data;
92 return $this->link;
93 }
94
95 public function toString(CopyrightDataInterface $copyright): string
96 {
97 return $copyright->exposed_data;
98 }
99 };
100 }
$res
Definition: ltiservices.php:69
link(string $caption, string $href, bool $new_viewport=false)

◆ testDescription()

ILIAS\MetaData\Services\CopyrightHelper\CopyrightTest::testDescription ( )

Definition at line 275 of file CopyrightTest.php.

275 : void
276 {
277 $copyright = new Copyright(
278 $this->getRenderer(),
279 $this->getIdentifierHandler(),
280 $this->getEntry(
281 false,
282 false,
283 35,
284 'cp title',
285 'cp description',
286 'data of copyright'
287 )
288 );
289
290 $this->assertSame('cp description', $copyright->description());
291 }
getRenderer(?Icon $icon=null, ?Link $link=null)
getEntry(bool $is_default, bool $is_outdated, int $id, string $title, string $description, string $cp_data)

◆ testIdentifier()

ILIAS\MetaData\Services\CopyrightHelper\CopyrightTest::testIdentifier ( )

Definition at line 239 of file CopyrightTest.php.

239 : void
240 {
241 $copyright = new Copyright(
242 $this->getRenderer(),
243 $this->getIdentifierHandler(),
244 $this->getEntry(
245 false,
246 false,
247 35,
248 'cp title',
249 'cp description',
250 'data of copyright'
251 )
252 );
253
254 $this->assertSame('identifier_35', $copyright->identifier());
255 }

◆ testIsDefaultFalse()

ILIAS\MetaData\Services\CopyrightHelper\CopyrightTest::testIsDefaultFalse ( )

Definition at line 185 of file CopyrightTest.php.

185 : void
186 {
187 $copyright = new Copyright(
188 $this->getRenderer(),
189 $this->getIdentifierHandler(),
190 $this->getEntry(
191 false,
192 false,
193 35,
194 'cp title',
195 'cp description',
196 'data of copyright'
197 )
198 );
199
200 $this->assertFalse($copyright->isDefault());
201 }

◆ testIsDefaultTrue()

ILIAS\MetaData\Services\CopyrightHelper\CopyrightTest::testIsDefaultTrue ( )

Definition at line 167 of file CopyrightTest.php.

167 : void
168 {
169 $copyright = new Copyright(
170 $this->getRenderer(),
171 $this->getIdentifierHandler(),
172 $this->getEntry(
173 true,
174 false,
175 35,
176 'cp title',
177 'cp description',
178 'data of copyright'
179 )
180 );
181
182 $this->assertTrue($copyright->isDefault());
183 }

◆ testIsOutdatedFalse()

ILIAS\MetaData\Services\CopyrightHelper\CopyrightTest::testIsOutdatedFalse ( )

Definition at line 221 of file CopyrightTest.php.

221 : void
222 {
223 $copyright = new Copyright(
224 $this->getRenderer(),
225 $this->getIdentifierHandler(),
226 $this->getEntry(
227 false,
228 false,
229 35,
230 'cp title',
231 'cp description',
232 'data of copyright'
233 )
234 );
235
236 $this->assertFalse($copyright->isOutdated());
237 }

◆ testIsOutdatedTrue()

ILIAS\MetaData\Services\CopyrightHelper\CopyrightTest::testIsOutdatedTrue ( )

Definition at line 203 of file CopyrightTest.php.

203 : void
204 {
205 $copyright = new Copyright(
206 $this->getRenderer(),
207 $this->getIdentifierHandler(),
208 $this->getEntry(
209 false,
210 true,
211 35,
212 'cp title',
213 'cp description',
214 'data of copyright'
215 )
216 );
217
218 $this->assertTrue($copyright->isOutdated());
219 }

◆ testPresentAsImageOnly()

ILIAS\MetaData\Services\CopyrightHelper\CopyrightTest::testPresentAsImageOnly ( )

Definition at line 319 of file CopyrightTest.php.

319 : void
320 {
321 $icon = $this->getIcon();
322 $renderer = $this->getRenderer($icon);
323 $copyright = new Copyright(
324 $renderer,
325 $this->getIdentifierHandler(),
326 $this->getEntry(
327 false,
328 false,
329 35,
330 'cp title',
331 'cp description',
332 'data of copyright'
333 )
334 );
335
336 $image = $copyright->presentAsImageOnly();
337
338 $this->assertSame($icon, $image);
339 $this->assertSame('data of copyright', $renderer->exposed_copyright_data);
340 }

References $renderer.

◆ testPresentAsLinkOnly()

ILIAS\MetaData\Services\CopyrightHelper\CopyrightTest::testPresentAsLinkOnly ( )

Definition at line 342 of file CopyrightTest.php.

342 : void
343 {
344 $link = $this->getLink();
345 $renderer = $this->getRenderer(null, $link);
346 $copyright = new Copyright(
347 $renderer,
348 $this->getIdentifierHandler(),
349 $this->getEntry(
350 false,
351 false,
352 35,
353 'cp title',
354 'cp description',
355 'data of copyright'
356 )
357 );
358
359 $res_link = $copyright->presentAsLinkOnly();
360
361 $this->assertSame($link, $res_link);
362 $this->assertSame('data of copyright', $renderer->exposed_copyright_data);
363 }

References $renderer.

◆ testPresentAsString()

ILIAS\MetaData\Services\CopyrightHelper\CopyrightTest::testPresentAsString ( )

Definition at line 365 of file CopyrightTest.php.

365 : void
366 {
367 $copyright = new Copyright(
368 $this->getRenderer(),
369 $this->getIdentifierHandler(),
370 $this->getEntry(
371 false,
372 false,
373 35,
374 'cp title',
375 'cp description',
376 'data of copyright'
377 )
378 );
379
380 $this->assertSame('data of copyright', $copyright->presentAsString());
381 }

◆ testPresentAsUIComponents()

ILIAS\MetaData\Services\CopyrightHelper\CopyrightTest::testPresentAsUIComponents ( )

Definition at line 293 of file CopyrightTest.php.

293 : void
294 {
295 $icon = $this->getIcon();
296 $link = $this->getLink();
297 $renderer = $this->getRenderer($icon, $link);
298 $copyright = new Copyright(
299 $renderer,
300 $this->getIdentifierHandler(),
301 $this->getEntry(
302 false,
303 false,
304 35,
305 'cp title',
306 'cp description',
307 'data of copyright'
308 )
309 );
310
311 $components = $copyright->presentAsUIComponents();
312
313 $this->assertCount(2, $components);
314 $this->assertSame($icon, $components[0] ?? null);
315 $this->assertSame($link, $components[1] ?? null);
316 $this->assertSame('data of copyright', $renderer->exposed_copyright_data);
317 }
$components

References $components, and $renderer.

◆ testTitle()

ILIAS\MetaData\Services\CopyrightHelper\CopyrightTest::testTitle ( )

Definition at line 257 of file CopyrightTest.php.

257 : void
258 {
259 $copyright = new Copyright(
260 $this->getRenderer(),
261 $this->getIdentifierHandler(),
262 $this->getEntry(
263 false,
264 false,
265 35,
266 'cp title',
267 'cp description',
268 'data of copyright'
269 )
270 );
271
272 $this->assertSame('cp title', $copyright->title());
273 }

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