19 declare(strict_types=1);
29 protected function setUp(): void
31 $this->URI_COMPLETE = new \ILIAS\Data\URI(
'https://www.ilias.de/foo/bar?var1=42&var2=foo#12345');
37 $this->assertInstanceOf(\
ILIAS\
Data\URI::class,
$url->buildURI());
38 $this->assertEquals(
'https://www.ilias.de/foo/bar?var1=42&var2=foo#12345', (
string)
$url->buildURI());
44 $result =
$url->acquireParameter([
'test'],
'title');
45 $this->assertInstanceOf(URLBuilder::class, $result[0]);
48 (
string) $result[0]->buildURI()
50 $this->assertInstanceOf(URLBuilderToken::class, $result[1]);
52 $this->assertNotEmpty($result[1]->getToken());
58 $result =
$url->acquireParameter([
'test',
'object',
'metadata'],
'title');
59 $this->assertInstanceOf(URLBuilder::class, $result[0]);
65 (
string) $result[0]->buildURI()
67 $this->assertInstanceOf(URLBuilderToken::class, $result[1]);
69 'test' . URLBuilder::SEPARATOR .
70 'object' . URLBuilder::SEPARATOR .
71 'metadata' . URLBuilder::SEPARATOR .
75 $this->assertNotEmpty($result[1]->getToken());
82 $result =
$url->acquireParameter([
'test'],
'title',
'bar');
83 $this->assertInstanceOf(URLBuilder::class, $result[0]);
85 'https://www.ilias.de/foo/bar?var1=42&var2=foo&test' . $sep .
'title=bar#12345',
86 (
string) $result[0]->buildURI()
88 $this->assertInstanceOf(URLBuilderToken::class, $result[1]);
89 $this->assertEquals(
'test' . $sep .
'title', $result[1]->getName());
90 $this->assertNotEmpty($result[1]->getToken());
97 $result =
$url->acquireParameter([
'test'],
'title',
'foo');
99 'https://www.ilias.de/foo/bar?var1=42&var2=foo&test' . $sep .
'title=foo#12345',
100 (
string) $result[0]->buildURI()
102 $this->assertEquals(
'test' . $sep .
'title', $result[1]->getName());
104 $result2 = $result[0]->acquireParameter([
'notatest'],
'title',
'bar');
106 'https://www.ilias.de/foo/bar?var1=42&var2=foo&test' . $sep .
'title=foo¬atest' . $sep .
'title=bar#12345',
107 (
string) $result2[0]->buildURI()
109 $this->assertEquals(
'notatest' . $sep .
'title', $result2[1]->getName());
110 $this->assertNotEquals($result[1]->getToken(), $result2[1]->getToken());
117 $result =
$url->acquireParameter([
'test'],
'title',
'bar');
119 'https://www.ilias.de/foo/bar?var1=42&var2=foo&test' . $sep .
'title=bar#12345',
120 (
string) $result[0]->buildURI()
123 $url = $result[0]->withParameter($result[1],
'foobar');
124 $this->assertInstanceOf(URLBuilder::class,
$url);
126 'https://www.ilias.de/foo/bar?var1=42&var2=foo&test' . $sep .
'title=foobar#12345',
127 (
string)
$url->buildURI()
130 $url = $result[0]->withParameter($result[1], [
'foo',
'bar']);
131 $this->assertInstanceOf(URLBuilder::class, $url);
133 'https://www.ilias.de/foo/bar?var1=42&var2=foo' 134 .
'&test' . $sep . urlencode(
'title[]') .
'=foo' 135 .
'&test' . $sep . urlencode(
'title[]') .
'=bar' 137 (
string) $url->buildURI()
145 $result =
$url->acquireParameter([
'test'],
'title',
'bar');
147 'https://www.ilias.de/foo/bar?var1=42&var2=foo&test' . $sep .
'title=bar#12345',
148 (
string) $result[0]->buildURI()
151 $url = $result[0]->deleteParameter($result[1]);
152 $this->assertEquals(
'https://www.ilias.de/foo/bar?var1=42&var2=foo#12345', (
string)
$url->buildURI());
159 $this->expectException(\LengthException::class);
160 $output = $result[0]->buildURI();
167 $this->assertInstanceOf(URLBuilder::class,
$url);
168 $this->assertEquals(
'https://www.ilias.de/foo/bar?var1=42&var2=foo', (
string)
$url->buildURI());
170 $this->assertInstanceOf(URLBuilder::class, $url);
171 $this->assertEquals(
'https://www.ilias.de/foo/bar?var1=42&var2=foo#12345', (
string) $url->buildURI());
172 $url = $url->withFragment(
'54321');
173 $this->assertInstanceOf(URLBuilder::class, $url);
174 $this->assertEquals(
'https://www.ilias.de/foo/bar?var1=42&var2=foo#54321', (
string) $url->buildURI());
180 $result =
$url->acquireParameter([
'test'],
'title',
'bar');
181 $url = $result[0]->withURI(
186 (
string)
$url->buildURI()
195 $result1 =
$url->acquireParameter([
'test',
'object'],
'title',
'bar');
197 $expected_token =
'new Map([["' . $result1[1]->getName() .
'",' 198 .
'new il.UI.core.URLBuilderToken(["test","object"], "title", "' . $result1[1]->getToken() .
'")]])';
199 $this->assertEquals($expected_token,
$url->renderTokens([$result1[1]]));
202 $result2 =
$url->acquireParameter([
'test'],
'description',
'foo');
204 $this->assertEquals($expected_token,
$url->renderTokens([$result1[1]]));
207 $expected_token =
'new Map([["' . $result1[1]->getName() .
'",' 208 .
'new il.UI.core.URLBuilderToken(["test","object"], "title", "' . $result1[1]->getToken() .
'")],' 209 .
'["' . $result2[1]->getName() .
'",' 210 .
'new il.UI.core.URLBuilderToken(["test"], "description", "' . $result2[1]->getToken() .
'")]])';
211 $this->assertEquals($expected_token,
$url->renderTokens([$result1[1], $result2[1]]));
219 $result1 =
$url->acquireParameter([
'test',
'object'],
'title',
'bar');
221 $expected_token =
'new Map([["' . $result1[1]->getName() .
'",' 222 .
'new il.UI.core.URLBuilderToken(["test","object"], "title", "' . $result1[1]->getToken() .
'")]])';
223 $expected_object =
'new il.UI.core.URLBuilder(new URL("https://www.ilias.de/foo/bar?var1=42&var2=foo&' 225 $this->assertEquals($expected_object,
$url->renderObject([$result1[1]]));
228 $result2 =
$url->acquireParameter([
'test'],
'description',
'foo');
230 $expected_object =
'new il.UI.core.URLBuilder(new URL("https://www.ilias.de/foo/bar?var1=42&var2=foo&' 233 $this->assertEquals($expected_object,
$url->renderObject([$result1[1]]));
236 $expected_token =
'new Map([["' . $result1[1]->getName() .
'",' 237 .
'new il.UI.core.URLBuilderToken(["test","object"], "title", "' . $result1[1]->getToken() .
'")],' 238 .
'["' . $result2[1]->getName() .
'",' 239 .
'new il.UI.core.URLBuilderToken(["test"], "description", "' . $result2[1]->getToken() .
'")]])';
240 $expected_object =
'new il.UI.core.URLBuilder(new URL("https://www.ilias.de/foo/bar?var1=42&var2=foo&' 243 $this->assertEquals($expected_object,
$url->renderObject([$result1[1], $result2[1]]));
testAcquireParamWithLongNamespace()
const URL_MAX_LENGTH
A maximum length of 2048 characters should be safe to use in most browsers, even though longer URLs w...
Interface Observer Contains several chained tasks and infos about them.
const SEPARATOR
Separator for parts of a parameter's namespace.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
readonly ILIAS Data URI $URI_COMPLETE
testRemoveAndAddFragment()
testAcquireParamWithSameName()
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
testAcquireParamWithValue()