ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ModalTest.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21namespace ILIAS\Badge\test;
22
23use Exception;
30use ILIAS\UI\Component\Image\Factory as ImageFactory;
32use ILIAS\UI\Component\Item\Factory as ItemFactory;
36use ILIAS\UI\Factory as UI;
37use PHPUnit\Framework\TestCase;
38use ilBadge;
39use ilLanguage;
40
41class 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}
Customizing of pimple-DIC for ILIAS.
Definition: Container.php:36
Provides fluid interface to RBAC services.
Definition: UIServices.php:25
Builds a Color from either hex- or rgb values.
Definition: Factory.php:31
language handling
This describes a Standard Dropdown.
Definition: Standard.php:27
This is how the factory for UI elements looks.
Definition: Factory.php:28
This is how a factory for listings looks like.
Definition: Factory.php:27
$container
@noRector
Definition: wac.php:37