ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ModifyFooterTest.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
27use ilTemplate;
30use ILIAS\LegalDocuments\test\ContainerMock;
34use PHPUnit\Framework\TestCase;
36
37require_once __DIR__ . '/../../ContainerMock.php';
38
39class ModifyFooterTest extends TestCase
40{
41 use ContainerMock;
42
43 public function testConstruct(): void
44 {
45 $this->assertInstanceOf(ModifyFooter::class, new ModifyFooter(
46 $this->mock(UI::class),
47 $this->mock(User::class),
48 $this->mock(Provide::class),
49 $this->fail(...),
50 $this->fail(...),
51 null,
52 ));
53 }
54
55 public function testInvoke(): void
56 {
57 $return = fn() => null;
58 $footer = fn() => $return;
59
60 $instance = new ModifyFooter(
61 $this->mock(UI::class),
62 $this->mockTree(User::class, ['acceptedVersion' => new Ok($this->mock(DocumentContent::class))]),
63 $this->mock(Provide::class),
64 fn() => 'rendered',
65 fn() => $this->mock(ilTemplate::class),
66 null,
67 );
68
69 $this->assertSame($return, $instance($footer));
70 }
71
72 public function testInvokeWithGotoLink(): void
73 {
74 $dummy_uri = $this->mock(URI::class);
75 $return = fn() => null;
76 $footer = function ($id, $title, $uri) use ($dummy_uri, $return) {
77 $this->assertSame('foo', $id);
78 $this->assertSame('translated', $title);
79 $this->assertSame($dummy_uri, $uri);
80 return $return;
81 };
82
83 $instance = new ModifyFooter(
84 $this->mockTree(UI::class, ['txt' => 'translated']),
85 $this->mockTree(User::class, ['acceptedVersion' => new Error('Not found.'), 'isLoggedIn' => false]),
86 $this->mockTree(Provide::class, ['id' => 'foo']),
87 fn() => 'rendered',
88 fn() => $this->mock(ilTemplate::class),
89 fn() => $dummy_uri,
90 );
91
92 $this->assertSame($return, $instance($footer));
93 }
94
95 public function testRenderModal(): void
96 {
97 $instance = new ModifyFooter(
98 $this->mock(UI::class),
99 $this->mock(User::class),
100 $this->mock(Provide::class),
101 fn() => 'rendered',
102 fn() => $this->mock(ilTemplate::class),
103 null
104 );
105
106 $modal = $instance->renderModal($this->mock(DocumentContent::class));
107 $this->assertInstanceOf(Modal::class, $modal);
108 }
109
110 public function testWithdrawalButton(): void
111 {
112 $template = $this->mock(ilTemplate::class);
113 $template->expects(self::exactly(3))->method('setVariable');
114 $template->expects(self::once())->method('get');
115
116 $instance = new ModifyFooter(
117 $this->mock(UI::class),
118 $this->mock(User::class),
119 $this->mock(Provide::class),
120 fn() => 'rendered',
121 fn() => $template,
122 null
123 );
124
125 $this->assertInstanceOf(Component::class, $instance->withdrawalButton());
126 }
127}
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
A result encapsulates a value or an error and simplifies the handling of those.
Definition: Ok.php:31
The scope of this class is split ilias-conform URI's into components.
Definition: URI.php:35
special template class to simplify handling of ITX/PEAR
A component is the most general form of an entity in the UI.
Definition: Component.php:28
This describes commonalities between the different modals.
Definition: Modal.php:35