3 declare(strict_types=1);
27 $this->assertTrue($structure->isBaseClass(
'baseclass1'));
28 $this->assertTrue($structure->isBaseClass(
'baseclass2'));
29 $this->assertTrue($structure->isBaseClass(
'baseclass3'));
30 $this->assertFalse($structure->isBaseClass(
'baseclass4'));
31 $this->assertFalse($structure->isBaseClass(
''));
60 $this->assertEmpty($structure->getUnsafeCommandsByCid(
'cid1'));
61 $this->assertEmpty($structure->getUnsafeCommandsByName(
'cmdClass1'));
63 $this->assertEquals([
'postCmd1'], $structure->getSafeCommandsByCid(
'cid1'));
64 $this->assertEquals([
'postCmd1'], $structure->getSafeCommandsByName(
'cmdClass1'));
66 $this->assertEquals([
'getCmd1'], $structure->getUnsafeCommandsByCid(
'cid2'));
67 $this->assertEquals([
'getCmd1'], $structure->getUnsafeCommandsByName(
'cmdClass2'));
69 $this->assertEmpty($structure->getSafeCommandsByCid(
'cid2'));
70 $this->assertEmpty($structure->getSafeCommandsByName(
'cmdClass2'));
72 $this->assertEmpty($structure->getUnsafeCommandsByName(
''));
73 $this->assertEmpty($structure->getUnsafeCommandsByCid(
''));
75 $this->assertEmpty($structure->getSafeCommandsByCid(
''));
76 $this->assertEmpty($structure->getSafeCommandsByName(
''));
102 $this->assertEquals(
'Class1', $structure->getObjNameByCid(
'cid1'));
103 $this->assertEquals(
'Class1', $structure->getObjNameByName(
'Class1'));
104 $this->assertEquals(
'Class2', $structure->getObjNameByCid(
'cid2'));
105 $this->assertEquals(
'Class2', $structure->getObjNameByName(
'Class2'));
106 $this->assertNull($structure->getObjNameByCid(
'cid3'));
107 $this->assertNull($structure->getObjNameByName(
'Class3'));
109 $this->assertEquals(
'class1', $structure->getClassNameByCid(
'cid1'));
110 $this->assertEquals(
'cid1', $structure->getClassCidByName(
'Class1'));
111 $this->assertEquals(
'class2', $structure->getClassNameByCid(
'cid2'));
112 $this->assertEquals(
'cid2', $structure->getClassCidByName(
'Class2'));
113 $this->assertNull($structure->getClassNameByCid(
'cid3'));
114 $this->assertNull($structure->getClassCidByName(
'Class3'));
116 $this->assertEquals(
'./path/1', $structure->getRelativePathByCid(
'cid1'));
117 $this->assertEquals(
'./path/1', $structure->getRelativePathByName(
'Class1'));
118 $this->assertEquals(
'./path/2', $structure->getRelativePathByCid(
'cid2'));
119 $this->assertEquals(
'./path/2', $structure->getRelativePathByName(
'Class2'));
120 $this->assertNull($structure->getRelativePathByCid(
'cid3'));
121 $this->assertNull($structure->getRelativePathByName(
'Class3'));
123 $this->assertEquals([
'class2'], $structure->getChildrenByCid(
'cid1'));
124 $this->assertEquals([
'class2'], $structure->getChildrenByName(
'Class1'));
125 $this->assertNull($structure->getChildrenByCid(
'cid2'));
126 $this->assertNull($structure->getChildrenByName(
'Class2'));
127 $this->assertNull($structure->getChildrenByCid(
'cid3'));
128 $this->assertNull($structure->getChildrenByName(
'Class3'));
130 $this->assertNull($structure->getParentsByCid(
'cid1'));
131 $this->assertNull($structure->getParentsByName(
'Class1'));
132 $this->assertEquals([
'class1'], $structure->getParentsByCid(
'cid2'));
133 $this->assertEquals([
'class1'], $structure->getParentsByName(
'Class2'));
134 $this->assertNull($structure->getParentsByCid(
'cid3'));
135 $this->assertNull($structure->getParentsByName(
'Class3'));
142 $structure->setPermanentParameterByClass(
'Class1',
'param1');
143 $structure->setPermanentParameterByClass(
'Class1',
'param2');
144 $structure->setPermanentParameterByClass(
'Class2',
'param1');
147 $this->assertEquals([
'param1',
'param2'], $structure->getPermanentParametersByClass(
'Class1'));
148 $this->assertEquals([
'param1'], $structure->getPermanentParametersByClass(
'Class2'));
150 $structure->removeSingleParameterByClass(
'Class1',
'param1');
154 $this->assertEquals([
'param2'], $structure->getPermanentParametersByClass(
'Class1'));
155 $this->assertEquals([
'param1'], $structure->getPermanentParametersByClass(
'Class2'));
157 $structure->removePermanentParametersByClass(
'Class1');
161 $this->assertNull($structure->getPermanentParametersByClass(
'Class1'));
162 $this->assertEquals([
'param1'], $structure->getPermanentParametersByClass(
'Class2'));
165 $parameter_name =
'$param';
166 $this->expectException(ilCtrlException::class);
167 $this->expectExceptionMessage(
"Cannot save parameter '$parameter_name', as it contains invalid characters.");
168 $structure->setPermanentParameterByClass(
'Class2', $parameter_name);
177 $this->expectException(ilCtrlException::class);
178 $structure->setPermanentParameterByClass(
'a_class', $protected_parameter);
185 $structure->setTemporaryParameterByClass(
'Class1',
'param1', 1);
186 $structure->setTemporaryParameterByClass(
'Class1',
'param2',
'2');
187 $structure->setTemporaryParameterByClass(
'Class2',
'param1',
true);
190 $this->assertEquals([
'param1' =>
true], $structure->getTemporaryParametersByClass(
'Class2'));
192 [
'param1' => 1,
'param2' =>
'2'],
193 $structure->getTemporaryParametersByClass(
'Class1')
196 $structure->removeSingleParameterByClass(
'Class1',
'param1');
200 $this->assertEquals([
'param1' =>
true], $structure->getTemporaryParametersByClass(
'Class2'));
203 $structure->getTemporaryParametersByClass(
'Class1')
206 $structure->removeTemporaryParametersByClass(
'Class1');
210 $this->assertEquals([
'param1' =>
true], $structure->getTemporaryParametersByClass(
'Class2'));
211 $this->assertNull($structure->getTemporaryParametersByClass(
'Class1'));
214 $parameter_name =
'$param';
215 $this->expectException(ilCtrlException::class);
216 $this->expectExceptionMessage(
"Cannot save parameter '$parameter_name', as it contains invalid characters.");
217 $structure->setTemporaryParameterByClass(
'Class3', $parameter_name, 0);
224 $test_url =
'https://domain.com/test/url';
225 $structure->setReturnTargetByClass(
'Class1', $test_url);
226 $this->assertEquals($test_url, $structure->getReturnTargetByClass(
'Class1'));
227 $this->assertNull($structure->getReturnTargetByClass(
'Class2'));
Class ilCtrlStructureTest.
Class ilCtrlStructure holds the currently read control structure.
testStructureSecurityInfos()
testStructureBaseClasses()
const KEY_UNSAFE_COMMANDS
testStructureSavedParameters()
const KEY_CLASS_CID
array key constants that are used for certain information.
testStructureSavedParametersWithProtectedKey($protected_parameter)
getProtectedParameters
testStructureReturnTargets()
testStructureTemporaryParameters()