ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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->getMockBuilder(ilWebLinkParameter::class)
32 ->disableOriginalConstructor()
33 ->onlyMethods(['appendToLink', 'getValue'])
34 ->getMock();
35 $param1->expects($this->once())
36 ->method('appendToLink')
37 ->with('target')
38 ->willReturn('target?param1');
39 $param1->expects($this->any())
40 ->method('getValue')
41 ->willReturn(1);
42
43
44 $param2 = $this->getMockBuilder(ilWebLinkParameter::class)
45 ->disableOriginalConstructor()
46 ->onlyMethods(['appendToLink', 'getValue'])
47 ->getMock();
48 $param2->expects($this->once())
49 ->method('appendToLink')
50 ->with('target?param1')
51 ->willReturn('target?param1&param2');
52 $param2->expects($this->any())
53 ->method('getValue')
54 ->willReturn(1);
55
56 $item = new ilWebLinkItemExternal(
57 0,
58 1,
59 'title',
60 null,
61 'target',
62 true,
63 new DateTimeImmutable(),
64 new DateTimeImmutable(),
65 [$param1, $param2]
66 );
67
68 $this->assertSame(
69 'target?param1&param2',
70 $item->getResolvedLink(true)
71 );
72 $this->assertSame(
73 'target',
74 $item->getResolvedLink(false)
75 );
76 }
77}
Immutable class for external Web Link items.
Unit tests for ilWebLinkItemExternal.