ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
ilComponentBuildPluginInfoObjectiveTest Class Reference
+ Inheritance diagram for ilComponentBuildPluginInfoObjectiveTest:
+ Collaboration diagram for ilComponentBuildPluginInfoObjectiveTest:

Public Member Functions

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

Data Fields

array $scanned
 
array $dirs
 
array $read
 
array $files
 
array $added
 

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 29 of file ilComponentBuildPluginInfoObjectiveTest.php.

References $data, XapiProxy\$plugin, and ILIAS\MetaData\Repository\Validation\Data\__construct().

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

◆ testAddPlugins()

ilComponentBuildPluginInfoObjectiveTest::testAddPlugins ( )

Definition at line 165 of file ilComponentBuildPluginInfoObjectiveTest.php.

References $data.

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

◆ testBuildPluginPath()

ilComponentBuildPluginInfoObjectiveTest::testBuildPluginPath ( )

Definition at line 190 of file ilComponentBuildPluginInfoObjectiveTest.php.

190  : void
191  {
192  $this->assertEquals("TYPE/COMPONENT/SLOT/PLUGIN/", $this->builder->_buildPluginPath("TYPE", "COMPONENT", "SLOT", "PLUGIN"));
193  }

◆ testIsDir()

ilComponentBuildPluginInfoObjectiveTest::testIsDir ( )

Definition at line 150 of file ilComponentBuildPluginInfoObjectiveTest.php.

150  : void
151  {
152  // Use the component directory, because this should be mostly stable.
153  $expected = true;
154  $actual = $this->builder->_isDir(__DIR__ . "/../..");
155  $this->assertEquals($expected, $actual);
156  }

◆ testIsDotFile()

ilComponentBuildPluginInfoObjectiveTest::testIsDotFile ( )

Definition at line 158 of file ilComponentBuildPluginInfoObjectiveTest.php.

158  : void
159  {
160  $expected = true;
161  $actual = $this->builder->_isDotFile(".DS_Store");
162  $this->assertEquals($expected, $actual);
163  }

◆ testPluginsAdded()

ilComponentBuildPluginInfoObjectiveTest::testPluginsAdded ( )

Definition at line 114 of file ilComponentBuildPluginInfoObjectiveTest.php.

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

◆ testScanDir()

ilComponentBuildPluginInfoObjectiveTest::testScanDir ( )

Definition at line 137 of file ilComponentBuildPluginInfoObjectiveTest.php.

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

◆ testScanningComplete()

ilComponentBuildPluginInfoObjectiveTest::testScanningComplete ( )

Definition at line 94 of file ilComponentBuildPluginInfoObjectiveTest.php.

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

◆ testScanningTopLevel()

ilComponentBuildPluginInfoObjectiveTest::testScanningTopLevel ( )

Definition at line 84 of file ilComponentBuildPluginInfoObjectiveTest.php.

84  : void
85  {
86  $this->builder->build();
87 
88  $expected = ["Modules", "Services"];
89  sort($expected);
90  sort($this->scanned);
91  $this->assertEquals($expected, $this->scanned);
92  }

Field Documentation

◆ $added

array ilComponentBuildPluginInfoObjectiveTest::$added

Definition at line 27 of file ilComponentBuildPluginInfoObjectiveTest.php.

◆ $builder

ilComponentBuildPluginInfoObjective ilComponentBuildPluginInfoObjectiveTest::$builder = null
private

Definition at line 22 of file ilComponentBuildPluginInfoObjectiveTest.php.

◆ $dirs

array ilComponentBuildPluginInfoObjectiveTest::$dirs

Definition at line 24 of file ilComponentBuildPluginInfoObjectiveTest.php.

◆ $files

array ilComponentBuildPluginInfoObjectiveTest::$files

Definition at line 26 of file ilComponentBuildPluginInfoObjectiveTest.php.

◆ $read

array ilComponentBuildPluginInfoObjectiveTest::$read

Definition at line 25 of file ilComponentBuildPluginInfoObjectiveTest.php.

◆ $scanned

array ilComponentBuildPluginInfoObjectiveTest::$scanned

Definition at line 23 of file ilComponentBuildPluginInfoObjectiveTest.php.


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