22 protected function setUp() : void
24 $this->db = $this->createMock(\ilDBInterface::class);
26 public function _shouldDescendToDirectory(
string $dir)
28 return $this->shouldDescendToDirectory($dir);
30 public function _getFilesIn(
string $dir)
32 return $this->getFilesIn($dir);
34 public function _isInterestingFile(
string $file)
36 return $this->isInterestingFile($file);
38 public function _getGUIClassNameFromClassPath(
string $file)
40 return $this->getGUIClassNameFromClassPath($file);
42 public function _getIlCtrlCalls(
string $content)
44 return $this->getIlCtrlCalls($content);
46 public function _getIlCtrlIsCalledBy(
string $content)
48 return $this->getIlCtrlIsCalledBy($content);
50 public function _containsClassDefinitionFor(
string $class,
string $content)
52 return $this->containsClassDefinitionFor($class, $content);
54 protected function getILIASAbsolutePath() :
string 62 protected function normalizePath(
string $path) :
string 72 $this->assertInstanceOf(ilCtrlStructureReader::class, $this->reader);
77 $dir = __DIR__ .
"/test_dir";
78 $result = $this->reader->_readDirTo($dir);
79 $this->assertInstanceOf(\ilCtrlStructure::class,
$result);
84 $dir = __DIR__ .
"/test_dir";
85 $result = $this->reader->_readDirTo($dir);
87 $expected_class_script = [
88 "ilmytestinggui" =>
"$dir/class.ilMyTestingGUI.php" 91 $expected_class_script,
92 iterator_to_array(
$result->getClassScripts())
98 $dir = __DIR__ .
"/test_dir/";
99 $result = $this->reader->_readDirTo($dir);
101 $expected_class_childs = [
102 "ilmytestinggui" => [
103 "ilmyothertestinggui" 105 "ilmythirdtestinggui" => [
110 $expected_class_childs,
111 iterator_to_array(
$result->getClassChildren())
117 $this->expectException(\Exception::class);
119 $dir = __DIR__ .
"/test_dir/";
121 $this->reader->comp_prefix =
"";
122 $ctrl_structure = new \ilCtrlStructure([
123 "ilmytestinggui" =>
"/some/other/dir/class.ilMyTestingGUI.php" 127 ->will($this->returnCallback(
function ($v, $_) {
132 ->will($this->returnCallback(
function (
$f, $v, $_, $__) {
133 return "$f = \"$v\"";
135 $this->db->expects($this->exactly(4))
136 ->method(
"manipulate")
138 [
"DELETE FROM ctrl_classfile WHERE comp_prefix = \"\""],
139 [
"DELETE FROM ctrl_classfile WHERE comp_prefix = \"\""],
140 [
"DELETE FROM ctrl_calls WHERE comp_prefix = \"\""],
141 [
"DELETE FROM ctrl_calls WHERE comp_prefix IS NULL"]
144 $result = $this->reader->_readDirTo($dir, $ctrl_structure);
149 $this->expectException(\Exception::class);
151 $dir = __DIR__ .
"/test_dir/";
152 $my_comp_prefix =
"mcp";
154 $this->reader->comp_prefix = $my_comp_prefix;
155 $ctrl_structure = new \ilCtrlStructure([
156 "ilmytestinggui" =>
"/some/other/dir/class.ilMyTestingGUI.php" 160 ->will($this->returnCallback(
function ($v, $_) {
165 ->will($this->returnCallback(
function (
$f, $v, $_, $__) {
166 return "$f = \"$v\"";
168 $this->db->expects($this->exactly(2))
169 ->method(
"manipulate")
171 [
"DELETE FROM ctrl_classfile WHERE comp_prefix = \"$my_comp_prefix\""],
172 [
"DELETE FROM ctrl_calls WHERE comp_prefix = \"$my_comp_prefix\""]
175 $result = $this->reader->_readDirTo($dir, $ctrl_structure);
180 $this->assertTrue($this->reader->_shouldDescendToDirectory(
"/foo"));
181 $this->assertTrue($this->reader->_shouldDescendToDirectory(
"/bar"));
182 $this->assertFalse($this->reader->_shouldDescendToDirectory(
"/data"));
183 $this->assertFalse($this->reader->_shouldDescendToDirectory(
"/Customizing"));
188 $dir = __DIR__ .
"/test_dir";
190 [
"class.ilMyTestingGUI.php",
"$dir/class.ilMyTestingGUI.php"],
191 [
"test_file",
"$dir/sub_test_dir/test_file"]
193 $result = iterator_to_array($this->reader->_getFilesIn($dir));
196 $this->assertEquals($expected,
$result);
201 $this->assertFalse($this->reader->_isInterestingFile(
"ilSCORM13Player.php"));
202 $this->assertTrue($this->reader->_isInterestingFile(
"class.ilSCORM13PlayerGUI.php"));
203 $this->assertTrue($this->reader->_isInterestingFile(
"class.ilMyTestingGUI.php"));
204 $this->assertFalse($this->reader->_isInterestingFile(
"foo.php"));
205 $this->assertFalse($this->reader->_isInterestingFile(
"picture.png"));
206 $this->assertFalse($this->reader->_isInterestingFile(
"icon.svg"));
207 $this->assertFalse($this->reader->_isInterestingFile(
"data.json"));
212 $this->assertNull($this->reader->_getGUIClassNameFromClassPath(
"/my/dir/ilSCORM13Player.php"));
213 $this->assertNull($this->reader->_getGUIClassNameFromClassPath(
"\\my\\dir\\ilSCORM13Player.php"));
214 $this->assertNull($this->reader->_getGUIClassNameFromClassPath(
"c:\\my\\dir\\ilSCORM13Player.php"));
215 $this->assertEquals(
"ilscorm13playergui", $this->reader->_getGUIClassNameFromClassPath(
"/my/dir/class.ilSCORM13PlayerGUI.php"));
216 $this->assertEquals(
"ilscorm13playergui", $this->reader->_getGUIClassNameFromClassPath(
"\\my\\dir\\class.ilSCORM13PlayerGUI.php"));
217 $this->assertEquals(
"ilscorm13playergui", $this->reader->_getGUIClassNameFromClassPath(
"c:\\my\\dir\\class.ilSCORM13PlayerGUI.php"));
218 $this->assertEquals(
"ilmytestinggui", $this->reader->_getGUIClassNameFromClassPath(
"/my/dir/class.ilMyTestingGUI.php"));
219 $this->assertEquals(
"ilmytestinggui", $this->reader->_getGUIClassNameFromClassPath(
"\\my\\dir\\class.ilMyTestingGUI.php"));
220 $this->assertEquals(
"ilmytestinggui", $this->reader->_getGUIClassNameFromClassPath(
"c:\\my\\dir\\class.ilMyTestingGUI.php"));
221 $this->assertNull($this->reader->_getGUIClassNameFromClassPath(
"/my/dir/foo.php"));
222 $this->assertNull($this->reader->_getGUIClassNameFromClassPath(
"\\my\\dir\\foo.php"));
223 $this->assertNull($this->reader->_getGUIClassNameFromClassPath(
"c:\\my\\dir\\foo.php"));
224 $this->assertNull($this->reader->_getGUIClassNameFromClassPath(
"/my/dir/picture.png"));
225 $this->assertNull($this->reader->_getGUIClassNameFromClassPath(
"\\my\\dir\\picture.png"));
226 $this->assertNull($this->reader->_getGUIClassNameFromClassPath(
"c:\\my\\dir\\picture.png"));
227 $this->assertNull($this->reader->_getGUIClassNameFromClassPath(
"/my/dir/icon.svg"));
228 $this->assertNull($this->reader->_getGUIClassNameFromClassPath(
"\\my\\dir\\icon.svg"));
229 $this->assertNull($this->reader->_getGUIClassNameFromClassPath(
"c:\\my\\dir\\icon.svg"));
230 $this->assertNull($this->reader->_getGUIClassNameFromClassPath(
"/my/dir/data.json"));
231 $this->assertNull($this->reader->_getGUIClassNameFromClassPath(
"\\my\\dir\\data.json"));
232 $this->assertNull($this->reader->_getGUIClassNameFromClassPath(
"c:\\my\\dir\\data.json"));
237 $gen = $this->reader->_getIlCtrlCalls(
239 class SomeRandomClass {
243 $this->assertNull($gen);
248 list($parent, $children) = $this->reader->_getIlCtrlCalls(
254 require_once
"./Services/Container/classes/class.ilContainerGUI.php";
273 "ilcourseregistrationgui",
274 "ilcourseobjectivesgui",
275 "ilobjcoursegroupinggui",
277 "illearningprogressgui",
279 "ilrepositorysearchgui" 285 $this->assertEquals(
"ilobjcoursegui", $parent);
286 $this->assertEquals($expected, $children);
291 $gen = $this->reader->_getIlCtrlIsCalledBy(
293 class SomeRandomClass {
297 $this->assertNull($gen);
302 list($parent, $children) = $this->reader->_getIlCtrlIsCalledBy(
308 require_once
"./Services/Container/classes/class.ilContainerGUI.php";
327 "ilcourseregistrationgui",
328 "ilcourseobjectivesgui",
329 "ilobjcoursegroupinggui",
331 "illearningprogressgui",
333 "ilrepositorysearchgui" 339 $this->assertEquals(
"ilobjcoursegui", $parent);
340 $this->assertEquals($expected, $children);
345 $res = $this->reader->_containsClassDefinitionFor(
348 class SomeRandomClass {
352 $this->assertTrue(
$res);
357 $res = $this->reader->_containsClassDefinitionFor(
360 class fooSomeRandomClass {
364 $this->assertFalse(
$res);
370 list($parent, $children) = $this->reader->_getIlCtrlCalls(
383 $expected = array_map(
"strtolower", [
384 "ilFormPropertyDispatchGUI",
385 "ILIAS\UICore\Test2GUI" 391 $this->assertEquals(strtolower(
"ILIAS\UICore\TestGUI"), $parent);
392 $this->assertEquals($expected, $children);
398 list($parent, $children) = $this->reader->_getIlCtrlIsCalledBy(
401 namespace ILIAS\UICore;
411 $expected = array_map(
"strtolower", [
412 "ilUIPluginRouterGUI",
413 "ILIAS\UICore\Test3GUI" 419 $this->assertEquals(strtolower(
"ILIAS\UICore\TestGUI"), $parent);
420 $this->assertEquals($expected, $children);
testGetIlCtrlIsCalledByWithNamespaces()
testReadRemovesDuplicateCallsInDatabase()
Class ChatMainBarProvider .
The CtrlStructure knows how GUIs call each other and where the code of the guis is located...
testReadRemovesDuplicateFilesInDatabaseIfCompPrefixIsSet()
testShouldDescendToDirectory()
testContainsClassDefinitionFor()
testGetIlCtrlIsCalledByNoContent()
testGetIlCtrlCallsWithNamespaces()
testGetIlCtrlCallsNoContent()
Class ilCtrlStructureReader.
testGetIlCtrlCallsWithContent()
foreach($_POST as $key=> $value) $res
testReadClassScriptIsAsExpected()
testDoesNotContainClassDefinitionFor()
testGetIlCtrlIsCalledByWithContent()
testReadClassChildsIsAsExpected()
testGetGUIClassNameFromClassPath()