ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ilWebResourceItemTest.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
22 
27 class ilWebResourceItemTest extends TestCase
28 {
29  public function testToXML(): 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  $writer->expects($this->exactly(3))
44  ->method('xmlElement')
45  ->withConsecutive(
46  ['Title', [], 'title'],
47  ['Description', [], 'description'],
48  ['Target', [], 'target'],
49  );
50  $writer->expects($this->once())
51  ->method('xmlEndTag')
52  ->with('WebLink');
53 
54  $param1 = $this->getMockBuilder(ilWebLinkParameter::class)
55  ->disableOriginalConstructor()
56  ->onlyMethods(['toXML'])
57  ->getMock();
58  $param1->expects($this->once())
59  ->method('toXML')
60  ->with($writer);
61  $param2 = $this->getMockBuilder(ilWebLinkParameter::class)
62  ->disableOriginalConstructor()
63  ->onlyMethods(['toXML'])
64  ->getMock();
65  $param2->expects($this->once())
66  ->method('toXML')
67  ->with($writer);
68 
69  $item_stub = $this->getMockForAbstractClass(
70  ilWebLinkItem::class,
71  [
72  1, 13, 'title', 'description', 'target',
73  true, new DateTimeImmutable(), new DateTimeImmutable(),
74  [$param1, $param2]
75  ]
76  );
77  $item_stub->expects($this->once())
78  ->method('isInternal')
79  ->willReturn(false);
80  $item_stub->toXML($writer, 7);
81  }
82 }
Unit tests for ilWebLinkItem.