ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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;
25
35
37{
39 protected array $entries_data;
40 protected Entries $entries;
41 protected Entry $entry;
42 protected array $entry_data;
43 protected URI $test_uri;
45 protected Container $dic;
46
47 protected function setUp(): void
48 {
49 global $DIC;
50
51 $this->dic = new Container();
52 $this->dic = (new UITestHelper())->init($this->dic);
53
54 $this->dic['ilCtrl'] = $this->getMockBuilder(ilCtrl::class)->disableOriginalConstructor()->onlyMethods([
55 'getLinkTargetByClass'
56 ])->getMock();
57 $this->dic['ilCtrl']->method('getLinkTargetByClass')->willReturn('1');
58
59 (new InitHttpServices())->init($this->dic);
60
61 $this->dic['global_screen'] = $this
62 ->getMockBuilder(ILIAS\GlobalScreen\Services::class)
63 ->disableOriginalConstructor()
64 ->onlyMethods(['identification'])
65 ->getMock();
66 $provider_factory = $this->getMockBuilder(ProviderFactory::class)->getMock();
67 $identification = new IdentificationFactory($provider_factory);
68 $this->dic['global_screen']->method('identification')->willReturn($identification);
69
71 $this->tool_provider = new SystemStylesGlobalScreenToolProvider($this->dic);
72
73 if (!defined('ILIAS_HTTP_PATH')) {
74 define('ILIAS_HTTP_PATH', 'http://localhost');
75 }
76 }
77
78 public function testConstruct(): void
79 {
80 $this->assertInstanceOf('SystemStylesGlobalScreenToolProvider', $this->tool_provider);
81 }
82
83 public function testIsInterestedInContexts(): void
84 {
85 $this->assertEquals(
86 ['administration'],
87 $this->tool_provider->isInterestedInContexts()->getStackAsArray()
88 );
89 }
90
91 public function testBuildTreeAsToolNotInContext(): void
92 {
93 $contexts = new CalledContexts(new ContextRepository());
94 $this->assertEquals([], $this->tool_provider->getToolsForContextStack($contexts));
95 }
96
98 {
99 $contexts = (new CalledContexts(new ContextRepository()))->administration();
100 $this->assertEquals([], $this->tool_provider->getToolsForContextStack($contexts));
101 }
102
104 {
105 $tree_available_context = (new ILIAS\GlobalScreen\ScreenContext\BasicScreenContext('administration'))->addAdditionalData(ilSystemStyleDocumentationGUI::SHOW_TREE, true);
106 $contexts = new CalledContexts(new ContextRepository());
107 $contexts->push($tree_available_context);
108 $tools = $this->tool_provider->getToolsForContextStack($contexts);
109 $this->assertCount(1, $tools);
110 $tool = array_pop($tools);
111 $this->assertInstanceOf(Tool::class, $tool);
112 $this->assertEquals('documentation', $tool->getTitle());
113 }
114}
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