ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
DocumentModalTest.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
25use ILIAS\UI\Component\Button\Factory as ButtonFactory;
28use ILIAS\UI\Component\Modal\Factory as ModalFactory;
32use ILIAS\LegalDocuments\test\ContainerMock;
34use PHPUnit\Framework\TestCase;
36
37require_once __DIR__ . '/../ContainerMock.php';
38
39class DocumentModalTest extends TestCase
40{
41 use ContainerMock;
42
43 public function testConstruct(): void
44 {
45 $this->assertInstanceOf(DocumentModal::class, new DocumentModal($this->mock(UIServices::class), $this->fail(...)));
46 }
47
48 public function testCreate(): void
49 {
50 $content = $this->mockTree(DocumentContent::class, ['title' => 'foo']);
51 $component = $this->mock(Component::class);
52 $signal = $this->mock(Signal::class);
53 $modal_component = $this->mockTree(Lightbox::class, ['getShowSignal' => $signal]);
54 $button_component = $this->mock(Shy::class);
55 $button_component->expects(self::once())->method('withOnClick')->with($signal)->willReturn($button_component);
56
57 $text_page = $this->mock(LightboxTextPage::class);
58
59 $modal = $this->mock(ModalFactory::class);
60 $modal->expects(self::once())->method('lightboxTextPage')->with('rendered', 'foo')->willReturn($text_page);
61 $modal->expects(self::once())->method('lightbox')->with([$text_page])->willReturn($modal_component);
62
63 $instance = new DocumentModal($this->mockTree(UIServices::class, [
64 'renderer' => $this->mockMethod(Renderer::class, 'render', [$component], 'rendered'),
65 'factory' => [
66 'modal' => $modal,
67 'button' => $this->mockMethod(ButtonFactory::class, 'shy', ['foo', ''], $button_component),
68 ],
69 ]), function (DocumentContent $c) use ($content, $component): Component {
70 $this->assertSame($content, $c);
71 return $component;
72 });
73
74 $this->assertSame([$button_component, $modal_component], $instance->create($content));
75 }
76}
Provides fluid interface to RBAC services.
Definition: UIServices.php:25
Builds a Color from either hex- or rgb values.
Definition: Factory.php:31
$c
Definition: deliver.php:25
A component is the most general form of an entity in the UI.
Definition: Component.php:28
A lightbox Text page represents a page displaying a media element, such as text.
An entity that renders components to a string output.
Definition: Renderer.php:31