ILIAS  trunk Revision v11.0_alpha-1713-gd8962da2f67
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ComponentEntriesTest Class Reference
+ Inheritance diagram for ComponentEntriesTest:
+ Collaboration diagram for ComponentEntriesTest:

Public Member Functions

 testConstruct ()
 
 testAddEntry ()
 
 testAddEntries ()
 
 testAddFromArray ()
 
 testGetRootEntryId ()
 
 testGetRootEntry ()
 
 testGetEntryById ()
 
 testGetParentsOfEntry ()
 
 testIsParentOfEntry ()
 
 testGetParentsOfEntryTitles ()
 
 testGetDescendantsOfEntries ()
 
 testGetDescendantsOfEntryTitles ()
 
 testGetChildrenOfEntry ()
 
 testJsonSerialize ()
 

Protected Member Functions

 setUp ()
 

Protected Attributes

 $entries_data
 
Entries $entries
 
Entry $entry
 
array $entry_data
 

Detailed Description

Definition at line 29 of file ComponentEntriesTest.php.

Member Function Documentation

◆ setUp()

ComponentEntriesTest::setUp ( )
protected

Definition at line 39 of file ComponentEntriesTest.php.

39  : void
40  {
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);
46  }

◆ testAddEntries()

ComponentEntriesTest::testAddEntries ( )

Definition at line 66 of file ComponentEntriesTest.php.

66  : void
67  {
68  $entry = new Entry($this->entry_data);
69 
70  $entries = new Entries();
71  $entries->addEntry($entry);
72 
73  $entry->setId("2");
74  $entries->addEntry($entry);
75 
76  $new_entries = new Entries();
77  $new_entries->addEntries($this->entries);
78  $this->assertEquals(2, $new_entries->count());
79  }

◆ testAddEntry()

ComponentEntriesTest::testAddEntry ( )

Definition at line 53 of file ComponentEntriesTest.php.

53  : void
54  {
55  $entry = new Entry($this->entry_data);
56  $entries = new Entries();
57 
58  $entries->addEntry($entry);
59  $this->assertEquals(1, $entries->count());
60 
61  $entry->setId("2");
62  $entries->addEntry($entry);
63  $this->assertEquals(2, $entries->count());
64  }

◆ testAddFromArray()

ComponentEntriesTest::testAddFromArray ( )

Definition at line 81 of file ComponentEntriesTest.php.

81  : void
82  {
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);
90  }

◆ testConstruct()

ComponentEntriesTest::testConstruct ( )

Definition at line 48 of file ComponentEntriesTest.php.

48  : void
49  {
50  $this->assertInstanceOf(Entries::class, $this->entries);
51  }

◆ testGetChildrenOfEntry()

ComponentEntriesTest::testGetChildrenOfEntry ( )

Definition at line 155 of file ComponentEntriesTest.php.

155  : void
156  {
157  $this->assertEquals([$this->entries->getEntryById("Entry2")], $this->entries->getChildrenOfEntry("Entry1"));
158  $this->assertEquals([], $this->entries->getDescendantsOfEntryTitles("Entry2"));
159  }

◆ testGetDescendantsOfEntries()

ComponentEntriesTest::testGetDescendantsOfEntries ( )

Definition at line 143 of file ComponentEntriesTest.php.

143  : void
144  {
145  $this->assertEquals(['Entry2'], $this->entries->getDescendantsOfEntry("Entry1"));
146  $this->assertEquals([], $this->entries->getDescendantsOfEntry("Entry2"));
147  }

◆ testGetDescendantsOfEntryTitles()

ComponentEntriesTest::testGetDescendantsOfEntryTitles ( )

Definition at line 149 of file ComponentEntriesTest.php.

149  : void
150  {
151  $this->assertEquals(['Entry2' => 'Entry2Title'], $this->entries->getDescendantsOfEntryTitles("Entry1"));
152  $this->assertEquals([], $this->entries->getDescendantsOfEntryTitles("Entry2"));
153  }

◆ testGetEntryById()

ComponentEntriesTest::testGetEntryById ( )

Definition at line 113 of file ComponentEntriesTest.php.

References Vendor\Package\$e.

113  : void
114  {
115  $entries = new Entries();
116  try {
117  $entries->getEntryById("invalid");
118  $this->assertFalse("this should not happen");
119  } catch (CrawlerException $e) {
120  $this->assertTrue(true);
121  }
122  $this->assertEquals(new Entry($this->entries_data["Entry2"]), $this->entries->getEntryById("Entry2"));
123  }

◆ testGetParentsOfEntry()

ComponentEntriesTest::testGetParentsOfEntry ( )

Definition at line 125 of file ComponentEntriesTest.php.

125  : void
126  {
127  $this->assertEquals([], $this->entries->getParentsOfEntry("Entry1"));
128  $this->assertEquals(["Entry1"], $this->entries->getParentsOfEntry("Entry2"));
129  }

◆ testGetParentsOfEntryTitles()

ComponentEntriesTest::testGetParentsOfEntryTitles ( )

Definition at line 137 of file ComponentEntriesTest.php.

137  : void
138  {
139  $this->assertEquals([], $this->entries->getParentsOfEntryTitles("Entry1"));
140  $this->assertEquals(['Entry1' => 'Entry1Title'], $this->entries->getParentsOfEntryTitles("Entry2"));
141  }

◆ testGetRootEntry()

ComponentEntriesTest::testGetRootEntry ( )

Definition at line 101 of file ComponentEntriesTest.php.

References Vendor\Package\$e.

101  : void
102  {
103  $entries = new Entries();
104  try {
105  $entries->getRootEntry();
106  $this->assertFalse("this should not happen");
107  } catch (CrawlerException $e) {
108  $this->assertTrue(true);
109  }
110  $this->assertEquals(new Entry($this->entries_data["Entry1"]), $this->entries->getRootEntry());
111  }

◆ testGetRootEntryId()

ComponentEntriesTest::testGetRootEntryId ( )

Definition at line 92 of file ComponentEntriesTest.php.

92  : void
93  {
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());
99  }

◆ testIsParentOfEntry()

ComponentEntriesTest::testIsParentOfEntry ( )

Definition at line 131 of file ComponentEntriesTest.php.

131  : void
132  {
133  $this->assertEquals(false, $this->entries->isParentOfEntry("Entry2", "Entry1"));
134  $this->assertEquals(true, $this->entries->isParentOfEntry("Entry1", "Entry2"));
135  }

◆ testJsonSerialize()

ComponentEntriesTest::testJsonSerialize ( )

Definition at line 161 of file ComponentEntriesTest.php.

161  : void
162  {
163  $entries = new Entries();
164 
165  $this->assertEquals([], $entries->jsonSerialize());
166  $this->assertEquals($this->entries_data, $this->entries->jsonSerialize());
167  }

Field Documentation

◆ $entries

Entries ComponentEntriesTest::$entries
protected

Definition at line 35 of file ComponentEntriesTest.php.

◆ $entries_data

ComponentEntriesTest::$entries_data
protected

Definition at line 34 of file ComponentEntriesTest.php.

◆ $entry

Entry ComponentEntriesTest::$entry
protected

Definition at line 36 of file ComponentEntriesTest.php.

◆ $entry_data

array ComponentEntriesTest::$entry_data
protected

Definition at line 37 of file ComponentEntriesTest.php.


The documentation for this class was generated from the following file: