ILIAS  release_8 Revision v8.24
InitUIFrameworkTest.php
Go to the documentation of this file.
1<?php
2
3require_once("libs/composer/vendor/autoload.php");
4
6use PHPUnit\Framework\TestCase;
7
8class InitUIFrameworkTest extends TestCase
9{
13 protected $dic;
14
18 protected function setUp(): void
19 {
20 $this->dic = new \ILIAS\DI\Container();
21
22 $this->dic["lng"] = Mockery::mock("\ilLanguage");
23 $this->dic["lng"]->shouldReceive("loadLanguageModule");
24 $this->dic["tpl"] = Mockery::mock("\ilGlobalTemplateInterface");
25 $this->dic["refinery"] = Mockery::mock("\ILIAS\Refinery\Factory");
26 }
27
28 public function testUIFrameworkInitialization(): void
29 {
30 $this->assertInstanceOf("\ILIAS\DI\UIServices", $this->dic->ui());
31 $this->assertFalse(isset($this->dic['ui.factory']));
32 $this->assertFalse(isset($this->dic['ui.renderer']));
33 (new \InitUIFramework())->init($this->dic);
34 $this->assertTrue(isset($this->dic['ui.factory']));
35 $this->assertTrue(isset($this->dic['ui.renderer']));
36 $this->assertInstanceOf("\ILIAS\UI\Factory", $this->dic->ui()->factory());
37 $this->assertInstanceOf("\ILIAS\UI\Renderer", $this->dic->ui()->renderer());
38 }
39
44 public function testByExampleThatFactoryIsLoaded(): void
45 {
46 (new \InitUIFramework())->init($this->dic);
47
48 $this->assertInstanceOf(
49 "ILIAS\UI\Implementation\Component\Divider\Vertical",
50 $this->dic->ui()->factory()->divider()->vertical()
51 );
52 }
53
60 {
61 (new \InitUIFramework())->init($this->dic);
62 $this->dic["tpl"]->shouldReceive("addJavaScript");
63
64 //Note, this dep is not properly injected ilTemplate, therefore we need to hit on the global.
65 global $DIC;
66 $initial_state = $DIC;
67 $DIC = new \ILIAS\DI\Container();
68
69 $example_componanent = $this->dic->ui()->factory()->divider()->vertical();
70 $example_out = $this->dic->ui()->renderer()->render($example_componanent);
71 $this->assertIsString($example_out);
72 $DIC = $initial_state;
73 }
74}
Builds data types.
Definition: Factory.php:21
setUp()
Several dependencies need to be wired up before the UI Framework can be initialised.
testByExampleThatFactoryIsLoaded()
This checks only by example that the factory is loaded and ready to work.
testByExampleThatRendererIsReadyToWork()
This checks only by example that the renderer is all up and ready to work.
global $DIC
Definition: feed.php:28