ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
ilWebResourceItemExternalTest.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21use PHPUnit\Framework\TestCase;
22
27class ilWebResourceItemExternalTest extends TestCase
28{
29 public function testGetResolvedLink(): void
30 {
31 $param1 = $this->createMock(ilWebLinkParameter::class);
32 $param1->expects($this->once())
33 ->method('appendToLink')
34 ->with('target')
35 ->willReturn('target?param1');
36 $param1->method('getValue')
37 ->willReturn(1);
38
39
40 $param2 = $this->createMock(ilWebLinkParameter::class);
41 $param2->expects($this->once())
42 ->method('appendToLink')
43 ->with('target?param1')
44 ->willReturn('target?param1&param2');
45 $param2->method('getValue')
46 ->willReturn(1);
47
48 $item = new ilWebLinkItemExternal(
49 0,
50 1,
51 'title',
52 null,
53 'target',
54 true,
55 new DateTimeImmutable(),
56 new DateTimeImmutable(),
57 [$param1, $param2]
58 );
59
60 $this->assertSame(
61 'target?param1&param2',
62 $item->getResolvedLink(true)
63 );
64 $this->assertSame(
65 'target',
66 $item->getResolvedLink(false)
67 );
68 }
69
70 public function testGetTargetTrailingSpace(): void
71 {
72 $item = new ilWebLinkItemExternal(
73 0,
74 1,
75 'title',
76 null,
77 'target ',
78 true,
79 new DateTimeImmutable(),
80 new DateTimeImmutable(),
81 []
82 );
83
84 $this->assertSame(
85 'target',
86 $item->getTarget()
87 );
88 }
89
90 public function testGetResolvedLinkTrailingSpace(): void
91 {
92 $item = new ilWebLinkItemExternal(
93 0,
94 1,
95 'title',
96 null,
97 'target ',
98 true,
99 new DateTimeImmutable(),
100 new DateTimeImmutable(),
101 []
102 );
103
104 $this->assertSame(
105 'target',
106 $item->getResolvedLink()
107 );
108 }
109}
Immutable class for external Web Link items.
Unit tests for ilWebLinkItemExternal.