19 declare(strict_types=1);
44 private array $services = [
45 ilAccess::class =>
'ilAccess',
46 ilAccessHandler::class =>
'ilAccess',
47 ilOrgUnitPositionAndRBACAccessHandler::class =>
'ilAccess',
48 ilOrgUnitPositionAccessHandler::class =>
'ilAccess',
49 ilRBACAccessHandler::class =>
'ilAccess',
50 DataFactory::class =>
'DataFactory',
51 ilGlobalPageTemplate::class =>
'tpl',
52 ilGlobalTemplateInterface::class =>
'tpl',
53 ilDBInterface::class =>
'ilDB',
54 ilBenchmark::class =>
'ilBench',
55 ilObjUser::class =>
'ilUser',
56 ilErrorHandling::class =>
'ilErr',
57 ilTree::class =>
'tree',
58 ilLanguage::class =>
'lng',
59 Language::class =>
'lng',
60 ilAppEventHandler::class =>
'ilAppEventHandler',
61 ilObjectDefinition::class =>
'objDefinition',
62 RefineryFactory::class =>
'refinery',
63 ilRbacSystem::class =>
'rbacsystem',
64 ilRbacReview::class =>
'rbacreview',
65 ilRbacAdmin::class =>
'rbacadmin',
66 HTTPServices::class =>
'http',
67 GlobalHttpState::class =>
'http',
68 ilComponentFactory::class =>
'component.factory',
69 ilComponentRepository::class =>
'component.repository',
70 ImplementationFactory::class =>
'ui.factory',
71 UIFactory::class =>
'ui.factory',
72 ImplementationDefaultRenderer::class =>
'ui.renderer',
73 UIRenderer::class =>
'ui.renderer',
74 ilUIService::class =>
'uiService',
75 StaticURLServices::class =>
'static_url',
76 FileUpload::class =>
'upload',
77 ilLogger::class =>
'ilLog',
78 ilSetting::class =>
'ilSetting',
79 Setting::class =>
'ilSetting',
80 ilCtrl::class =>
'ilCtrl',
81 ilCtrlInterface::class =>
'ilCtrl',
82 ilObjectDataCache::class =>
'ilObjDataCache',
83 ilHelpGUI::class =>
'ilHelp',
84 ilCtrlBaseClassInterface::class =>
'ilHelp',
85 ilTabsGUI::class =>
'ilTabs',
86 ilLocatorGUI::class =>
'ilLocator',
87 ilToolbarGUI::class =>
'ilToolbar',
88 ilObjectCustomIconFactory::class =>
'object.customicons.factory',
89 Filesystems::class =>
'filesystem',
90 ilObjTest::class =>
'ilObjTest',
91 \ILIAS\Cache\Services::class =>
'global_cache',
96 if (!defined(
'ILIAS_HTTP_PATH')) {
97 define(
'ILIAS_HTTP_PATH',
'http://localhost');
99 if (!defined(
'CLIENT_DATA_DIR')) {
100 define(
'CLIENT_DATA_DIR',
'/var/iliasdata');
102 if (!defined(
'IL_INST_ID')) {
103 define(
'IL_INST_ID',
'0');
105 if (!defined(
'ANONYMOUS_USER_ID')) {
106 define(
'ANONYMOUS_USER_ID', 13);
108 if (!defined(
'ANONYMOUS_USER_ID')) {
109 define(
'ANONYMOUS_USER_ID', 13);
111 if (!defined(
'ROOT_FOLDER_ID')) {
112 define(
'ROOT_FOLDER_ID', 8);
114 if (!defined(
'ILIAS_LOG_ENABLED')) {
115 define(
'ILIAS_LOG_ENABLED',
true);
117 if (!defined(
'ILIAS_LOG_DIR')) {
118 define(
'ILIAS_LOG_DIR',
'/var/log');
120 if (!defined(
'ILIAS_LOG_FILE')) {
121 define(
'ILIAS_LOG_FILE',
'/var/log/ilias.log');
136 $DIC[$name] =
static function (
Container $c) use ($value) {
146 return $this->createMock(ilTemplate::class);
154 return $this->createMock(ilDBInterface::class);
162 $mock = $this->createMock(ILIAS::class);
166 $account->fullname =
'Esther Tester';
168 $mock->account = $account;
169 $mock->ini_ilias = $this->createMock(ilIniFile::class);
191 $this->
setGlobalVariable(
'objDefinition', $this->createMock(ilObjectDefinition::class));
241 $db = $this->createMock(ilDBInterface::class);
243 ->method(
'loadModule')
244 ->willReturnCallback(
246 return match ($module) {
284 $this->
setGlobalVariable(
'ilNavigationHistory', $this->createMock(ilNavigationHistory::class));
289 $this->
setGlobalVariable(
'ilAppEventHandler', $this->createMock(ilAppEventHandler::class));
299 $this->
setGlobalVariable(
'component.repository', $this->createMock(ilComponentRepository::class));
304 $this->
setGlobalVariable(
'component.factory', $this->createMock(ilComponentFactory::class));
314 $this->
setGlobalVariable(
'ilObjDataCache', $this->createMock(ilObjectDataCache::class));
333 $request_mock = $this->getMockBuilder(\Psr\
Http\Message\ServerRequestInterface::class)
334 ->disableOriginalConstructor()
336 $request_mock->method(
'getUri')
337 ->willReturn(
new GuzzleURI(
'http://wwww.ilias.de'));
338 $http_mock = $this->getMockBuilder(HTTPServices::class)->disableOriginalConstructor()
340 $http_mock->method(
'request')
341 ->willReturn($request_mock);
352 $this->
setGlobalVariable(
'ilLoggerFactory', $this->createMock(ilLoggerFactory::class));
367 $this->
setGlobalVariable(
'ui.factory', $this->createMock(FactoryInternal::class));
377 $refineryMock = $this->getMockBuilder(RefineryFactory::class)->disableOriginalConstructor()->getMock();
378 $refineryMock->expects(self::any())->method(
'random')->willReturn($this->getMockBuilder(RandomGroup::class)->getMock());
394 $this->
setGlobalVariable(
'object.customicons.factory', $this->getMockBuilder(
ILIAS\ILIASObject\Properties\AdditionalProperties\
Icon\Factory::class)->disableOriginalConstructor()->getMock());
395 $object_mock = $this->getMockBuilder(\ilObjectService::class)->disableOriginalConstructor()->getMock();
421 new ILIAS\FileDelivery\
Token\Signer\Key\Secret\SecretKeyRotation(
422 new ILIAS\FileDelivery\
Token\Signer\Key\Secret\SecretKey(
'blup')
425 $http_mock = $this->createMock(HTTPServices::class);
426 $response_builder_mock = $this->createMock(\
ILIAS\FileDelivery\Delivery\ResponseBuilder\ResponseBuilder::class);
427 return new \ILIAS\FileDelivery\Services(
428 new ILIAS\FileDelivery\Delivery\StreamDelivery(
431 $response_builder_mock,
432 $response_builder_mock
434 new \
ILIAS\FileDelivery\Delivery\LegacyDelivery(
436 $response_builder_mock,
437 $response_builder_mock
446 return $this->createConfiguredMock(ilObjTest::class, [
453 $local_dic_mock = $this->getMockBuilder(
ILIAS\
Test\TestDIC::class)
454 ->onlyMethods([])->getMock();
455 $local_dic_mock[
'question.general_properties.repository'] = fn(Pimple\
Container $c)
456 => $this->createMock(
457 ILIAS\TestQuestionPool\Questions\GeneralQuestionPropertiesRepository::class
459 $local_dic_mock[
'request_data_collector'] = fn(Pimple\
Container $c)
460 => $this->createMock(
463 $local_dic_mock[
'participant.access_filter.factory'] = fn(Pimple\
Container $c)
464 => $this->createMock(
465 \ilTestParticipantAccessFilterFactory::class
467 $local_dic_mock[
'logging.logger'] = fn(Pimple\
Container $c)
468 => $this->createMock(
471 $local_dic_mock[
'logging.viewer'] = fn(Pimple\
Container $c)
472 => $this->createMock(
475 $local_dic_mock[
'shuffler'] = fn(Pimple\
Container $c)
476 => $this->createMock(
477 \ilTestShuffler::class
479 $local_dic_mock[
'results.presentation.factory'] = fn(Pimple\
Container $c)
480 => $this->createMock(
483 $local_dic_mock[
'results.data.factory'] = fn(Pimple\
Container $c)
484 => $this->createMock(
487 $local_dic_mock[
'results.toplist.repository'] = fn(Pimple\
Container $c)
488 => $this->createMock(
491 $local_dic_mock[
'results.data.repository'] = fn(Pimple\
Container $c)
492 => $this->createMock(
495 $local_dic_mock[
'questions.properties.repository'] = fn(Pimple\
Container $c)
496 => $this->createMock(
497 ILIAS\
Test\Questions\Properties\Repository::class
499 return $local_dic_mock;
505 if ($reflection_function->getNumberOfParameters() !== 1) {
506 throw new \Exception(
'Callable must have exactly one parameter of type MockObject.');
509 if (isset($this->services[$service_name])) {
511 if (!isset($DIC[$this->services[$service_name]])) {
512 $DIC[$this->services[$service_name]] = $this->createMock($service_name);
515 $adapt($DIC[$this->services[$service_name]]);
524 $this->dic[
'tpl']->expects($this->once())->method(
'setContent')->with($expected_content);
529 $this->dic[
'ilCtrl']->method(
'getCmd')->willReturn($command);
534 $this->dic[
'ilCtrl']->expects($expects)->method(
'redirect')->with($this->anything(), $this->equalTo($method));
537 public function mockPostRequest(array $properties, array $query_parameters = []): void
539 $this->
mockRequest(
'POST', $properties, $query_parameters);
547 private function mockRequest(
string $request_method, array $properties, array $query_parameters): void
549 $_SERVER[
'REQUEST_METHOD'] = $request_method;
550 $request = $this->createConfiguredMock(ServerRequestInterface::class, [
551 'getServerParams' => [
'REQUEST_METHOD' => $request_method],
552 'getParsedBody' => $properties,
553 'getQueryParams' => $query_parameters
555 $this->dic[
'http']->method(
'request')->willReturn($request);
556 $this->dic[
'http']->method(
'wrapper')->willReturn(
new WrapperFactory($request));
addGlobal_ilAppEventHandler()
addGlobal_ilComponentFactory()
expectRedirect(InvocationOrder $expects, string $method)
Interface Observer Contains several chained tasks and infos about them.
addGlobal_objectService()
mockRequest(string $request_method, array $properties, array $query_parameters)
Customizing of pimple-DIC for ILIAS.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
adaptDICServiceMock(string $service_name, callable $adapt)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
mockGetRequest(array $query_parameters=[])
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
addGlobal_resourceStorage()
addGlobal_ilLoggerFactory()
addGlobal_ilNavigationHistory()
mockPostRequest(array $properties, array $query_parameters=[])
expectTplContent(mixed $expected_content)
Expect that the template content will be set to the specified expected content.
addGlobal_objDefinition()
addGlobal_ilObjDataCache()
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setGlobalVariable(string $name, mixed $value)
addGlobal_ilComponentRepository()
addGlobal_ilIliasIniFile()
addGlobal_GlobalScreenService()
addGlobal_uiUploadLimitResolver()
mockCommand(string $command)
addGlobal_objectMetadata()