ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
PCMediaObjectTest Class Reference
+ Inheritance diagram for PCMediaObjectTest:
+ Collaboration diagram for PCMediaObjectTest:

Public Member Functions

 testConstruction ()
 
 testCreate ()
 
 testCreateAlias ()
 
 testDump ()
 
 testSetClass ()
 
 testCaptionClass ()
 
 checkMAProps (Closure $assert, ?string $expected=null)
 
 testWidth ()
 
 testHeight ()
 
 testDeriveSize ()
 
 testCaption ()
 
 testDeriveCaption ()
 
 testQuickEditCaption ()
 
 testTextRepresentation ()
 
 testDeriveTextRepresentation ()
 
 testHorizontalAlign ()
 
 testParameters ()
 
 testDeriveParameters ()
 
 testAddMapArea ()
 
 testDeleteMapArea ()
 
 testDeleteMapAreaById ()
 
 testDeleteAllMapAreas ()
 
 testAreaProps ()
 

Protected Member Functions

 getObjectAdapterMock ()
 
 getMediaObjectInPage (ilPageObject $page)
 
- Protected Member Functions inherited from COPageTestBase
 setGlobalVariable (string $name, $value)
 
 setUp ()
 
 getIdGeneratorMock ()
 
 getPCDefinition ()
 
 setPCIdCnt (int $cnt)
 
 getIDManager (\ilPageObject $page)
 
 insertParagraphAt (\ilPageObject $page, string $hier_id, string $text="")
 
 tearDown ()
 
 normalize (string $html)
 
 assertXmlEquals (string $expected_xml_as_string, string $html_xml_string)
 
 getEmptyPageWithDom ()
 
 legacyHtmlToXml (string $content)
 
 getMediaObjectMock ()
 

Additional Inherited Members

- Protected Attributes inherited from COPageTestBase
int $pc_cnt
 

Detailed Description

Author
Alexander Killing killi.nosp@m.ng@l.nosp@m.eifos.nosp@m..de

Definition at line 27 of file PCMediaObjectTest.php.

Member Function Documentation

◆ checkMAProps()

PCMediaObjectTest::checkMAProps ( Closure  $assert,
?string  $expected = null 
)

Definition at line 163 of file PCMediaObjectTest.php.

166 : void {
167 $page = $this->getEmptyPageWithDom();
168 $pc = $this->getMediaObjectInPage($page);
169 $ma = $pc->getStandardMediaAliasItem();
170
171 $assert($ma);
172
173 $page->stripHierIDs();
174 $page->stripPCIDs();
175
176 if (!is_null($expected)) {
177 $this->assertXmlEquals(
178 $expected,
179 $page->getXMLFromDom()
180 );
181 }
182 }
assertXmlEquals(string $expected_xml_as_string, string $html_xml_string)
getMediaObjectInPage(ilPageObject $page)

◆ getMediaObjectInPage()

PCMediaObjectTest::getMediaObjectInPage ( ilPageObject  $page)
protected

Definition at line 80 of file PCMediaObjectTest.php.

81 {
82 $pc = new ilPCMediaObject($page);
83 $pc->setMediaObject($this->getMediaObjectMock());
84 $pc->createAlias($page, "pg");
85 $page->addHierIDs();
86 $page->insertPCIds();
87 $pc->setHierId("1");
88 $pc->setPCId($page->getPCIdForHierId("1"));
89 $pc->setDomNode($pc->getDomNode());
90 return $pc;
91 }
Class ilPCMediaObject Media content object (see ILIAS DTD)

References $page, and COPageTestBase\getMediaObjectMock().

Referenced by testCaptionClass(), testDump(), and testSetClass().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getObjectAdapterMock()

PCMediaObjectTest::getObjectAdapterMock ( )
protected
Returns
(\ILIAS\Repository\Object\ObjectAdapter&Stub)|Stub

Definition at line 32 of file PCMediaObjectTest.php.

32 : Stub
33 {
34 $object_adapter = $this->createStub(\ILIAS\Repository\Object\ObjectAdapter::class);
35 $object_adapter->method("getTypeForObjId")
36 ->willReturnCallback(fn() => "dummy");
37 return $object_adapter;
38 }
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.

◆ testAddMapArea()

PCMediaObjectTest::testAddMapArea ( )

Definition at line 439 of file PCMediaObjectTest.php.

439 : void
440 {
441 $this->checkMAProps(
442 function (ilMediaAliasItem $ma): void {
443 $ma->addMapArea(
445 "10,10,100,100",
446 "Area Title",
447 [
448 "LinkType" => "ext",
449 "Href" => "http://www.ilias.de"
450 ],
451 "One"
452 );
453 $this->assertEquals(
454 [
455 0 => [
456 "Nr" => 1,
457 "Shape" => "Rect",
458 "Coords" => "10,10,100,100",
459 "HighlightMode" => "",
460 "HighlightClass" => "",
461 "Id" => "One",
462 "Link" => [
463 "LinkType" => "ExtLink",
464 "Href" => "http://www.ilias.de",
465 "Title" => "Area Title"
466 ]
467 ]
468 ],
469 $ma->getMapAreas()
470 );
471 $this->assertEquals(
472 "http://www.ilias.de",
473 $ma->getHrefOfArea(1)
474 );
475 },
476 $expected = <<<EOT
477<PageObject><PageContent><MediaObject><MediaAlias OriginId="il__mob_0"></MediaAlias><MediaAliasItem Purpose="Standard"><Layout HorizontalAlign="Left"></Layout><MapArea Shape="Rect" Coords="10,10,100,100" Id="One"><ExtLink Href="http://www.ilias.de">Area Title</ExtLink></MapArea></MediaAliasItem><MediaAliasItem Purpose="Fullscreen"><Layout Width="100" Height="50"></Layout></MediaAliasItem></MediaObject></PageContent></PageObject>
478EOT
479 );
480 }
checkMAProps(Closure $assert, ?string $expected=null)
Title class.
Definition: Title.php:42
const IL_AREA_RECT
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getHrefOfArea(int $a_nr)
Get href (only external link)
addMapArea(string $a_shape_type, string $a_coords, string $a_title, array $a_link, string $a_id="", string $hl_mode="", string $hl_class="",)
Add a new area to the map.
getMapAreas()
Get all map areas.

References ilMediaAliasItem\addMapArea(), ilMediaAliasItem\getHrefOfArea(), ilMediaAliasItem\getMapAreas(), and IL_AREA_RECT.

+ Here is the call graph for this function:

◆ testAreaProps()

PCMediaObjectTest::testAreaProps ( )

Definition at line 578 of file PCMediaObjectTest.php.

578 : void
579 {
580 $this->checkMAProps(
581 function (ilMediaAliasItem $ma): void {
582 $ma->addMapArea(
584 "10,10,100,100",
585 "Area Title",
586 [
587 "LinkType" => "int",
588 "Type" => "ltype",
589 "Target" => "ltarget",
590 "TargetFrame" => "ltargetframe"
591 ],
592 "One"
593 );
594 $this->assertEquals(
595 "int",
596 $ma->getLinkTypeOfArea(1)
597 );
598 $this->assertEquals(
599 "ltype",
600 $ma->getTypeOfArea(1)
601 );
602 $this->assertEquals(
603 "ltarget",
604 $ma->getTargetOfArea(1)
605 );
606 $this->assertEquals(
607 "ltargetframe",
609 );
610 $this->assertEquals(
611 "Area Title",
612 $ma->getTitleOfArea(1)
613 );
614 },
615 null
616 );
617 }
getTitleOfArea(int $a_nr)
Get title.
getTargetFrameOfArea(int $a_nr)
Get target frame (only internal link)
getTypeOfArea(int $a_nr)
Get type (only internal link)
getTargetOfArea(int $a_nr)
Get target (only internal link)
getLinkTypeOfArea(int $a_nr)
Get link type.

References ilMediaAliasItem\addMapArea(), ilMediaAliasItem\getLinkTypeOfArea(), ilMediaAliasItem\getTargetFrameOfArea(), ilMediaAliasItem\getTargetOfArea(), ilMediaAliasItem\getTitleOfArea(), ilMediaAliasItem\getTypeOfArea(), and IL_AREA_RECT.

+ Here is the call graph for this function:

◆ testCaption()

PCMediaObjectTest::testCaption ( )

Definition at line 250 of file PCMediaObjectTest.php.

250 : void
251 {
252 $this->checkMAProps(
253 function (ilMediaAliasItem $ma): void {
254 $this->assertEquals(
255 false,
256 $ma->definesCaption()
257 );
258 $ma->setCaption("My Caption");
259 $this->assertEquals(
260 "My Caption",
261 $ma->getCaption()
262 );
263 $this->assertEquals(
264 true,
265 $ma->definesCaption()
266 );
267 },
268 $expected = <<<EOT
269<PageObject><PageContent><MediaObject><MediaAlias OriginId="il__mob_0"></MediaAlias><MediaAliasItem Purpose="Standard"><Layout HorizontalAlign="Left"></Layout><Caption Align="bottom">My Caption</Caption></MediaAliasItem><MediaAliasItem Purpose="Fullscreen"><Layout Width="100" Height="50"></Layout></MediaAliasItem></MediaObject></PageContent></PageObject>
270EOT
271 );
272 }
setCaption(string $a_caption)
definesCaption()
check if alias item defines own caption or derives caption from object

References ilMediaAliasItem\definesCaption(), ilMediaAliasItem\getCaption(), and ilMediaAliasItem\setCaption().

+ Here is the call graph for this function:

◆ testCaptionClass()

PCMediaObjectTest::testCaptionClass ( )

Definition at line 136 of file PCMediaObjectTest.php.

136 : void
137 {
138 $page = $this->getEmptyPageWithDom();
139 $pc = $this->getMediaObjectInPage($page);
140
141 $pc->setCaptionClass("MyCaptionClass");
142
143 $this->assertEquals(
144 "MyCaptionClass",
145 $pc->getCaptionClass()
146 );
147
148 $page->stripHierIDs();
149 $page->stripPCIDs();
150
151 $expected = <<<EOT
152<PageObject><PageContent><MediaObject><MediaAlias OriginId="il__mob_0" CaptionClass="MyCaptionClass"/><MediaAliasItem Purpose="Standard"><Layout HorizontalAlign="Left"/></MediaAliasItem><MediaAliasItem Purpose="Fullscreen"><Layout Width="100" Height="50"/></MediaAliasItem></MediaObject></PageContent></PageObject>
153EOT;
154
155 $this->assertXmlEquals(
156 $expected,
157 $page->getXMLFromDom()
158 );
159 }

References $page, COPageTestBase\assertXmlEquals(), COPageTestBase\getEmptyPageWithDom(), and getMediaObjectInPage().

+ Here is the call graph for this function:

◆ testConstruction()

PCMediaObjectTest::testConstruction ( )

Definition at line 40 of file PCMediaObjectTest.php.

40 : void
41 {
42 $page = $this->getEmptyPageWithDom();
43 $pc = new ilPCMediaObject($page);
44 $this->assertEquals(
45 ilPCMediaObject::class,
46 get_class($pc)
47 );
48 }

References $page, and COPageTestBase\getEmptyPageWithDom().

+ Here is the call graph for this function:

◆ testCreate()

PCMediaObjectTest::testCreate ( )

Definition at line 50 of file PCMediaObjectTest.php.

50 : void
51 {
52 $page = $this->getEmptyPageWithDom();
53 $pc = new ilPCMediaObject($page);
54 $pc->create($page, "pg");
55 $this->assertXmlEquals(
56 '<PageObject HierId="pg"></PageObject>',
57 $page->getXMLFromDom()
58 );
59 }

References $page, COPageTestBase\assertXmlEquals(), and COPageTestBase\getEmptyPageWithDom().

+ Here is the call graph for this function:

◆ testCreateAlias()

PCMediaObjectTest::testCreateAlias ( )

Definition at line 61 of file PCMediaObjectTest.php.

61 : void
62 {
63 $page = $this->getEmptyPageWithDom();
64 $pc = new ilPCMediaObject($page);
65 $pc->setMediaObject($this->getMediaObjectMock());
66 $pc->createAlias($page, "pg");
67
68 $page->stripHierIDs();
69
70 $expected = <<<EOT
71<PageObject><PageContent><MediaObject><MediaAlias OriginId="il__mob_0"></MediaAlias><MediaAliasItem Purpose="Standard"><Layout HorizontalAlign="Left"></Layout></MediaAliasItem><MediaAliasItem Purpose="Fullscreen"><Layout Width="100" Height="50"></Layout></MediaAliasItem></MediaObject></PageContent></PageObject>
72EOT;
73
74 $this->assertXmlEquals(
75 $expected,
76 $page->getXMLFromDom()
77 );
78 }

References $page, COPageTestBase\assertXmlEquals(), COPageTestBase\getEmptyPageWithDom(), and COPageTestBase\getMediaObjectMock().

+ Here is the call graph for this function:

◆ testDeleteAllMapAreas()

PCMediaObjectTest::testDeleteAllMapAreas ( )

Definition at line 546 of file PCMediaObjectTest.php.

546 : void
547 {
548 $this->checkMAProps(
549 function (ilMediaAliasItem $ma): void {
550 $ma->addMapArea(
552 "10,10,100,100",
553 "Area Title",
554 [
555 "LinkType" => "ext",
556 "Href" => "http://www.ilias.de"
557 ],
558 "One"
559 );
560 $ma->addMapArea(
562 "11,11,101,101",
563 "Area Title 2",
564 [
565 "LinkType" => "ext",
566 "Href" => "http://ilias.de"
567 ],
568 "Two"
569 );
570 $ma->deleteAllMapAreas();
571 },
572 $expected = <<<EOT
573<PageObject><PageContent><MediaObject><MediaAlias OriginId="il__mob_0"></MediaAlias><MediaAliasItem Purpose="Standard"><Layout HorizontalAlign="Left"></Layout></MediaAliasItem><MediaAliasItem Purpose="Fullscreen"><Layout Width="100" Height="50"></Layout></MediaAliasItem></MediaObject></PageContent></PageObject>
574EOT
575 );
576 }
deleteAllMapAreas()
Delete all map areas.

References ilMediaAliasItem\addMapArea(), ilMediaAliasItem\deleteAllMapAreas(), and IL_AREA_RECT.

+ Here is the call graph for this function:

◆ testDeleteMapArea()

PCMediaObjectTest::testDeleteMapArea ( )

Definition at line 482 of file PCMediaObjectTest.php.

482 : void
483 {
484 $this->checkMAProps(
485 function (ilMediaAliasItem $ma): void {
486 $ma->addMapArea(
488 "10,10,100,100",
489 "Area Title",
490 [
491 "LinkType" => "ext",
492 "Href" => "http://www.ilias.de"
493 ],
494 "One"
495 );
496 $ma->addMapArea(
498 "11,11,101,101",
499 "Area Title 2",
500 [
501 "LinkType" => "ext",
502 "Href" => "http://ilias.de"
503 ],
504 "Two"
505 );
506 $ma->deleteMapArea(1);
507 },
508 $expected = <<<EOT
509<PageObject><PageContent><MediaObject><MediaAlias OriginId="il__mob_0"></MediaAlias><MediaAliasItem Purpose="Standard"><Layout HorizontalAlign="Left"></Layout><MapArea Shape="Rect" Coords="11,11,101,101" Id="Two"><ExtLink Href="http://ilias.de">Area Title 2</ExtLink></MapArea></MediaAliasItem><MediaAliasItem Purpose="Fullscreen"><Layout Width="100" Height="50"></Layout></MediaAliasItem></MediaObject></PageContent></PageObject>
510EOT
511 );
512 }
deleteMapArea(int $a_nr)
Delete a sinlge map area.

References ilMediaAliasItem\addMapArea(), ilMediaAliasItem\deleteMapArea(), and IL_AREA_RECT.

+ Here is the call graph for this function:

◆ testDeleteMapAreaById()

PCMediaObjectTest::testDeleteMapAreaById ( )

Definition at line 514 of file PCMediaObjectTest.php.

514 : void
515 {
516 $this->checkMAProps(
517 function (ilMediaAliasItem $ma): void {
518 $ma->addMapArea(
520 "10,10,100,100",
521 "Area Title",
522 [
523 "LinkType" => "ext",
524 "Href" => "http://www.ilias.de"
525 ],
526 "One"
527 );
528 $ma->addMapArea(
530 "11,11,101,101",
531 "Area Title 2",
532 [
533 "LinkType" => "ext",
534 "Href" => "http://ilias.de"
535 ],
536 "Two"
537 );
538 $ma->deleteMapAreaById("One");
539 },
540 $expected = <<<EOT
541<PageObject><PageContent><MediaObject><MediaAlias OriginId="il__mob_0"></MediaAlias><MediaAliasItem Purpose="Standard"><Layout HorizontalAlign="Left"></Layout><MapArea Shape="Rect" Coords="11,11,101,101" Id="Two"><ExtLink Href="http://ilias.de">Area Title 2</ExtLink></MapArea></MediaAliasItem><MediaAliasItem Purpose="Fullscreen"><Layout Width="100" Height="50"></Layout></MediaAliasItem></MediaObject></PageContent></PageObject>
542EOT
543 );
544 }
deleteMapAreaById(string $a_id)
Delete map areas by id.

References ilMediaAliasItem\addMapArea(), ilMediaAliasItem\deleteMapAreaById(), and IL_AREA_RECT.

+ Here is the call graph for this function:

◆ testDeriveCaption()

PCMediaObjectTest::testDeriveCaption ( )

Definition at line 274 of file PCMediaObjectTest.php.

274 : void
275 {
276 $this->checkMAProps(
277 function (ilMediaAliasItem $ma): void {
278 $ma->setCaption("My Caption");
279 $this->assertEquals(
280 true,
281 $ma->definesCaption()
282 );
283 $ma->deriveCaption();
284 $this->assertEquals(
285 false,
286 $ma->definesCaption()
287 );
288 },
289 $expected = <<<EOT
290<PageObject><PageContent><MediaObject><MediaAlias OriginId="il__mob_0"></MediaAlias><MediaAliasItem Purpose="Standard"><Layout HorizontalAlign="Left"></Layout></MediaAliasItem><MediaAliasItem Purpose="Fullscreen"><Layout Width="100" Height="50"></Layout></MediaAliasItem></MediaObject></PageContent></PageObject>
291EOT
292 );
293 }
deriveCaption()
derive caption from object (-> caption element is removed from media alias item)

References ilMediaAliasItem\definesCaption(), ilMediaAliasItem\deriveCaption(), and ilMediaAliasItem\setCaption().

+ Here is the call graph for this function:

◆ testDeriveParameters()

PCMediaObjectTest::testDeriveParameters ( )

Definition at line 419 of file PCMediaObjectTest.php.

419 : void
420 {
421 $this->checkMAProps(
422 function (ilMediaAliasItem $ma): void {
423 $ma->setParameters([
424 "par1" => "val1",
425 "par2" => "val2"
426 ]);
427 $ma->deriveParameters();
428 $this->assertEquals(
429 false,
430 $ma->definesParameters()
431 );
432 },
433 $expected = <<<EOT
434<PageObject><PageContent><MediaObject><MediaAlias OriginId="il__mob_0"></MediaAlias><MediaAliasItem Purpose="Standard"><Layout HorizontalAlign="Left"></Layout></MediaAliasItem><MediaAliasItem Purpose="Fullscreen"><Layout Width="100" Height="50"></Layout></MediaAliasItem></MediaObject></PageContent></PageObject>
435EOT
436 );
437 }
setParameters(array $a_par_array)
definesParameters()
check if alias item defines own parameters or derives parameters from object
deriveParameters()
derive parameters from object (-> all parameter elements are removed from media alias item)

References ilMediaAliasItem\definesParameters(), ilMediaAliasItem\deriveParameters(), and ilMediaAliasItem\setParameters().

+ Here is the call graph for this function:

◆ testDeriveSize()

PCMediaObjectTest::testDeriveSize ( )

Definition at line 224 of file PCMediaObjectTest.php.

224 : void
225 {
226 $this->checkMAProps(
227 function (ilMediaAliasItem $ma): void {
228 $this->assertEquals(
229 false,
230 $ma->definesSize()
231 );
232 $ma->setWidth("222");
233 $ma->setHeight("111");
234 $this->assertEquals(
235 true,
236 $ma->definesSize()
237 );
238 $ma->deriveSize();
239 $this->assertEquals(
240 false,
241 $ma->definesSize()
242 );
243 },
244 $expected = <<<EOT
245<PageObject><PageContent><MediaObject><MediaAlias OriginId="il__mob_0"/><MediaAliasItem Purpose="Standard"><Layout HorizontalAlign="Left"/></MediaAliasItem><MediaAliasItem Purpose="Fullscreen"><Layout Width="100" Height="50"/></MediaAliasItem></MediaObject></PageContent></PageObject>
246EOT
247 );
248 }
setHeight(string $a_height)
setWidth(string $a_width)
definesSize()
check if alias item defines own size or derives size from object
deriveSize()
derive size from object (-> width and height attributes are removed from layout element)

References ilMediaAliasItem\definesSize(), ilMediaAliasItem\deriveSize(), ilMediaAliasItem\setHeight(), and ilMediaAliasItem\setWidth().

+ Here is the call graph for this function:

◆ testDeriveTextRepresentation()

PCMediaObjectTest::testDeriveTextRepresentation ( )

Definition at line 348 of file PCMediaObjectTest.php.

348 : void
349 {
350 $this->checkMAProps(
351 function (ilMediaAliasItem $ma): void {
352 $ma->setTextRepresentation("My Text");
353 $this->assertEquals(
354 true,
356 );
358 $this->assertEquals(
359 false,
361 );
362 },
363 $expected = <<<EOT
364<PageObject><PageContent><MediaObject><MediaAlias OriginId="il__mob_0"></MediaAlias><MediaAliasItem Purpose="Standard"><Layout HorizontalAlign="Left"></Layout></MediaAliasItem><MediaAliasItem Purpose="Fullscreen"><Layout Width="100" Height="50"></Layout></MediaAliasItem></MediaObject></PageContent></PageObject>
365EOT
366 );
367 }
definesTextRepresentation()
check if alias item defines own TextRepresentation or derives TextRepresentation from object
setTextRepresentation(string $a_text_representation)
deriveTextRepresentation()
derive TextRepresentation from object (-> TextRepresentation element is removed from media alias item...

References ilMediaAliasItem\definesTextRepresentation(), ilMediaAliasItem\deriveTextRepresentation(), and ilMediaAliasItem\setTextRepresentation().

+ Here is the call graph for this function:

◆ testDump()

PCMediaObjectTest::testDump ( )

Definition at line 93 of file PCMediaObjectTest.php.

93 : void
94 {
95 $page = $this->getEmptyPageWithDom();
96 $pc = $this->getMediaObjectInPage($page);
97
98 $page->stripHierIDs();
99 $page->stripPCIDs();
100
101 $expected = <<<EOT
102<PageContent><MediaObject><MediaAlias OriginId="il__mob_0"/><MediaAliasItem Purpose="Standard"><Layout HorizontalAlign="Left"/></MediaAliasItem><MediaAliasItem Purpose="Fullscreen"><Layout Width="100" Height="50"/></MediaAliasItem></MediaObject></PageContent>
103EOT;
104
105 $this->assertXmlEquals(
106 $expected,
107 $pc->dumpXML()
108 );
109 }

References $page, COPageTestBase\assertXmlEquals(), COPageTestBase\getEmptyPageWithDom(), and getMediaObjectInPage().

+ Here is the call graph for this function:

◆ testHeight()

PCMediaObjectTest::testHeight ( )

Definition at line 208 of file PCMediaObjectTest.php.

208 : void
209 {
210 $this->checkMAProps(
211 function (ilMediaAliasItem $ma): void {
212 $ma->setHeight("11");
213 $this->assertEquals(
214 "11",
215 $ma->getHeight()
216 );
217 },
218 $expected = <<<EOT
219<PageObject><PageContent><MediaObject><MediaAlias OriginId="il__mob_0"/><MediaAliasItem Purpose="Standard"><Layout HorizontalAlign="Left" Height="11"/></MediaAliasItem><MediaAliasItem Purpose="Fullscreen"><Layout Width="100" Height="50"/></MediaAliasItem></MediaObject></PageContent></PageObject>
220EOT
221 );
222 }

References ilMediaAliasItem\getHeight(), and ilMediaAliasItem\setHeight().

+ Here is the call graph for this function:

◆ testHorizontalAlign()

PCMediaObjectTest::testHorizontalAlign ( )

Definition at line 369 of file PCMediaObjectTest.php.

369 : void
370 {
371 $this->checkMAProps(
372 function (ilMediaAliasItem $ma): void {
373 $ma->setHorizontalAlign("Right");
374 $this->assertEquals(
375 "Right",
376 $ma->getHorizontalAlign()
377 );
378 },
379 $expected = <<<EOT
380<PageObject><PageContent><MediaObject><MediaAlias OriginId="il__mob_0"></MediaAlias><MediaAliasItem Purpose="Standard"><Layout HorizontalAlign="Right"></Layout></MediaAliasItem><MediaAliasItem Purpose="Fullscreen"><Layout Width="100" Height="50"></Layout></MediaAliasItem></MediaObject></PageContent></PageObject>
381EOT
382 );
383 }
setHorizontalAlign(string $a_halign)

References ilMediaAliasItem\getHorizontalAlign(), and ilMediaAliasItem\setHorizontalAlign().

+ Here is the call graph for this function:

◆ testParameters()

PCMediaObjectTest::testParameters ( )

Definition at line 385 of file PCMediaObjectTest.php.

385 : void
386 {
387 $this->checkMAProps(
388 function (ilMediaAliasItem $ma): void {
389 $this->assertEquals(
390 false,
391 $ma->definesParameters()
392 );
393 $ma->setParameters([
394 "par1" => "val1",
395 "par2" => "val2"
396 ]);
397 $this->assertEquals(
398 [
399 "par1" => "val1",
400 "par2" => "val2"
401 ],
402 $ma->getParameters()
403 );
404 $this->assertEquals(
405 true,
406 $ma->definesParameters()
407 );
408 $this->assertEquals(
409 'par1="val1", par2="val2"',
410 $ma->getParameterString()
411 );
412 },
413 $expected = <<<EOT
414<PageObject><PageContent><MediaObject><MediaAlias OriginId="il__mob_0"></MediaAlias><MediaAliasItem Purpose="Standard"><Layout HorizontalAlign="Left"></Layout><Parameter Name="par1" Value="val1"></Parameter><Parameter Name="par2" Value="val2"></Parameter></MediaAliasItem><MediaAliasItem Purpose="Fullscreen"><Layout Width="100" Height="50"></Layout></MediaAliasItem></MediaObject></PageContent></PageObject>
415EOT
416 );
417 }
getParameterString()
Get all parameters as string.
getParameters()
Get all parameters as array.

References ilMediaAliasItem\definesParameters(), ilMediaAliasItem\getParameters(), ilMediaAliasItem\getParameterString(), and ilMediaAliasItem\setParameters().

+ Here is the call graph for this function:

◆ testQuickEditCaption()

PCMediaObjectTest::testQuickEditCaption ( )

Definition at line 295 of file PCMediaObjectTest.php.

295 : void
296 {
297 $page = $this->getEmptyPageWithDom();
298 $media_item = new ilMediaItem();
299 $media_item->setCaption("Source caption");
300 $media_object = $this->getMockBuilder(ilObjMediaObject::class)
301 ->disableOriginalConstructor()
302 ->getMock();
303 $media_object->method("getMediaItem")
304 ->willReturn($media_item);
305 $media_object->method("getUsages")
306 ->willReturn([]);
307
308 $pc = new ilPCMediaObject($page);
309 $pc->setMediaObject($media_object);
310 $pc->createAlias($page, "pg");
311 $page->addHierIDs();
312 $pc->setHierId("1");
313 $page->insertPCIds();
314 $pc->setPCId($page->getPCIdForHierId("1"));
315
316 $quick_edit = new ilPCMediaObjectQuickEdit($pc);
317 $this->assertEquals("Source caption", $quick_edit->getCaption());
318
319 $pc->getStandardMediaAliasItem()->setCaption("");
320
321 $this->assertEquals("", $quick_edit->getCaption());
322 }
Class ilMediaItem Media Item, component of a media object (file or reference)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

References $page.

◆ testSetClass()

PCMediaObjectTest::testSetClass ( )

Definition at line 111 of file PCMediaObjectTest.php.

111 : void
112 {
113 $page = $this->getEmptyPageWithDom();
114 $pc = $this->getMediaObjectInPage($page);
115
116 $pc->setClass("MyClass");
117
118 $this->assertEquals(
119 "MyClass",
120 $pc->getClass()
121 );
122
123 $page->stripHierIDs();
124 $page->stripPCIDs();
125
126 $expected = <<<EOT
127<PageObject><PageContent><MediaObject><MediaAlias OriginId="il__mob_0" Class="MyClass"/><MediaAliasItem Purpose="Standard"><Layout HorizontalAlign="Left"/></MediaAliasItem><MediaAliasItem Purpose="Fullscreen"><Layout Width="100" Height="50"/></MediaAliasItem></MediaObject></PageContent></PageObject>
128EOT;
129
130 $this->assertXmlEquals(
131 $expected,
132 $page->getXMLFromDom()
133 );
134 }

References $page, COPageTestBase\assertXmlEquals(), COPageTestBase\getEmptyPageWithDom(), and getMediaObjectInPage().

+ Here is the call graph for this function:

◆ testTextRepresentation()

PCMediaObjectTest::testTextRepresentation ( )

Definition at line 324 of file PCMediaObjectTest.php.

324 : void
325 {
326 $this->checkMAProps(
327 function (ilMediaAliasItem $ma): void {
328 $this->assertEquals(
329 false,
331 );
332 $ma->setTextRepresentation("My Text");
333 $this->assertEquals(
334 "My Text",
336 );
337 $this->assertEquals(
338 true,
340 );
341 },
342 $expected = <<<EOT
343<PageObject><PageContent><MediaObject><MediaAlias OriginId="il__mob_0"></MediaAlias><MediaAliasItem Purpose="Standard"><Layout HorizontalAlign="Left"></Layout><TextRepresentation>My Text</TextRepresentation></MediaAliasItem><MediaAliasItem Purpose="Fullscreen"><Layout Width="100" Height="50"></Layout></MediaAliasItem></MediaObject></PageContent></PageObject>
344EOT
345 );
346 }

References ilMediaAliasItem\definesTextRepresentation(), ilMediaAliasItem\getTextRepresentation(), and ilMediaAliasItem\setTextRepresentation().

+ Here is the call graph for this function:

◆ testWidth()

PCMediaObjectTest::testWidth ( )

Definition at line 184 of file PCMediaObjectTest.php.

184 : void
185 {
186 $this->checkMAProps(
187 function (ilMediaAliasItem $ma): void {
188 $this->assertEquals(
189 false,
190 $ma->definesSize()
191 );
192 $ma->setWidth("222");
193 $this->assertEquals(
194 "222",
195 $ma->getWidth()
196 );
197 $this->assertEquals(
198 true,
199 $ma->definesSize()
200 );
201 },
202 $expected = <<<EOT
203<PageObject><PageContent><MediaObject><MediaAlias OriginId="il__mob_0"/><MediaAliasItem Purpose="Standard"><Layout HorizontalAlign="Left" Width="222"/></MediaAliasItem><MediaAliasItem Purpose="Fullscreen"><Layout Width="100" Height="50"/></MediaAliasItem></MediaObject></PageContent></PageObject>
204EOT
205 );
206 }

References ilMediaAliasItem\definesSize(), ilMediaAliasItem\getWidth(), and ilMediaAliasItem\setWidth().

+ Here is the call graph for this function:

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