ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
URIBuilderTest.php
Go to the documentation of this file.
1<?php
2
19namespace ILIAS\StaticURL\Tests;
20
21use PHPUnit\Framework\Attributes\DataProvider;
24
25require_once "Base.php";
26
30class URIBuilderTest extends Base
31{
32 private ?string $ilias_http_path_backup = null;
34
35 public static function getILIAS_HTTP_Paths(): \Iterator
36 {
37 yield ['https://ilias.de/ilias', 'https://ilias.de/ilias'];
38 yield ['https://ilias.de/ilias/', 'https://ilias.de/ilias'];
39 yield ['http://ilias.de/ilias', 'http://ilias.de/ilias'];
40 yield ['https://test9.ilias.de/goto.php', 'https://test9.ilias.de'];
41 yield ['https://test9.ilias.de/goto.php/', 'https://test9.ilias.de'];
42 yield ['https://test9.ilias.de/goto.php/wiki', 'https://test9.ilias.de'];
43 yield ['https://test9.ilias.de/goto.php/wiki/22', 'https://test9.ilias.de'];
44 yield ['http://test9.ilias.de/goto.php', 'http://test9.ilias.de'];
45 yield ['http://test9.ilias.de/go/hello', 'http://test9.ilias.de'];
46 yield ['http://test9.ilias.de/go/hello', 'http://test9.ilias.de'];
47 yield ['http://test9.ilias.de/Customizing/plugins/Services/index.php', 'http://test9.ilias.de'];
48 }
49
50 #[DataProvider('getILIAS_HTTP_Paths')]
51 public function testBaseURI(string $ILIAS_HTTP_PATH, string $expected): void
52 {
53 $uri_builder = new StandardURIBuilder($ILIAS_HTTP_PATH);
54 $this->assertSame($expected, (string) $uri_builder->getBaseURI());
55 }
56
57 public static function getBuilderParts(): \Iterator
58 {
59 yield ['wiki', 42, [], 'https://test9.ilias.de/goto.php/wiki/42'];
60 yield ['file', 42, ['download'], 'https://test9.ilias.de/goto.php/file/42/download'];
61 yield ['dashboard', null, [], 'https://test9.ilias.de/goto.php/dashboard'];
62 }
63
64 #[DataProvider('getBuilderParts')]
65 public function testFullBuilder(string $namespace, ?int $ref_id, array $params, string $expected): void
66 {
67 $uri_builder = new StandardURIBuilder('https://test9.ilias.de');
68 $uri = $uri_builder->build(
70 $ref_id === null ? null : new ReferenceId($ref_id),
72 );
73 $this->assertSame($expected, (string) $uri);
74 }
75}
build(string $namespace, ?ReferenceId $reference_id=null, array $additional_parameters=[])
testBaseURI(string $ILIAS_HTTP_PATH, string $expected)
testFullBuilder(string $namespace, ?int $ref_id, array $params, string $expected)
if($err=$client->getError()) $namespace
$ref_id
Definition: ltiauth.php:66
if(! $DIC->user() ->getId()||!ilLTIConsumerAccess::hasCustomProviderCreationAccess()) $params
Definition: ltiregstart.php:31
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: Base.php:19