33 require_once
"Base.php";
44 private \ilCtrlInterface|MockObject
$ctrl;
52 protected function setUp(): void
54 $this->
ctrl = $this->createMock(\ilCtrlInterface::class);
55 $this->http_mock = $this->createMock(Services::class);
56 $this->request_mock = $this->createMock(ServerRequestInterface::class);
57 $this->http_mock->method(
'request')->willReturn($this->request_mock);
59 $this->component_factory_mock = $this->createMock(\ilComponentFactory::class);
63 $this->createMock(\ilLanguage::class),
72 $this->request_mock->method(
'getQueryParams')->willReturn($params);
73 $this->http_mock->method(
'wrapper')->willReturn(
new WrapperFactory($this->request_mock));
79 [
'https://ilias.domain/goto.php?client_id=unittest&target=impr',
'impr'],
80 [
'https://ilias.domain/goto.php?target=root_1&client_id=unittest',
'root_1'],
81 [
'https://ilias.domain/go/root/1',
'root_1'],
82 [
'https://ilias.domain/goto.php?target=root_1&client_id=unittest&lang=de',
'root_1'],
83 [
'https://ilias.domain/sub/goto.php?target=root_1&client_id=unittest&lang=de',
'root_1'],
84 [
'https://ilias.domain/goto.php?target=crs_256&client_id=unittest&lang=de',
'crs_256'],
85 [
'https://ilias.domain/goto.php?target=lorem_256&client_id=unittest&lang=de',
'lorem_256'],
86 [
'https://ilias.domain/goto.php?target=wiki_wpage_4826_86154&client_id=unittest&lang=de',
'wiki_wpage_4826_86154'],
87 [
'https://ilias.domain/sub/goto.php?target=wiki_wpage_4826_86154&client_id=unittest&lang=de',
'wiki_wpage_4826_86154'],
88 [
'https://ilias.domain/goto.php/wiki/wpage_4826_86154',
'wiki_wpage_4826_86154'],
89 [
'https://ilias.domain/go/wiki/wpage_4826_86154',
'wiki_wpage_4826_86154'],
90 [
'https://ilias.domain/sub/goto.php/wiki/wpage_4826_86154',
'wiki_wpage_4826_86154'],
91 [
'https://ilias.domain/sub/go/wiki/wpage_4826_86154',
'wiki_wpage_4826_86154'],
95 #[DataProvider('urlProvider')] 96 public function testBase(
string $called_url,
string $target): void
98 $this->http_mock->request()->method(
'getUri')->willReturn(
new \
GuzzleHttp\Psr7\Uri($called_url));
99 $this->assertEquals($called_url, $this->http_mock->request()->getUri());
101 $uri =
new URI($called_url);
106 $request = $this->request_builder->buildRequest(
112 $this->assertInstanceOf(Request::class, $request);
113 $this->assertTrue($this->subject->canHandle($request));
118 private function insertDIC(
string $key,
object $value): void
122 if (isset($DIC[$key])) {
123 $this->dic_backup[$key] = clone $DIC[$key];
126 $DIC->offsetUnset($key);
134 foreach ($this->dic_backup as $key => $value) {
135 $DIC->offsetUnset($key);
143 $this->
insertDIC(
'component.factory', $this->component_factory_mock);
145 $access_mock = $this->createMock(\ilAccessHandler::class);
146 $access_mock->method(
'checkAccess')->willReturn(
true);
147 $this->
insertDIC(
'ilAccess', $access_mock);
148 $this->
insertDIC(
'objDefinition', $this->createMock(\ilObjectDefinition::class));
149 $user_mock = $this->createMock(\ilObjUser::class);
150 $user_mock->method(
'getId')->willReturn(42);
152 $this->
insertDIC(
'http', $this->http_mock);
153 $this->
insertDIC(
'tpl', $this->createMock(\ilGlobalTemplateInterface::class));
154 $this->
insertDIC(
'lng', $this->createMock(\ilLanguage::class));
155 $this->
insertDIC(
'ilObjDataCache', $this->createMock(\ilObjectDataCache::class));
156 $this->
insertDIC(
'ilDB', $this->createMock(\ilDBInterface::class));
157 $this->
insertDIC(
'tree', $this->createMock(\ilTree::class));
158 $this->
insertDIC(
'rbacreview', $this->createMock(\ilRbacReview::class));
159 $this->
insertDIC(
'ilSetting', $this->createMock(\ilSetting::class));
160 $this->
insertDIC(
'ilErr', $this->createMock(\ilErrorHandling::class));
163 if (!defined(
'ROOT_FOLDER_ID')) {
164 define(
'ROOT_FOLDER_ID', 1);
167 if (!defined(
'ANONYMOUS_USER_ID')) {
168 define(
'ANONYMOUS_USER_ID', 13);
insertDIC(string $key, object $value)
if(! $DIC->user() ->getId()||!ilLTIConsumerAccess::hasCustomProviderCreationAccess()) $params
Interface Observer Contains several chained tasks and infos about them.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
testBase(string $called_url, string $target)
updateRequestAndWrapperMockWithParams(array $params)
Customizing of pimple-DIC for ILIAS.
LegacyGotoHandler $subject
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Services MockObject $http_mock
MockObject $component_factory_mock
ilCtrlInterface MockObject $ctrl