ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
URIBuilderTest.php
Go to the documentation of this file.
1 <?php
2 
19 namespace ILIAS\StaticURL\Tests;
20 
23 
24 require_once "Base.php";
25 
29 class URIBuilderTest extends Base
30 {
31  private ?string $ilias_http_path_backup = null;
33 
34  public function getILIAS_HTTP_Paths(): array
35  {
36  return [
37  ['https://ilias.de/ilias', 'https://ilias.de/ilias'],
38  ['https://ilias.de/ilias/', 'https://ilias.de/ilias'],
39  ['http://ilias.de/ilias', 'http://ilias.de/ilias'],
40  ['https://test9.ilias.de/goto.php', 'https://test9.ilias.de'],
41  ['https://test9.ilias.de/goto.php/', 'https://test9.ilias.de'],
42  ['https://test9.ilias.de/goto.php/wiki', 'https://test9.ilias.de'],
43  ['https://test9.ilias.de/goto.php/wiki/22', 'https://test9.ilias.de'],
44  ['http://test9.ilias.de/goto.php', 'http://test9.ilias.de'],
45  ['http://test9.ilias.de/go/hello', 'http://test9.ilias.de'],
46  ['http://test9.ilias.de/go/hello', 'http://test9.ilias.de'],
47  ['http://test9.ilias.de/Customizing/global/plugins/Services/index.php', 'http://test9.ilias.de'],
48  ];
49  }
50 
54  public function testBaseURI(string $ILIAS_HTTP_PATH, string $expected): void
55  {
56  $uri_builder = new StandardURIBuilder($ILIAS_HTTP_PATH);
57  $this->assertEquals($expected, (string) $uri_builder->getBaseURI());
58  }
59 
60  public function getBuilderParts(): array
61  {
62  return [
63  ['wiki', 42, [], 'https://test9.ilias.de/goto.php/wiki/42'],
64  ['file', 42, ['download'], 'https://test9.ilias.de/goto.php/file/42/download'],
65  ['dashboard', null, [], 'https://test9.ilias.de/goto.php/dashboard'],
66 
67  ];
68  }
69 
73  public function testFullBuilder(string $namespace, ?int $ref_id, array $params, string $expected): void
74  {
75  $uri_builder = new StandardURIBuilder('https://test9.ilias.de');
76  $uri = $uri_builder->build(
77  $namespace,
78  $ref_id === null ? null : new ReferenceId($ref_id),
79  $params
80  );
81  $this->assertEquals($expected, (string) $uri);
82  }
83 }
if($err=$client->getError()) $namespace
if(! $DIC->user() ->getId()||!ilLTIConsumerAccess::hasCustomProviderCreationAccess()) $params
Definition: ltiregstart.php:33
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: Base.php:19
testFullBuilder(string $namespace, ?int $ref_id, array $params, string $expected)
getBuilderParts
$ref_id
Definition: ltiauth.php:67
build(string $namespace, ?ReferenceId $reference_id=null, array $additional_parameters=[])
testBaseURI(string $ILIAS_HTTP_PATH, string $expected)
getILIAS_HTTP_Paths