ILIAS  release_8 Revision v8.24
ilComponentBuildPluginInfoObjectiveTest Class Reference
+ Inheritance diagram for ilComponentBuildPluginInfoObjectiveTest:
+ Collaboration diagram for ilComponentBuildPluginInfoObjectiveTest:

Public Member Functions

 testScanningTopLevel ()
 
 testScanningComplete ()
 
 testPluginsAdded ()
 
 testScanDir ()
 
 testIsDir ()
 
 testIsDotFile ()
 
 testAddPlugins ()
 
 testBuildPluginPath ()
 

Protected Member Functions

 setUp ()
 

Private Attributes

ilComponentBuildPluginInfoObjective $builder = null
 

Detailed Description

Definition at line 20 of file ilComponentBuildPluginInfoObjectiveTest.php.

Member Function Documentation

◆ setUp()

ilComponentBuildPluginInfoObjectiveTest::setUp ( )
protected

Definition at line 24 of file ilComponentBuildPluginInfoObjectiveTest.php.

24 : void
25 {
26 $this->scanned = [];
27 $this->dirs = [];
28 $this->read = [];
29 $this->files = [];
30 $this->added = [];
31 $this->builder = new class ($this) extends ilComponentBuildPluginInfoObjective {
32 protected const BASE_PATH = "";
34 public function __construct($test)
35 {
36 $this->test = $test;
37 }
38 protected function scanDir(string $dir): array
39 {
40 $this->test->scanned[] = $dir;
41 return $this->test->dirs[$dir] ?? [];
42 }
43 public function _scanDir(string $dir): array
44 {
45 return parent::scanDir($dir);
46 }
47 protected function isDir(string $dir): bool
48 {
49 return true;
50 }
51 public function _isDir(string $dir): bool
52 {
53 return parent::isDir($dir);
54 }
55 public function _isDotFile(string $file): bool
56 {
57 return parent::isDotFile($file);
58 }
59 protected function buildPluginPath(string $type, string $component, string $slot, string $plugin): string
60 {
61 return $this->test->files[parent::buildPluginPath($type, $component, $slot, $plugin)];
62 }
63
64 public function _buildPluginPath(string $type, string $component, string $slot, string $plugin): string
65 {
66 return parent::buildPluginPath($type, $component, $slot, $plugin);
67 }
68 protected function addPlugin(array &$data, string $type, string $component, string $slot, string $plugin): void
69 {
70 $this->test->added[] = "$type/$component/$slot/$plugin";
71 }
72 public function _addPlugin(array &$data, string $type, string $component, string $slot, string $plugin): void
73 {
74 parent::addPlugin($data, $type, $component, $slot, $plugin);
75 }
76 };
77 }
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$type

References $data, XapiProxy\$plugin, $type, and ILIAS\GlobalScreen\Provider\__construct().

+ Here is the call graph for this function:

◆ testAddPlugins()

ilComponentBuildPluginInfoObjectiveTest::testAddPlugins ( )

Definition at line 160 of file ilComponentBuildPluginInfoObjectiveTest.php.

160 : void
161 {
162 $data = [];
163 $this->files["Modules/Module1/Slot1/Plugin1/"] = __DIR__ . "/";
164 $this->builder->_addPlugin($data, "Modules", "Module1", "Slot1", "Plugin1");
165
166 $expected = [
167 "tstplg" => [
168 "Modules",
169 "Module1",
170 "Slot1",
171 "Plugin1",
172 "1.9.1",
173 "8.0",
174 "8.999",
175 "Richard Klees",
176 "richard.klees@concepts-and-training.de",
177 true,
178 false,
179 null
180 ]
181 ];
182 $this->assertEquals($expected, $data);
183 }

References $data.

◆ testBuildPluginPath()

ilComponentBuildPluginInfoObjectiveTest::testBuildPluginPath ( )

Definition at line 185 of file ilComponentBuildPluginInfoObjectiveTest.php.

185 : void
186 {
187 $this->assertEquals("TYPE/COMPONENT/SLOT/PLUGIN/", $this->builder->_buildPluginPath("TYPE", "COMPONENT", "SLOT", "PLUGIN"));
188 }

◆ testIsDir()

ilComponentBuildPluginInfoObjectiveTest::testIsDir ( )

Definition at line 145 of file ilComponentBuildPluginInfoObjectiveTest.php.

145 : void
146 {
147 // Use the component directory, because this should be mostly stable.
148 $expected = true;
149 $actual = $this->builder->_isDir(__DIR__ . "/../..");
150 $this->assertEquals($expected, $actual);
151 }

◆ testIsDotFile()

ilComponentBuildPluginInfoObjectiveTest::testIsDotFile ( )

Definition at line 153 of file ilComponentBuildPluginInfoObjectiveTest.php.

153 : void
154 {
155 $expected = true;
156 $actual = $this->builder->_isDotFile(".DS_Store");
157 $this->assertEquals($expected, $actual);
158 }

◆ testPluginsAdded()

ilComponentBuildPluginInfoObjectiveTest::testPluginsAdded ( )

Definition at line 109 of file ilComponentBuildPluginInfoObjectiveTest.php.

109 : void
110 {
111 $this->dirs = [
112 "Modules" => ["Module1"],
113 "Services" => ["Service1"],
114 "Modules/Module1" => ["Slot1"],
115 "Services/Service1" => ["Slot2"],
116 "Modules/Module1/Slot1" => ["Plugin1", "Plugin2"],
117 "Services/Service1/Slot2" => ["Plugin3"]
118 ];
119
120 $this->builder->build();
121
122 $expected = [
123 "Modules/Module1/Slot1/Plugin1",
124 "Modules/Module1/Slot1/Plugin2",
125 "Services/Service1/Slot2/Plugin3"
126 ];
127 sort($expected);
128 sort($this->added);
129 $this->assertEquals($expected, $this->added);
130 }

◆ testScanDir()

ilComponentBuildPluginInfoObjectiveTest::testScanDir ( )

Definition at line 132 of file ilComponentBuildPluginInfoObjectiveTest.php.

132 : void
133 {
134 // Use the component directory without artifacts, because this should be mostly stable.
135 $expected = ["ROADMAP.md", "classes", "exceptions", "maintenance.json", "service.xml", "test"];
136 $actual = array_values(
137 array_diff(
138 $this->builder->_scanDir(__DIR__ . "/../.."),
139 ["artifacts", ".DS_Store"] // .DS_Store is a macOS artifact which is not relevant for the test.
140 )
141 );
142 $this->assertEquals($expected, $actual);
143 }

◆ testScanningComplete()

ilComponentBuildPluginInfoObjectiveTest::testScanningComplete ( )

Definition at line 89 of file ilComponentBuildPluginInfoObjectiveTest.php.

89 : void
90 {
91 $this->dirs = [
92 "Modules" => ["Module1", "Module2"],
93 "Services" => ["Service1"],
94 "Modules/Module1" => ["Slot1", "Slot2"],
95 "Modules/Module2" => [],
96 "Services/Service1" => ["Slot3",".DS_Store"] // .DS_Store should be skipped
97 ];
98
99 $this->builder->build();
100
101 $expected = ["Modules", "Services", "Modules/Module1", "Modules/Module2",
102 "Services/Service1", "Modules/Module1/Slot1", "Modules/Module1/Slot2",
103 "Services/Service1/Slot3"];
104 sort($expected);
105 sort($this->scanned);
106 $this->assertEquals($expected, $this->scanned);
107 }

◆ testScanningTopLevel()

ilComponentBuildPluginInfoObjectiveTest::testScanningTopLevel ( )

Definition at line 79 of file ilComponentBuildPluginInfoObjectiveTest.php.

79 : void
80 {
81 $this->builder->build();
82
83 $expected = ["Modules", "Services"];
84 sort($expected);
85 sort($this->scanned);
86 $this->assertEquals($expected, $this->scanned);
87 }

Field Documentation

◆ $builder

ilComponentBuildPluginInfoObjective ilComponentBuildPluginInfoObjectiveTest::$builder = null
private

Definition at line 22 of file ilComponentBuildPluginInfoObjectiveTest.php.


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