34     public static array $components = [
    35         [
"Modules", 
"A_Module", 
"/path/to/module.xml"],
    36         [
"Services", 
"A_Service", 
"/other/path/to/service.xml"]
    39     protected function setUp(): void
    41         $this->processor1 = $this->createMock(ilComponentDefinitionProcessorMock1::class);
    42         $this->processor2 = $this->createMock(ilComponentDefinitionProcessorMock2::class);
    45             protected function getComponents(): 
Iterator    49             public $read_files = [];
    50             protected function readFile(
string $path): 
string    52                 $this->read_files[] = 
$path;
    53                 if ($path === 
"/path/to/module.xml") {
    55 '<?xml version = "1.0" encoding = "UTF-8"?>    56 <module a1="a1" a2="a2">    63                 if ($path === 
"/other/path/to/service.xml") {
    65 '<?xml version = "1.0" encoding = "UTF-8"?>    77             ->expects($this->once())
    81             ->expects($this->once())
    85         $this->reader->purge();
    94             public function _getComponents(): array
    96                 return iterator_to_array($this->getComponents());
   100         $components = $reader->_getComponents();
   102         $this->assertIsArray($components);
   103         $this->assertContains([
"Modules", 
"Course", realpath(__DIR__ . 
"/../../../Modules/Course/module.xml")], $components);
   104         $this->assertContains([
"Services", 
"Component", realpath(__DIR__ . 
"/../../../Services/Component/service.xml")], $components);
   109         $processor1_stack = [];
   111             ->method(
"beginComponent")
   112             ->willReturnCallback(
function ($s1, $s2) use (&$processor1_stack) {
   113                 $processor1_stack[] = 
"beginComponent";
   114                 $processor1_stack[] = $s1;
   115                 $processor1_stack[] = $s2;
   118             ->method(
"endComponent")
   119             ->willReturnCallback(
function ($s1, $s2) use (&$processor1_stack) {
   120                 $processor1_stack[] = 
"endComponent";
   121                 $processor1_stack[] = $s1;
   122                 $processor1_stack[] = $s2;
   126             ->willReturnCallback(
function ($s1, $s2) use (&$processor1_stack) {
   127                 $processor1_stack[] = 
"beginTag";
   128                 $processor1_stack[] = $s1;
   129                 $processor1_stack[] = $s2;
   133             ->willReturnCallback(
function ($s1) use (&$processor1_stack) {
   134                 $processor1_stack[] = 
"endTag";
   135                 $processor1_stack[] = $s1;
   138         $processor2_stack = [];
   140             ->method(
"beginComponent")
   141             ->willReturnCallback(
function ($s1, $s2) use (&$processor2_stack) {
   142                 $processor2_stack[] = 
"beginComponent";
   143                 $processor2_stack[] = $s1;
   144                 $processor2_stack[] = $s2;
   147             ->method(
"endComponent")
   148             ->willReturnCallback(
function ($s1, $s2) use (&$processor2_stack) {
   149                 $processor2_stack[] = 
"endComponent";
   150                 $processor2_stack[] = $s1;
   151                 $processor2_stack[] = $s2;
   155             ->willReturnCallback(
function ($s1, $s2) use (&$processor2_stack) {
   156                 $processor2_stack[] = 
"beginTag";
   157                 $processor2_stack[] = $s1;
   158                 $processor2_stack[] = $s2;
   162             ->willReturnCallback(
function ($s1) use (&$processor2_stack) {
   163                 $processor2_stack[] = 
"endTag";
   164                 $processor2_stack[] = $s1;
   168         $this->reader->readComponentDefinitions();
   171         $this->assertEquals([self::$components[0][2], self::$components[1][2]], $this->reader->read_files);
   173         $expected_processor_stack = [
   175             self::$components[0][1], 
   176             self::$components[0][0], 
   178             "module", [
"a1" => 
"a1", 
"a2" => 
"a2"],
   194             self::$components[0][1], 
   195             self::$components[0][0], 
   197             self::$components[1][1], 
   198             self::$components[1][0], 
   204             self::$components[1][1], 
   205             self::$components[1][0], 
   207         $this->assertEquals($expected_processor_stack, $processor1_stack);
   208         $this->assertEquals($expected_processor_stack, $processor2_stack);
 ilComponentDefinitionProcessor $processor1
 
ilComponentDefinitionProcessor $processor2
 
An ilComponentDefinitionProcessor processes some attributes from a component.xml (i.e. 
 
ilComponentDefinitionReader $reader
 
testReadComponentDefinitions()