19 declare(strict_types=1);
21 require_once(
"vendor/composer/vendor/autoload.php");
39 protected function setUp(): void
41 $this->entries_data = include
"components/ILIAS/UI/tests/Crawler/Fixture/EntriesFixture.php";
42 $this->entries =
new Entries();
43 $this->entry_data = include
"components/ILIAS/UI/tests/Crawler/Fixture/EntryFixture.php";
44 $this->entry =
new Entry($this->entry_data);
45 $this->entries->addEntriesFromArray($this->entries_data);
50 $this->assertInstanceOf(Entries::class, $this->entries);
55 $entry =
new Entry($this->entry_data);
56 $entries =
new Entries();
58 $entries->addEntry($entry);
59 $this->assertEquals(1, $entries->count());
62 $entries->addEntry($entry);
63 $this->assertEquals(2, $entries->count());
68 $entry =
new Entry($this->entry_data);
70 $entries =
new Entries();
71 $entries->addEntry($entry);
74 $entries->addEntry($entry);
76 $new_entries =
new Entries();
77 $new_entries->addEntries($this->entries);
78 $this->assertEquals(2, $new_entries->count());
83 $entries_emtpy =
new Entries();
84 $entries =
new Entries();
85 $this->assertEquals($entries_emtpy, $entries);
86 $entries->addEntriesFromArray([]);
87 $this->assertEquals($entries_emtpy, $entries);
88 $entries->addEntriesFromArray($this->entries_data);
89 $this->assertEquals($entries, $this->entries);
94 $entries =
new Entries();
95 $this->assertEquals(
"root", $entries->getRootEntryId());
96 $entries->setRootEntryId(
"root2");
97 $this->assertEquals(
"root2", $entries->getRootEntryId());
98 $this->assertEquals(
"Entry1", $this->entries->getRootEntryId());
103 $entries =
new Entries();
105 $entries->getRootEntry();
106 $this->assertFalse(
"this should not happen");
108 $this->assertTrue(
true);
110 $this->assertEquals(
new Entry($this->entries_data[
"Entry1"]), $this->entries->getRootEntry());
115 $entries =
new Entries();
117 $entries->getEntryById(
"invalid");
118 $this->assertFalse(
"this should not happen");
120 $this->assertTrue(
true);
122 $this->assertEquals(
new Entry($this->entries_data[
"Entry2"]), $this->entries->getEntryById(
"Entry2"));
127 $this->assertEquals([], $this->entries->getParentsOfEntry(
"Entry1"));
128 $this->assertEquals([
"Entry1"], $this->entries->getParentsOfEntry(
"Entry2"));
133 $this->assertEquals(
false, $this->entries->isParentOfEntry(
"Entry2",
"Entry1"));
134 $this->assertEquals(
true, $this->entries->isParentOfEntry(
"Entry1",
"Entry2"));
139 $this->assertEquals([], $this->entries->getParentsOfEntryTitles(
"Entry1"));
140 $this->assertEquals([
'Entry1' =>
'Entry1Title'], $this->entries->getParentsOfEntryTitles(
"Entry2"));
145 $this->assertEquals([
'Entry2'], $this->entries->getDescendantsOfEntry(
"Entry1"));
146 $this->assertEquals([], $this->entries->getDescendantsOfEntry(
"Entry2"));
151 $this->assertEquals([
'Entry2' =>
'Entry2Title'], $this->entries->getDescendantsOfEntryTitles(
"Entry1"));
152 $this->assertEquals([], $this->entries->getDescendantsOfEntryTitles(
"Entry2"));
157 $this->assertEquals([$this->entries->getEntryById(
"Entry2")], $this->entries->getChildrenOfEntry(
"Entry1"));
158 $this->assertEquals([], $this->entries->getDescendantsOfEntryTitles(
"Entry2"));
163 $entries =
new Entries();
165 $this->assertEquals([], $entries->jsonSerialize());
166 $this->assertEquals($this->entries_data, $this->entries->jsonSerialize());
testGetParentsOfEntryTitles()
Container storing a list of UI Component Entries, can act as Iterator, countable and is serializable...
testGetDescendantsOfEntries()
testGetDescendantsOfEntryTitles()