19 declare(strict_types=1);
30 protected function setUp(): void
32 $namespace_1 = $this->createMock(ilFileNamespaceHandler::class);
39 ilFileNamespaceCollectionInterface $collection,
40 array $expected_elements
42 $this->assertSameSize($expected_elements, $collection);
43 $collection->rewind();
44 $this->assertEquals(0, $collection->key());
45 for ($i = 0; $i < $collection->count(); $i++) {
46 $current = $collection->current();
47 $this->assertTrue($collection->valid());
48 $this->assertEquals($i, $collection->key());
49 $this->assertEquals($expected_elements[$i], $current);
52 $collection->rewind();
53 $this->assertEquals(0, $collection->key());
58 $namespace_1 = $this->createMock(ilFileNamespaceHandler::class);
59 $namespace_1->expects($this->any())->method(
'getNamespace')->willReturn(
'namespace_1');
60 $namespace_1->expects($this->any())->method(
'getPrefix')->willReturn(
'prefix_1');
62 $namespace_2 = $this->createMock(ilFileNamespaceHandler::class);
63 $namespace_2->expects($this->any())->method(
'getNamespace')->willReturn(
'namespace_2');
64 $namespace_2->expects($this->any())->method(
'getPrefix')->willReturn(
'prefix_2');
66 $namespace_3 = $this->createMock(ilFileNamespaceHandler::class);
67 $namespace_3->expects($this->any())->method(
'getNamespace')->willReturn(
'namespace_3');
68 $namespace_3->expects($this->any())->method(
'getPrefix')->willReturn(
'prefix_3');
70 $collection_one_element = (
new ilFileNamespaceCollection())
71 ->withElement($namespace_1);
72 $collection_two_elements = (
new ilFileNamespaceCollection())
73 ->withElement($namespace_1)
74 ->withElement($namespace_2);
75 $collection_three_elements = (
new ilFileNamespaceCollection())
76 ->withElement($namespace_1)
77 ->withElement($namespace_2)
78 ->withElement($namespace_3);
79 $merged_collection = $collection_three_elements->withMerged($collection_two_elements);
82 $this->
checkCollection($collection_two_elements, [$namespace_1, $namespace_2]);
83 $this->
checkCollection($collection_three_elements, [$namespace_1, $namespace_2, $namespace_3]);
84 $this->
checkCollection($merged_collection, [$namespace_1, $namespace_2, $namespace_3, $namespace_1, $namespace_2]);
checkCollection(ilFileNamespaceCollectionInterface $collection, array $expected_elements)