ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ILIAS\StaticURL\Tests\LegacyGotoHandlerTest Class Reference
+ Inheritance diagram for ILIAS\StaticURL\Tests\LegacyGotoHandlerTest:
+ Collaboration diagram for ILIAS\StaticURL\Tests\LegacyGotoHandlerTest:

Public Member Functions

 testBase (string $called_url, string $target)
 

Static Public Member Functions

static urlProvider ()
 

Data Fields

MockObject $request_mock
 
MockObject $component_factory_mock
 
 $refinery
 
 $request_builder
 

Protected Member Functions

 setUp ()
 
 tearDown ()
 
 buildDependecies ()
 

Private Member Functions

 updateRequestAndWrapperMockWithParams (array $params)
 
 insertDIC (string $key, object $value)
 

Private Attributes

ilCtrlInterface MockObject $ctrl
 
LegacyGotoHandler $subject
 
Services MockObject $http_mock
 
array $dic_backup = []
 

Detailed Description

Member Function Documentation

◆ buildDependecies()

ILIAS\StaticURL\Tests\LegacyGotoHandlerTest::buildDependecies ( )
protected

Definition at line 139 of file LegacyGotoHandlerTest.php.

139 : void
140 {
141 $this->insertDIC('component.factory', $this->component_factory_mock);
142 $this->insertDIC('ctrl', $this->ctrl);
143 $access_mock = $this->createMock(\ilAccessHandler::class);
144 $access_mock->method('checkAccess')->willReturn(true);
145 $this->insertDIC('ilAccess', $access_mock);
146 $this->insertDIC('objDefinition', $this->createMock(\ilObjectDefinition::class));
147 $user_mock = $this->createMock(\ilObjUser::class);
148 $user_mock->method('getId')->willReturn(42);
149 $this->insertDIC('ilUser', $user_mock);
150 $this->insertDIC('http', $this->http_mock);
151 $this->insertDIC('tpl', $this->createMock(\ilGlobalTemplateInterface::class));
152 $this->insertDIC('lng', $this->createMock(\ilLanguage::class));
153 $this->insertDIC('ilObjDataCache', $this->createMock(\ilObjectDataCache::class));
154 $this->insertDIC('ilDB', $this->createMock(\ilDBInterface::class));
155 $this->insertDIC('tree', $this->createMock(\ilTree::class));
156 $this->insertDIC('rbacreview', $this->createMock(\ilRbacReview::class));
157 $this->insertDIC('ilSetting', $this->createMock(\ilSetting::class));
158 $this->insertDIC('ilErr', $this->createMock(\ilErrorHandling::class));
159 $this->insertDIC('ilCtrl', $this->ctrl);
160
161 if (!defined('ROOT_FOLDER_ID')) {
162 define('ROOT_FOLDER_ID', 1);
163 }
164
165 if (!defined('ANONYMOUS_USER_ID')) {
166 define('ANONYMOUS_USER_ID', 13);
167 }
168 }

References ILIAS\Repository\ctrl(), and ILIAS\StaticURL\Tests\LegacyGotoHandlerTest\insertDIC().

+ Here is the call graph for this function:

◆ insertDIC()

ILIAS\StaticURL\Tests\LegacyGotoHandlerTest::insertDIC ( string  $key,
object  $value 
)
private

Definition at line 116 of file LegacyGotoHandlerTest.php.

116 : void
117 {
118 global $DIC;
119 $DIC = $DIC instanceof Container ? $DIC : new Container();
120 if (isset($DIC[$key])) {
121 $this->dic_backup[$key] = clone $DIC[$key];
122 }
123 $GLOBALS[$key] = $value;
124 $DIC->offsetUnset($key);
125 $DIC[$key] = (static fn(): \ilCtrlInterface|Services|MockObject => $value);
126 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: shib_login.php:26
$GLOBALS["DIC"]
Definition: wac.php:54

References $DIC, and $GLOBALS.

Referenced by ILIAS\StaticURL\Tests\LegacyGotoHandlerTest\buildDependecies().

+ Here is the caller graph for this function:

◆ setUp()

ILIAS\StaticURL\Tests\LegacyGotoHandlerTest::setUp ( )
protected

Definition at line 52 of file LegacyGotoHandlerTest.php.

52 : void
53 {
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);
58
59 $this->component_factory_mock = $this->createMock(\ilComponentFactory::class);
60
61 $this->refinery = new Factory(
62 new \ILIAS\Data\Factory(),
63 $this->createMock(\ilLanguage::class),
64 );
65
66 $this->request_builder = new LegacyRequestBuilder();
67 $this->subject = new LegacyGotoHandler();
68 }
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.

References ILIAS\Repository\ctrl(), and ILIAS\Repository\refinery().

+ Here is the call graph for this function:

◆ tearDown()

ILIAS\StaticURL\Tests\LegacyGotoHandlerTest::tearDown ( )
protected

Definition at line 128 of file LegacyGotoHandlerTest.php.

128 : void
129 {
130 global $DIC;
131 $DIC = $DIC instanceof Container ? $DIC : new Container();
132 foreach ($this->dic_backup as $key => $value) {
133 $DIC->offsetUnset($key);
134 $DIC[$key] = $value;
135 $GLOBALS[$key] = $value;
136 }
137 }

References $DIC, and $GLOBALS.

◆ testBase()

ILIAS\StaticURL\Tests\LegacyGotoHandlerTest::testBase ( string  $called_url,
string  $target 
)

Definition at line 94 of file LegacyGotoHandlerTest.php.

94 : void
95 {
96 $this->http_mock->request()->method('getUri')->willReturn(new \GuzzleHttp\Psr7\Uri($called_url));
97 $this->assertEquals($called_url, $this->http_mock->request()->getUri());
98
99 $uri = new URI($called_url);
100 //$this->assertGreaterThanOrEqual(2, count($uri->getParameters()));
101
102 $this->updateRequestAndWrapperMockWithParams($uri->getParameters());
103
104 $request = $this->request_builder->buildRequest(
105 $this->http_mock,
106 $this->refinery,
107 []
108 );
109
110 $this->assertInstanceOf(Request::class, $request);
111 $this->assertTrue($this->subject->canHandle($request));
112 $this->assertEquals($target, $request->getAdditionalParameters()[LegacyGotoHandler::TARGET]);
113
114 }

References ILIAS\Repository\refinery(), ILIAS\StaticURL\Handler\LegacyGotoHandler\TARGET, and ILIAS\StaticURL\Tests\LegacyGotoHandlerTest\updateRequestAndWrapperMockWithParams().

+ Here is the call graph for this function:

◆ updateRequestAndWrapperMockWithParams()

ILIAS\StaticURL\Tests\LegacyGotoHandlerTest::updateRequestAndWrapperMockWithParams ( array  $params)
private

Definition at line 70 of file LegacyGotoHandlerTest.php.

70 : void
71 {
72 $this->request_mock->method('getQueryParams')->willReturn($params);
73 $this->http_mock->method('wrapper')->willReturn(new WrapperFactory($this->request_mock));
74 }
if(! $DIC->user() ->getId()||!ilLTIConsumerAccess::hasCustomProviderCreationAccess()) $params
Definition: ltiregstart.php:31

References $params.

Referenced by ILIAS\StaticURL\Tests\LegacyGotoHandlerTest\testBase().

+ Here is the caller graph for this function:

◆ urlProvider()

static ILIAS\StaticURL\Tests\LegacyGotoHandlerTest::urlProvider ( )
static

Definition at line 76 of file LegacyGotoHandlerTest.php.

76 : \Iterator
77 {
78 yield ['https://ilias.domain/goto.php?client_id=unittest&target=impr', 'impr'];
79 yield ['https://ilias.domain/goto.php?target=root_1&client_id=unittest', 'root_1'];
80 yield ['https://ilias.domain/go/root/1', 'root_1'];
81 yield ['https://ilias.domain/goto.php?target=root_1&client_id=unittest&lang=de', 'root_1'];
82 yield ['https://ilias.domain/sub/goto.php?target=root_1&client_id=unittest&lang=de', 'root_1'];
83 yield ['https://ilias.domain/goto.php?target=crs_256&client_id=unittest&lang=de', 'crs_256'];
84 yield ['https://ilias.domain/goto.php?target=lorem_256&client_id=unittest&lang=de', 'lorem_256'];
85 yield ['https://ilias.domain/goto.php?target=wiki_wpage_4826_86154&client_id=unittest&lang=de', 'wiki_wpage_4826_86154'];
86 yield ['https://ilias.domain/sub/goto.php?target=wiki_wpage_4826_86154&client_id=unittest&lang=de', 'wiki_wpage_4826_86154'];
87 yield ['https://ilias.domain/goto.php/wiki/wpage_4826_86154', 'wiki_wpage_4826_86154'];
88 yield ['https://ilias.domain/go/wiki/wpage_4826_86154', 'wiki_wpage_4826_86154'];
89 yield ['https://ilias.domain/sub/goto.php/wiki/wpage_4826_86154', 'wiki_wpage_4826_86154'];
90 yield ['https://ilias.domain/sub/go/wiki/wpage_4826_86154', 'wiki_wpage_4826_86154'];
91 }

Field Documentation

◆ $component_factory_mock

MockObject ILIAS\StaticURL\Tests\LegacyGotoHandlerTest::$component_factory_mock

Definition at line 41 of file LegacyGotoHandlerTest.php.

◆ $ctrl

ilCtrlInterface MockObject ILIAS\StaticURL\Tests\LegacyGotoHandlerTest::$ctrl
private

Definition at line 44 of file LegacyGotoHandlerTest.php.

◆ $dic_backup

array ILIAS\StaticURL\Tests\LegacyGotoHandlerTest::$dic_backup = []
private

Definition at line 50 of file LegacyGotoHandlerTest.php.

◆ $http_mock

Services MockObject ILIAS\StaticURL\Tests\LegacyGotoHandlerTest::$http_mock
private

Definition at line 49 of file LegacyGotoHandlerTest.php.

◆ $refinery

ILIAS\StaticURL\Tests\LegacyGotoHandlerTest::$refinery

Definition at line 42 of file LegacyGotoHandlerTest.php.

◆ $request_builder

ILIAS\StaticURL\Tests\LegacyGotoHandlerTest::$request_builder

Definition at line 43 of file LegacyGotoHandlerTest.php.

◆ $request_mock

MockObject ILIAS\StaticURL\Tests\LegacyGotoHandlerTest::$request_mock

Definition at line 40 of file LegacyGotoHandlerTest.php.

◆ $subject

LegacyGotoHandler ILIAS\StaticURL\Tests\LegacyGotoHandlerTest::$subject
private

Definition at line 45 of file LegacyGotoHandlerTest.php.


The documentation for this class was generated from the following file: