ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
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;
38 use ilBadge;
39 use ilLanguage;
40 
41 class ModalTest extends TestCase
42 {
43  public function testConstruct(): void
44  {
45  $container = $this->getMockBuilder(Container::class)->disableOriginalConstructor()->getMock();
46  $modal = new Modal($container, static function (): void {
47  throw new Exception('Should not be called.');
48  });
49  $this->assertInstanceOf(Modal::class, $modal);
50  }
51 
52  public function testComponents(): void
53  {
54  $badge = $this->getMockBuilder(ilBadge::class)->disableOriginalConstructor()->getMock();
55  $container = $this->getMockBuilder(Container::class)->disableOriginalConstructor()->getMock();
56  $content = $this->getMockBuilder(ModalContent::class)->disableOriginalConstructor()->getMock();
57  $divider = $this->getMockBuilder(Divider::class)->getMock();
58  $divider_component = $this->getMockBuilder(Horizontal::class)->getMock();
59  $factory = $this->getMockBuilder(UI::class)->disableOriginalConstructor()->getMock();
60  $group = $this->getMockBuilder(Group::class)->getMock();
61  $image = $this->getMockBuilder(ImageFactory::class)->getMock();
62  $image_component = $this->getMockBuilder(Image::class)->getMock();
63  $item = $this->getMockBuilder(ItemFactory::class)->getMock();
64  $item_component = $this->getMockBuilder(Item::class)->getMock();
65  $language = $this->getMockBuilder(ilLanguage::class)->disableOriginalConstructor()->getMock();
66  $listing = $this->getMockBuilder(Listing::class)->getMock();
67  $ui = $this->getMockBuilder(UIServices::class)->disableOriginalConstructor()->getMock();
68 
69  $factory->method('image')->willReturn($image);
70  $factory->method('listing')->willReturn($listing);
71  $factory->method('divider')->willReturn($divider);
72  $factory->method('item')->willReturn($item);
73  $item->method('group')->willReturn($group);
74  $item->method('standard')->willReturn($item_component);
75  $ui->method('factory')->willReturn($factory);
76  $container->method('ui')->willReturn($ui);
77  $container->method('language')->willReturn($language);
78  $image->expects(self::once())->method('responsive')->willReturn($image_component);
79  $divider->expects(self::once())->method('horizontal')->willReturn($divider_component);
80 
81  $properties = [
82  'lorem' => 'ipsum',
83  'dolor' => 'posuere',
84  ];
85 
86  $item_component->method('withDescription')->willReturn($item_component);
87  $item_component->method('withProperties')->with($properties)->willReturn($item_component);
88 
89  $content->method('badge')->willReturn($badge);
90  $content->method('properties')->willReturn($properties);
91 
92  $modal = new Modal($container, fn(string $file): string => '/');
93 
94  $this->assertSame([$image_component, $divider_component, $item_component], $modal->components($content));
95  }
96 }
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