ILIAS  trunk Revision v11.0_alpha-1761-g6dbbfa7b760
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
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 141 of file LegacyGotoHandlerTest.php.

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

141  : void
142  {
143  $this->insertDIC('component.factory', $this->component_factory_mock);
144  $this->insertDIC('ctrl', $this->ctrl);
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);
151  $this->insertDIC('ilUser', $user_mock);
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));
161  $this->insertDIC('ilCtrl', $this->ctrl);
162 
163  if (!defined('ROOT_FOLDER_ID')) {
164  define('ROOT_FOLDER_ID', 1);
165  }
166 
167  if (!defined('ANONYMOUS_USER_ID')) {
168  define('ANONYMOUS_USER_ID', 13);
169  }
170  }
+ Here is the call graph for this function:

◆ insertDIC()

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

Definition at line 118 of file LegacyGotoHandlerTest.php.

References $DIC, and $GLOBALS.

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

118  : void
119  {
120  global $DIC;
121  $DIC = $DIC instanceof Container ? $DIC : new Container();
122  if (isset($DIC[$key])) {
123  $this->dic_backup[$key] = clone $DIC[$key];
124  }
125  $GLOBALS[$key] = $value;
126  $DIC->offsetUnset($key);
127  $DIC[$key] = (static fn(): \ilCtrlInterface|Services|MockObject => $value);
128  }
$GLOBALS["DIC"]
Definition: wac.php:53
global $DIC
Definition: shib_login.php:22
+ Here is the caller graph for this function:

◆ setUp()

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

Definition at line 52 of file LegacyGotoHandlerTest.php.

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

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 Contains several chained tasks and infos about them.
+ Here is the call graph for this function:

◆ tearDown()

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

Definition at line 130 of file LegacyGotoHandlerTest.php.

References $DIC, and $GLOBALS.

130  : void
131  {
132  global $DIC;
133  $DIC = $DIC instanceof Container ? $DIC : new Container();
134  foreach ($this->dic_backup as $key => $value) {
135  $DIC->offsetUnset($key);
136  $DIC[$key] = $value;
137  $GLOBALS[$key] = $value;
138  }
139  }
$GLOBALS["DIC"]
Definition: wac.php:53
global $DIC
Definition: shib_login.php:22

◆ testBase()

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

Definition at line 96 of file LegacyGotoHandlerTest.php.

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

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

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

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
+ 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  : array
77  {
78  return [
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'],
92  ];
93  }

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: