ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
ModifyFooterTest.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
23 use ILIAS\Data\URI;
27 use ilTemplate;
36 use Closure;
38 
39 require_once __DIR__ . '/../../ContainerMock.php';
40 
41 class ModifyFooterTest extends TestCase
42 {
43  use ContainerMock;
44 
45  public function testConstruct(): void
46  {
47  $this->assertInstanceOf(ModifyFooter::class, new ModifyFooter(
48  $this->mock(UI::class),
49  $this->mock(User::class),
50  $this->mock(Provide::class),
51  $this->fail(...),
52  $this->fail(...),
53  null,
54  ));
55  }
56 
57  public function testInvoke(): void
58  {
59  $return = fn() => null;
60  $footer = fn() => $return;
61 
62  $instance = new ModifyFooter(
63  $this->mock(UI::class),
64  $this->mockTree(User::class, ['acceptedVersion' => new Ok($this->mock(DocumentContent::class))]),
65  $this->mock(Provide::class),
66  fn() => 'rendered',
67  fn() => $this->mock(ilTemplate::class),
68  null,
69  );
70 
71  $this->assertSame($return, $instance($footer));
72  }
73 
74  public function testInvokeWithGotoLink(): void
75  {
76  $dummy_uri = $this->mock(URI::class);
77  $return = fn() => null;
78  $footer = function ($id, $title, $uri) use ($dummy_uri, $return) {
79  $this->assertSame('foo', $id);
80  $this->assertSame('translated', $title);
81  $this->assertSame($dummy_uri, $uri);
82  return $return;
83  };
84 
85  $instance = new ModifyFooter(
86  $this->mockTree(UI::class, ['txt' => 'translated']),
87  $this->mockTree(User::class, ['acceptedVersion' => new Error('Not found.'), 'isLoggedIn' => false]),
88  $this->mockTree(Provide::class, ['id' => 'foo']),
89  fn() => 'rendered',
90  fn() => $this->mock(ilTemplate::class),
91  fn() => $dummy_uri,
92  );
93 
94  $this->assertSame($return, $instance($footer));
95  }
96 
97  public function testRenderModal(): void
98  {
99  $instance = new ModifyFooter(
100  $this->mock(UI::class),
101  $this->mock(User::class),
102  $this->mock(Provide::class),
103  fn() => 'rendered',
104  fn() => $this->mock(ilTemplate::class),
105  null
106  );
107 
108  $modal = $instance->renderModal($this->mock(DocumentContent::class));
109  $this->assertInstanceOf(Modal::class, $modal);
110  }
111 
112  public function testWithdrawalButton(): void
113  {
114  $template = $this->mock(ilTemplate::class);
115  $template->expects(self::exactly(3))->method('setVariable');
116  $template->expects(self::once())->method('get');
117 
118  $instance = new ModifyFooter(
119  $this->mock(UI::class),
120  $this->mock(User::class),
121  $this->mock(Provide::class),
122  fn() => 'rendered',
123  fn() => $template,
124  null
125  );
126 
127  $this->assertInstanceOf(Component::class, $instance->withdrawalButton());
128  }
129 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
A result encapsulates a value or an error and simplifies the handling of those.
Definition: Ok.php:16
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23