ILIAS  trunk Revision v11.0_alpha-1715-g7fc467680fb
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilScorm2004BaseTestCase.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
29 use ILIAS\Refinery\Random\Group as RandomGroup;
30 
37 {
38  protected Container $dic;
39 
43  protected function setUp(): void
44  {
45  $this->dic = new Container();
46  $GLOBALS['DIC'] = $this->dic;
47 
48  parent::setUp();
49  }
50 
51  protected function setGlobalVariable(string $name, mixed $value): void
52  {
53  global $DIC;
54 
55  $GLOBALS[$name] = $value;
56 
57  unset($DIC[$name]);
58  $DIC[$name] = static fn(\ILIAS\DI\Container $c) => $value;
59  }
60 
61  protected function getGlobalTemplateMock(): MockObject
62  {
63  return $this->getMockBuilder(ilTemplate::class)->disableOriginalConstructor()->getMock();
64  }
65 
66  protected function getDatabaseMock(): MockObject
67  {
68  return $this->getMockBuilder(ilDBInterface::class)->disableOriginalConstructor()->getMock();
69  }
70 
71  protected function getIliasMock(): MockObject
72  {
73  $mock = $this->getMockBuilder(ILIAS::class)->disableOriginalConstructor()->getMock();
74 
75  $account = new stdClass();
76  $account->id = 6;
77  $account->fullname = 'Esther Tester';
78 
79  $mock->account = $account;
80 
81  return $mock;
82  }
83 
84  protected function addGlobal_ilAccess(): void
85  {
86  $this->setGlobalVariable("ilAccess", $this->createMock(ilAccess::class));
87  }
88 
89  protected function addGlobal_ilUser(): void
90  {
91  $this->setGlobalVariable("ilUser", $this->createMock(ilObjUser::class));
92  }
93 
94  protected function addGlobal_objDefinition(): void
95  {
96  $this->setGlobalVariable("objDefinition", $this->createMock(ilObjectDefinition::class));
97  }
98 
99  protected function addGlobal_tree(): void
100  {
101  $this->setGlobalVariable("tree", $this->createMock(ilTree::class));
102  }
103 
104  protected function addGlobal_ilSetting(): void
105  {
106  $this->setGlobalVariable("ilSetting", $this->createMock(ilSetting::class));
107  }
108 
109  protected function addGlobal_rbacsystem(): void
110  {
111  $this->setGlobalVariable("rbacsystem", $this->createMock(ilRbacSystem::class));
112  }
113 
114  protected function addGlobal_ilCtrl(): void
115  {
116  $this->setGlobalVariable("ilCtrl", $this->createMock(ilCtrl::class));
117  }
118 
119  protected function addGlobal_lng(): void
120  {
121  $this->setGlobalVariable("lng", $this->createMock(ilLanguage::class));
122  }
123 
124  protected function addGlobal_filesystem(): void
125  {
126  $this->setGlobalVariable("filesystem", $this->createMock(Filesystems::class));
127  }
128 
129  protected function addGlobal_upload(): void
130  {
131  $this->setGlobalVariable("upload", $this->createMock(FileUpload::class));
132  }
133 
134  protected function addGlobal_ilDB(): void
135  {
136  $this->setGlobalVariable("ilDB", $this->createMock(ilDBInterface::class));
137  }
138 
139  protected function addGlobal_ilLog(): void
140  {
141  $this->setGlobalVariable("ilLog", $this->createMock(ilLogger::class));
142  }
143 
144  protected function addGlobal_ilias(): void
145  {
146  $this->setGlobalVariable("ilias", $this->getIliasMock());
147  }
148 
149  protected function addGlobal_ilErr(): void
150  {
151  $this->setGlobalVariable("ilErr", $this->createMock(ilErrorHandling::class));
152  }
153 
154  protected function addGlobal_ilAppEventHandler(): void
155  {
156  $this->setGlobalVariable("ilAppEventHandler", $this->createMock(ilAppEventHandler::class));
157  }
158 
159  protected function addGlobal_tpl(): void
160  {
161  $this->setGlobalVariable("tpl", $this->createMock(ilGlobalPageTemplate::class));
162  }
163 
164  protected function addGlobal_ilPluginAdmin(): void
165  {
166  $this->setGlobalVariable("ilPluginAdmin", $this->createMock(ilPluginAdmin::class));
167  }
168 
169  protected function addGlobal_ilTabs(): void
170  {
171  $this->setGlobalVariable("ilTabs", $this->createMock(ilTabsGUI::class));
172  }
173 
174  protected function addGlobal_ilObjDataCache(): void
175  {
176  $this->setGlobalVariable("ilObjDataCache", $this->createMock(ilObjectDataCache::class));
177  }
178 
179  protected function addGlobal_ilLocator(): void
180  {
181  $this->setGlobalVariable("ilLocator", $this->createMock(ilLocatorGUI::class));
182  }
183 
184  protected function addGlobal_rbacreview(): void
185  {
186  $this->setGlobalVariable("rbacreview", $this->createMock(ilRbacReview::class));
187  }
188 
189  protected function addGlobal_ilToolbar(): void
190  {
191  $this->setGlobalVariable("ilToolbar", $this->createMock(ilToolbarGUI::class));
192  }
193 
194  protected function addGlobal_http(): void
195  {
196  $this->setGlobalVariable("http", $this->createMock(Services::class));
197  }
198 
199  protected function addGlobal_ilIliasIniFile(): void
200  {
201  $this->setGlobalVariable("ilIliasIniFile", $this->createMock(ilIniFile::class));
202  }
203 
204  protected function addGlobal_ilLoggerFactory(): void
205  {
206  $this->setGlobalVariable("ilLoggerFactory", $this->createMock(ilLoggerFactory::class));
207  }
208 
209  protected function addGlobal_ilHelp(): void
210  {
211  $this->setGlobalVariable("ilHelp", $this->createMock(ilHelp::class));
212  }
213 
214  protected function addGlobal_uiFactory(): void
215  {
216  $this->setGlobalVariable("ui.factory", $this->createMock(FactoryInternal::class));
217  }
218 
219  protected function addGlobal_uiRenderer(): void
220  {
221  $this->setGlobalVariable("ui.renderer", $this->createMock(ILIAS\UI\Implementation\DefaultRenderer::class));
222  }
223 
224  protected function addGlobal_refinery(): void
225  {
226  $refineryMock = $this->getMockBuilder(RefineryFactory::class)->disableOriginalConstructor()->getMock();
227  $refineryMock->expects(self::any())->method('random')->willReturn($this->getMockBuilder(RandomGroup::class)->getMock());
228  $this->setGlobalVariable("refinery", $refineryMock);
229  }
230 }
Interface Observer Contains several chained tasks and infos about them.
$c
Definition: deliver.php:25
Customizing of pimple-DIC for ILIAS.
Definition: Container.php:35
Class ilScorm2004BaseTestCase.
setGlobalVariable(string $name, mixed $value)
$GLOBALS["DIC"]
Definition: wac.php:53
Class HTTPServicesTest.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: shib_login.php:22