ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
ShowOnLoginPageTest.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
31 use ilTemplate;
32 
33 require_once __DIR__ . '/../../ContainerMock.php';
34 
35 class ShowOnLoginPageTest extends TestCase
36 {
37  use ContainerMock;
38 
39  public function testConstruct(): void
40  {
41  $this->assertInstanceOf(ShowOnLoginPage::class, new ShowOnLoginPage($this->mock(Provide::class), $this->mock(UI::class), $this->fail(...)));
42  }
43 
44  public function testInvokeWithoutDocuments(): void
45  {
46  $instance = new ShowOnLoginPage($this->mockTree(Provide::class, [
47  'document' => ['repository' => ['countAll' => 0]],
48  ]), $this->mock(UI::class), $this->fail(...));
49 
50  $this->assertSame([], $instance());
51  }
52 
53  public function testInvoke(): void
54  {
55  $translated = 'Translated<br/>';
56  $url = 'Dummy URL';
57  $legacy = $this->mock(Legacy::class);
58 
59  $template = $this->mock(ilTemplate::class);
60  $template->expects(self::exactly(2))->method('setVariable')->withConsecutive(['LABEL', htmlentities($translated)], ['HREF', $url]);
61  $template->expects(self::once())->method('get')->willReturn('Rendered');
62 
63  $instance = new ShowOnLoginPage($this->mockTree(Provide::class, [
64  'document' => ['repository' => ['countAll' => 1]],
65  'publicPage' => ['url' => $url],
66  ]), $this->mockTree(UI::class, [
67  'txt' => $translated,
68  'create' => $this->mockMethod(UIFactory::class, 'legacy', ['Rendered'], $legacy),
69  ]), fn() => $template);
70 
71  $array = $instance();
72 
73  $this->assertSame(1, count($array));
74  $this->assertSame($legacy, $array[0]);
75  }
76 }
$url
Definition: ltiregstart.php:35