30 require_once
"Base.php";
41 private \ilCtrlInterface|\PHPUnit\Framework\MockObject\MockObject
$ctrl;
46 private \ILIAS\HTTP\Services|\PHPUnit\Framework\MockObject\MockObject
$http_mock;
49 protected function setUp(): void
51 $this->
ctrl = $this->createMock(\ilCtrlInterface::class);
52 $this->http_mock = $this->createMock(\
ILIAS\
HTTP\Services::class);
53 $this->request_mock = $this->createMock(ServerRequestInterface::class);
54 $this->http_mock->method(
'request')->willReturn($this->request_mock);
56 $this->component_factory_mock = $this->createMock(\ilComponentFactory::class);
60 $this->createMock(\ilLanguage::class),
69 $this->request_mock->method(
'getQueryParams')->willReturn($params);
70 $this->http_mock->method(
'wrapper')->willReturn(
new WrapperFactory($this->request_mock));
76 [
'https://ilias.domain/goto.php?client_id=unittest&target=impr',
'impr'],
77 [
'https://ilias.domain/goto.php?target=root_1&client_id=unittest',
'root_1'],
78 [
'https://ilias.domain/go/root/1',
'root_1'],
79 [
'https://ilias.domain/goto.php?target=root_1&client_id=unittest&lang=de',
'root_1'],
80 [
'https://ilias.domain/sub/goto.php?target=root_1&client_id=unittest&lang=de',
'root_1'],
81 [
'https://ilias.domain/goto.php?target=crs_256&client_id=unittest&lang=de',
'crs_256'],
82 [
'https://ilias.domain/goto.php?target=lorem_256&client_id=unittest&lang=de',
'lorem_256'],
83 [
'https://ilias.domain/goto.php?target=wiki_wpage_4826_86154&client_id=unittest&lang=de',
'wiki_wpage_4826_86154'],
84 [
'https://ilias.domain/sub/goto.php?target=wiki_wpage_4826_86154&client_id=unittest&lang=de',
'wiki_wpage_4826_86154'],
85 [
'https://ilias.domain/goto.php/wiki/wpage_4826_86154',
'wiki_wpage_4826_86154'],
86 [
'https://ilias.domain/go/wiki/wpage_4826_86154',
'wiki_wpage_4826_86154'],
87 [
'https://ilias.domain/sub/goto.php/wiki/wpage_4826_86154',
'wiki_wpage_4826_86154'],
88 [
'https://ilias.domain/sub/go/wiki/wpage_4826_86154',
'wiki_wpage_4826_86154'],
95 public function testBase(
string $called_url,
string $target): void
97 $this->http_mock->request()->method(
'getUri')->willReturn(
new \
GuzzleHttp\Psr7\Uri($called_url));
98 $this->assertEquals($called_url, $this->http_mock->request()->getUri());
100 $uri =
new URI($called_url);
105 $request = $this->request_builder->buildRequest(
111 $this->assertInstanceOf(Request::class, $request);
112 $this->assertTrue($this->subject->canHandle($request));
121 if (isset($DIC[$key])) {
122 $this->dic_backup[$key] = clone $DIC[$key];
125 $DIC->offsetUnset($key);
126 $DIC[$key] =
static function () use ($value) {
135 foreach ($this->dic_backup as $key => $value) {
136 $DIC->offsetUnset($key);
144 $this->
insertDIC(
'component.factory', $this->component_factory_mock);
146 $access_mock = $this->createMock(\ilAccessHandler::class);
147 $access_mock->method(
'checkAccess')->willReturn(
true);
148 $this->
insertDIC(
'ilAccess', $access_mock);
149 $this->
insertDIC(
'objDefinition', $this->createMock(\ilObjectDefinition::class));
150 $user_mock = $this->createMock(\ilObjUser::class);
151 $user_mock->method(
'getId')->willReturn(42);
153 $this->
insertDIC(
'http', $this->http_mock);
154 $this->
insertDIC(
'tpl', $this->createMock(\ilGlobalTemplateInterface::class));
155 $this->
insertDIC(
'lng', $this->createMock(\ilLanguage::class));
156 $this->
insertDIC(
'ilObjDataCache', $this->createMock(\ilObjectDataCache::class));
157 $this->
insertDIC(
'ilDB', $this->createMock(\ilDBInterface::class));
158 $this->
insertDIC(
'tree', $this->createMock(\ilTree::class));
159 $this->
insertDIC(
'rbacreview', $this->createMock(\ilRbacReview::class));
160 $this->
insertDIC(
'ilSetting', $this->createMock(\ilSetting::class));
161 $this->
insertDIC(
'ilErr', $this->createMock(\ilErrorHandling::class));
164 if (!defined(
'ROOT_FOLDER_ID')) {
165 define(
'ROOT_FOLDER_ID', 1);
168 if (!defined(
'ANONYMOUS_USER_ID')) {
169 define(
'ANONYMOUS_USER_ID', 13);
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)
urlProvider
updateRequestAndWrapperMockWithParams(array $params)
Customizing of pimple-DIC for ILIAS.
insertDIC(string $key, $value)
LegacyGotoHandler $subject
ilCtrlInterface PHPUnit Framework MockObject MockObject $ctrl
The scope of this class is split ilias-conform URI's into components.
ILIAS HTTP Services PHPUnit Framework MockObject MockObject $http_mock