ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
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)
 urlProvider More...
 

Static Public Member Functions

static urlProvider ()
 

Data Fields

 $request_mock
 
 $component_factory_mock
 
 $refinery
 
 $request_builder
 

Protected Member Functions

 setUp ()
 
 tearDown ()
 
 buildDependecies ()
 

Private Member Functions

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

Private Attributes

ilCtrlInterface PHPUnit Framework MockObject MockObject $ctrl
 
LegacyGotoHandler $subject
 
ILIAS HTTP Services PHPUnit Framework MockObject MockObject $http_mock
 
array $dic_backup = []
 

Detailed Description

Member Function Documentation

◆ buildDependecies()

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

Definition at line 142 of file LegacyGotoHandlerTest.php.

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

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

◆ insertDIC()

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

Definition at line 117 of file LegacyGotoHandlerTest.php.

References $DIC, and $GLOBALS.

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

117  : void
118  {
119  global $DIC;
120  $DIC = $DIC instanceof Container ? $DIC : new Container();
121  if (isset($DIC[$key])) {
122  $this->dic_backup[$key] = clone $DIC[$key];
123  }
124  $GLOBALS[$key] = $value;
125  $DIC->offsetUnset($key);
126  $DIC[$key] = static function () use ($value) {
127  return $value;
128  };
129  }
$GLOBALS["DIC"]
Definition: wac.php:30
global $DIC
Definition: shib_login.php:25
+ Here is the caller graph for this function:

◆ setUp()

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

Definition at line 49 of file LegacyGotoHandlerTest.php.

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

49  : void
50  {
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);
55 
56  $this->component_factory_mock = $this->createMock(\ilComponentFactory::class);
57 
58  $this->refinery = new Factory(
59  new \ILIAS\Data\Factory(),
60  $this->createMock(\ilLanguage::class),
61  );
62 
63  $this->request_builder = new LegacyRequestBuilder();
64  $this->subject = new LegacyGotoHandler();
65  }
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 131 of file LegacyGotoHandlerTest.php.

References $DIC, and $GLOBALS.

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

◆ testBase()

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

urlProvider

Definition at line 95 of file LegacyGotoHandlerTest.php.

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

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

◆ updateRequestAndWrapperMockWithParams()

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

Definition at line 67 of file LegacyGotoHandlerTest.php.

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

67  : void
68  {
69  $this->request_mock->method('getQueryParams')->willReturn($params);
70  $this->http_mock->method('wrapper')->willReturn(new WrapperFactory($this->request_mock));
71  }
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 73 of file LegacyGotoHandlerTest.php.

73  : array
74  {
75  return [
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'],
89  ];
90  }

Field Documentation

◆ $component_factory_mock

ILIAS\StaticURL\Tests\LegacyGotoHandlerTest::$component_factory_mock

Definition at line 38 of file LegacyGotoHandlerTest.php.

◆ $ctrl

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

Definition at line 41 of file LegacyGotoHandlerTest.php.

◆ $dic_backup

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

Definition at line 47 of file LegacyGotoHandlerTest.php.

◆ $http_mock

ILIAS HTTP Services PHPUnit Framework MockObject MockObject ILIAS\StaticURL\Tests\LegacyGotoHandlerTest::$http_mock
private

Definition at line 46 of file LegacyGotoHandlerTest.php.

◆ $refinery

ILIAS\StaticURL\Tests\LegacyGotoHandlerTest::$refinery

Definition at line 39 of file LegacyGotoHandlerTest.php.

◆ $request_builder

ILIAS\StaticURL\Tests\LegacyGotoHandlerTest::$request_builder

Definition at line 40 of file LegacyGotoHandlerTest.php.

◆ $request_mock

ILIAS\StaticURL\Tests\LegacyGotoHandlerTest::$request_mock

Definition at line 37 of file LegacyGotoHandlerTest.php.

◆ $subject

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

Definition at line 42 of file LegacyGotoHandlerTest.php.


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