ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilCollectionTest.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
23use ILIAS\Export\ImportHandler\Parser\NodeInfo\Attribute\Collection as ilXMLFileNodeInfoAttributeCollection;
24use ILIAS\Export\ImportHandler\Parser\NodeInfo\Attribute\Handler as ilXMLFileNodeInfoAttributePair;
25use ILIAS\Export\ImportHandler\Parser\NodeInfo\DOM\Handler as ilXMLFileNodeInfoDOMNodeHandler;
26use ilLogger;
27use PHPUnit\Framework\TestCase;
28
29class ilCollectionTest extends TestCase
30{
31 public function testNodeInfoAttributeCollection(): void
32 {
33 $logger = $this->createMock(ilLogger::class);
34 $node_info = $this->createMock(ilXMLFileNodeInfoDOMNodeHandler::class);
35 $node_info->expects($this->any())->method('getValueOfAttribute')->willReturnMap([
36 ['key1', 'val1'],
37 ['key2', 'val2'],
38 ['key3', 'val3'],
39 ]);
40 $node_info->expects($this->any())->method('hasAttribute')->willReturnMap([
41 ['key1', true],
42 ['key2', true],
43 ['key3', true],
44 ['key4', false]
45 ]);
46 $pair1 = $this->createMock(ilXMLFileNodeInfoAttributePair::class);
47 $pair1->expects($this->any())->method('getKey')->willReturn('key1');
48 $pair1->expects($this->any())->method('getValue')->willReturn('val1');
49 $pair2 = $this->createMock(ilXMLFileNodeInfoAttributePair::class);
50 $pair2->expects($this->any())->method('getKey')->willReturn('key2');
51 $pair2->expects($this->any())->method('getValue')->willReturn('val2');
52 $pair3 = $this->createMock(ilXMLFileNodeInfoAttributePair::class);
53 $pair3->expects($this->any())->method('getKey')->willReturn('key3');
54 $pair3->expects($this->any())->method('getValue')->willReturn('val3');
55 $pair4 = $this->createMock(ilXMLFileNodeInfoAttributePair::class);
56 $pair4->expects($this->any())->method('getKey')->willReturn('key4');
57 $pair4->expects($this->any())->method('getValue')->willReturn('val4');
58
59 $collection = (new ilXMLFileNodeInfoAttributeCollection($logger))
60 ->withElement($pair1)
61 ->withElement($pair2)
62 ->withElement($pair3);
63 $collection2 = $collection
64 ->withElement($pair4);
65
66 $this->assertTrue($collection->matches($node_info));
67 $this->assertFalse($collection2->matches($node_info));
68 }
69}
Component logger with individual log levels by component id.