ILIAS  trunk Revision v11.0_alpha-1744-gb0451eebef4
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ModalTest.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
21 namespace ILIAS\Badge\test;
22 
23 use Exception;
30 use ILIAS\UI\Component\Image\Factory as ImageFactory;
32 use ILIAS\UI\Component\Item\Factory as ItemFactory;
36 use ILIAS\UI\Factory as UI;
39 use ilBadge;
40 use ilLanguage;
41 
42 class ModalTest extends TestCase
43 {
44  public function testConstruct(): void
45  {
46  $container = $this->getMockBuilder(Container::class)->disableOriginalConstructor()->getMock();
47  $modal = new Modal($container, static function (): void {
48  throw new Exception('Should not be called.');
49  });
50  $this->assertInstanceOf(Modal::class, $modal);
51  }
52 
53  public function testComponents(): void
54  {
55  $badge = $this->getMockBuilder(ilBadge::class)->disableOriginalConstructor()->getMock();
56  $container = $this->getMockBuilder(Container::class)->disableOriginalConstructor()->getMock();
57  $content = $this->getMockBuilder(ModalContent::class)->disableOriginalConstructor()->getMock();
58  $divider = $this->getMockBuilder(Divider::class)->getMock();
59  $divider_component = $this->getMockBuilder(Horizontal::class)->getMock();
60  $factory = $this->getMockBuilder(UI::class)->disableOriginalConstructor()->getMock();
61  $group = $this->getMockBuilder(Group::class)->getMock();
62  $image = $this->getMockBuilder(ImageFactory::class)->getMock();
63  $image_component = $this->getMockBuilder(Image::class)->getMock();
64  $item = $this->getMockBuilder(ItemFactory::class)->getMock();
65  $item_component = $this->getMockBuilder(Item::class)->getMock();
66  $language = $this->getMockBuilder(ilLanguage::class)->disableOriginalConstructor()->getMock();
67  $listing = $this->getMockBuilder(Listing::class)->getMock();
68  $ui = $this->getMockBuilder(UIServices::class)->disableOriginalConstructor()->getMock();
69 
70  $factory->method('image')->willReturn($image);
71  $factory->method('listing')->willReturn($listing);
72  $factory->method('divider')->willReturn($divider);
73  $factory->method('item')->willReturn($item);
74  $item->method('group')->willReturn($group);
75  $item->method('standard')->willReturn($item_component);
76  $ui->method('factory')->willReturn($factory);
77  $container->method('ui')->willReturn($ui);
78  $container->method('language')->willReturn($language);
79  $image->expects(self::once())->method('responsive')->willReturn($image_component);
80  $divider->expects(self::once())->method('horizontal')->willReturn($divider_component);
81 
82  $properties = [
83  'lorem' => 'ipsum',
84  'dolor' => 'posuere',
85  ];
86 
87  $item_component->method('withDescription')->willReturn($item_component);
88  $item_component->method('withProperties')->with($properties)->willReturn($item_component);
89 
90  $content->method('badge')->willReturn($badge);
91  $content->method('properties')->willReturn($properties);
92 
93  $modal = new Modal($container, fn(string $file): string => '/');
94 
95  $this->assertSame([$image_component, $divider_component, $item_component], $modal->components($content));
96  }
97 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$container
Definition: wac.php:36
This is how a factory for listings looks like.
Definition: Factory.php:26
This is how a factory for Items looks like.
Definition: Factory.php:28
This is how the factory for UI elements looks.
Definition: Factory.php:27