ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
ilCtrlStructureTest Class Reference
+ Inheritance diagram for ilCtrlStructureTest:
+ Collaboration diagram for ilCtrlStructureTest:

Public Member Functions

 testAddClassScript ()
 
 testAddClassScriptPanicsOnDuplicate ()
 
 testAddClassChild ()
 
 testConstructor ()
 
 testGetClassScriptOf ()
 

Protected Member Functions

 setUp ()
 

Detailed Description

Definition at line 6 of file ilCtrlStructureTest.php.

Member Function Documentation

◆ setUp()

ilCtrlStructureTest::setUp ( )
protected

Definition at line 8 of file ilCtrlStructureTest.php.

8  : void
9  {
10  $this->ctrl_structure = new \ilCtrlStructure();
11  }

◆ testAddClassChild()

ilCtrlStructureTest::testAddClassChild ( )

Definition at line 42 of file ilCtrlStructureTest.php.

43  {
44  $this->ctrl_structure = $this->ctrl_structure
45  ->withClassChild("parent1", "child1")
46  ->withClassChild("parent2", "child2")
47  ->withClassChild("parent1", "child3");
48 
49  $expected = [
50  "parent1" => ["child1", "child3"],
51  "parent2" => ["child2"]
52  ];
53 
54  $this->assertEquals(
55  $expected,
56  iterator_to_array($this->ctrl_structure->getClassChildren())
57  );
58  }

◆ testAddClassScript()

ilCtrlStructureTest::testAddClassScript ( )

Definition at line 13 of file ilCtrlStructureTest.php.

14  {
15  $this->ctrl_structure = $this->ctrl_structure
16  ->withClassScript("class1", "file1")
17  ->withClassScript("class2", "file2")
18  ->withClassScript("class3", "file3")
19  ->withClassScript("class2", "file2");
20 
21  $expected = [
22  "class1" => "file1",
23  "class2" => "file2",
24  "class3" => "file3",
25  ];
26 
27  $this->assertEquals(
28  $expected,
29  iterator_to_array($this->ctrl_structure->getClassScripts())
30  );
31  }

◆ testAddClassScriptPanicsOnDuplicate()

ilCtrlStructureTest::testAddClassScriptPanicsOnDuplicate ( )

Definition at line 33 of file ilCtrlStructureTest.php.

34  {
35  $this->expectException(\RuntimeException::class);
36 
37  $this->ctrl_structure
38  ->withClassScript("class1", "file1")
39  ->withClassScript("class1", "file2");
40  }

◆ testConstructor()

ilCtrlStructureTest::testConstructor ( )

Definition at line 60 of file ilCtrlStructureTest.php.

61  {
62  $scripts = [
63  "class1" => "file1",
64  "class2" => "file2",
65  "class3" => "file3",
66  ];
67 
68  $children = [
69  "parent1" => ["child1", "child3"],
70  "parent2" => ["child2"]
71  ];
72 
73  $ctrl_structure = new \ilCtrlStructure($scripts, $children);
74 
75  $this->assertEquals(
76  $scripts,
77  iterator_to_array($ctrl_structure->getClassScripts())
78  );
79 
80  $this->assertEquals(
81  $children,
82  iterator_to_array($ctrl_structure->getClassChildren())
83  );
84  }

◆ testGetClassScriptOf()

ilCtrlStructureTest::testGetClassScriptOf ( )

Definition at line 86 of file ilCtrlStructureTest.php.

87  {
88  $scripts = [
89  "class1" => "file1",
90  "class2" => "file2",
91  "class3" => "file3",
92  ];
93 
94  $ctrl_structure = new \ilCtrlStructure($scripts, []);
95 
96  $this->assertEquals("file1", $ctrl_structure->getClassScriptOf("class1"));
97  $this->assertEquals("file2", $ctrl_structure->getClassScriptOf("class2"));
98  $this->assertEquals("file3", $ctrl_structure->getClassScriptOf("class3"));
99  $this->assertSame(null, $ctrl_structure->getClassScriptOf("class4"));
100  }

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