ILIAS  trunk Revision v12.0_alpha-1540-g00f839d5fa1
SystemStylesGlobalScreenToolProviderTest.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21require_once('vendor/composer/vendor/autoload.php');
22include_once('./components/ILIAS/UI/tests/UITestHelper.php');
23
24use PHPUnit\Framework\TestCase;
34
36{
38 protected array $entries_data;
39 protected Entries $entries;
40 protected Entry $entry;
41 protected array $entry_data;
42 protected URI $test_uri;
44 protected Container $dic;
45
46 protected function setUp(): void
47 {
48 global $DIC;
49
50 $this->dic = new Container();
51 $this->dic = (new UITestHelper())->init($this->dic);
52
53 $this->dic['ilCtrl'] = $this->getMockBuilder(ilCtrl::class)->disableOriginalConstructor()->onlyMethods([
54 'getLinkTargetByClass'
55 ])->getMock();
56 $this->dic['ilCtrl']->method('getLinkTargetByClass')->willReturn('1');
57
58 (new InitHttpServices())->init($this->dic);
59
60 $this->dic['global_screen'] = $this
61 ->getMockBuilder(ILIAS\GlobalScreen\Services::class)
62 ->disableOriginalConstructor()
63 ->onlyMethods(['identification'])
64 ->getMock();
65 $provider_factory = $this->getMockBuilder(ProviderFactory::class)->getMock();
66 $identification = new IdentificationFactory($provider_factory);
67 $this->dic['global_screen']->method('identification')->willReturn($identification);
68
70 $this->tool_provider = new SystemStylesGlobalScreenToolProvider($this->dic);
71
72 if (!defined('ILIAS_HTTP_PATH')) {
73 define('ILIAS_HTTP_PATH', 'http://localhost');
74 }
75 }
76
77 public function testConstruct(): void
78 {
79 $this->assertInstanceOf('SystemStylesGlobalScreenToolProvider', $this->tool_provider);
80 }
81
82 public function testIsInterestedInContexts(): void
83 {
84 $this->assertEquals(
85 ['administration'],
86 $this->tool_provider->isInterestedInContexts()->getStackAsArray()
87 );
88 }
89
90 public function testBuildTreeAsToolNotInContext(): void
91 {
92 $contexts = new CalledContexts(new ContextRepository());
93 $this->assertEquals([], $this->tool_provider->getToolsForContextStack($contexts));
94 }
95
97 {
98 $contexts = (new CalledContexts(new ContextRepository()))->administration();
99 $this->assertEquals([], $this->tool_provider->getToolsForContextStack($contexts));
100 }
101
103 {
104 $tree_available_context = (new ILIAS\GlobalScreen\ScreenContext\BasicScreenContext('administration'))->addAdditionalData(ilSystemStyleDocumentationGUI::SHOW_TREE, true);
105 $contexts = new CalledContexts(new ContextRepository());
106 $contexts->push($tree_available_context);
107 $tools = $this->tool_provider->getToolsForContextStack($contexts);
108 $this->assertCount(1, $tools);
109 $tool = array_pop($tools);
110 $this->assertInstanceOf(Tool::class, $tool);
111 $this->assertEquals('documentation', $tool->getTitle());
112 }
113}
trait UITestHelper
Class UITestHelper can be helpful for test cases outside the UI Components, to inject a working facto...
Customizing of pimple-DIC for ILIAS.
Definition: Container.php:36
The scope of this class is split ilias-conform URI's into components.
Definition: URI.php:35
Class IdentificationFactory All elements in the GlobalScreen service must be identifiable for the sup...
The Collection of all available Contexts in the System.
Container storing a list of UI Component Entries, can act as Iterator, countable and is serializable.
Stores Information of UI Components parsed from YAML, examples and less files.
Responsible for loading the HTTP Service into the dependency injection container of ILIAS.
Provider for the Tree in the Main Bar Slate showing the UI Components.
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.
global $DIC
Definition: shib_login.php:26