29 : void
30 {
31 $writer = $this->getMockBuilder(ilXmlWriter::class)
32 ->disableOriginalConstructor()
33 ->onlyMethods(['xmlStartTag', 'xmlElement', 'xmlEndTag'])
34 ->getMock();
35 $writer->expects($this->once())
36 ->method('xmlStartTag')
37 ->with('WebLink', [
38 'id' => 13,
39 'active' => 1,
40 'position' => 7,
41 'internal' => 0
42 ]);
43
44
45
46
47
48
49
50 $writer->expects($this->exactly(3))
51 ->method('xmlElement')
52 ->willReturnCallback(fn($tag, $attrs,
$data) => match([$tag, $attrs,
$data]) {
53 ['Title', [], 'title'] => 1,
54 ['Description', [], 'description'] => 2,
55 ['Target', [], 'target'] => 3
56 });
57 $writer->expects($this->once())
58 ->method('xmlEndTag')
59 ->with('WebLink');
60
61 $param1 = $this->getMockBuilder(ilWebLinkParameter::class)
62 ->disableOriginalConstructor()
63 ->onlyMethods(['toXML'])
64 ->getMock();
65 $param1->expects($this->once())
66 ->method('toXML')
67 ->with($writer);
68 $param2 = $this->getMockBuilder(ilWebLinkParameter::class)
69 ->disableOriginalConstructor()
70 ->onlyMethods(['toXML'])
71 ->getMock();
72 $param2->expects($this->once())
73 ->method('toXML')
74 ->with($writer);
75
76 $item_stub = new class (
77 1,
78 13,
79 'title',
80 'description',
81 'target',
82 true,
83 new DateTimeImmutable(),
84 new DateTimeImmutable(),
85 [$param1, $param2]
87 public function getResolvedLink(bool $with_parameters = true): string
88 {
89 return '';
90 }
91
92 public function isInternal(): bool
93 {
94 return false;
95 }
96 };
97 $item_stub->toXML($writer, 7);
98 }
Immutable class for Web Link items.