ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
SystemStylesGlobalScreenToolProviderTest.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
21 require_once('libs/composer/vendor/autoload.php');
22 include_once('./tests/UI/UITestHelper.php');
23 
25 
28 use ILIAS\Data\URI;
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 
70  $DIC = $this->dic;
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 }
Class ChatMainBarProvider .
Container storing a list of UI Component Entries, can act as Iterator, countable and is serializable...
Provider for the Tree in the Main Bar Slate showing the UI Components.
Customizing of pimple-DIC for ILIAS.
Definition: Container.php:31
Class ContextRepository The Collection of all available Contexts in the System.
global $DIC
Definition: feed.php:28
Stores Information of UI Components parsed from YAML, examples and less files.
The scope of this class is split ilias-conform URI&#39;s into components.
Definition: URI.php:34
Class IdentificationFactory All elements in the GlobalScreen service must be identifiable for the sup...
Class UITestHelper can be helpful for test cases outside the UI Components, to inject a working facto...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...