36 [
"components/ILIAS",
"A_Module",
"/path/to/module.xml"],
37 [
"components/ILIAS",
"A_Service",
"/other/path/to/service.xml"]
40 protected function setUp(): void
42 $this->processor1 = $this->createMock(ilComponentDefinitionProcessorMock1::class);
43 $this->processor2 = $this->createMock(ilComponentDefinitionProcessorMock2::class);
46 protected function getComponents():
Iterator 50 public $read_files = [];
51 protected function readFile(
string $path):
string 53 $this->read_files[] =
$path;
54 if ($path ===
"/path/to/module.xml") {
56 '<?xml version = "1.0" encoding = "UTF-8"?> 57 <module a1="a1" a2="a2"> 64 if ($path ===
"/other/path/to/service.xml") {
66 '<?xml version = "1.0" encoding = "UTF-8"?> 78 ->expects($this->once())
82 ->expects($this->once())
86 $this->reader->purge();
95 public function _getComponents(): array
97 return iterator_to_array($this->getComponents());
101 $components = $reader->_getComponents();
103 $this->assertIsArray($components);
104 $this->assertContains([
"components/ILIAS",
"Course", realpath(__DIR__ .
"/../../../../components/ILIAS/Course/module.xml")], $components);
105 $this->assertContains([
"components/ILIAS",
"Component", realpath(__DIR__ .
"/../../../../components/ILIAS/Component/service.xml")], $components);
110 $processor1_stack = [];
112 ->method(
"beginComponent")
113 ->willReturnCallback(
function ($s1, $s2) use (&$processor1_stack) {
114 $processor1_stack[] =
"beginComponent";
115 $processor1_stack[] = $s1;
116 $processor1_stack[] = $s2;
119 ->method(
"endComponent")
120 ->willReturnCallback(
function ($s1, $s2) use (&$processor1_stack) {
121 $processor1_stack[] =
"endComponent";
122 $processor1_stack[] = $s1;
123 $processor1_stack[] = $s2;
127 ->willReturnCallback(
function ($s1, $s2) use (&$processor1_stack) {
128 $processor1_stack[] =
"beginTag";
129 $processor1_stack[] = $s1;
130 $processor1_stack[] = $s2;
134 ->willReturnCallback(
function ($s1) use (&$processor1_stack) {
135 $processor1_stack[] =
"endTag";
136 $processor1_stack[] = $s1;
139 $processor2_stack = [];
141 ->method(
"beginComponent")
142 ->willReturnCallback(
function ($s1, $s2) use (&$processor2_stack) {
143 $processor2_stack[] =
"beginComponent";
144 $processor2_stack[] = $s1;
145 $processor2_stack[] = $s2;
148 ->method(
"endComponent")
149 ->willReturnCallback(
function ($s1, $s2) use (&$processor2_stack) {
150 $processor2_stack[] =
"endComponent";
151 $processor2_stack[] = $s1;
152 $processor2_stack[] = $s2;
156 ->willReturnCallback(
function ($s1, $s2) use (&$processor2_stack) {
157 $processor2_stack[] =
"beginTag";
158 $processor2_stack[] = $s1;
159 $processor2_stack[] = $s2;
163 ->willReturnCallback(
function ($s1) use (&$processor2_stack) {
164 $processor2_stack[] =
"endTag";
165 $processor2_stack[] = $s1;
169 $this->reader->readComponentDefinitions();
174 $expected_processor_stack = [
179 "module", [
"a1" =>
"a1",
"a2" =>
"a2"],
195 self::$components[0][1],
196 self::$components[0][0],
198 self::$components[1][1],
199 self::$components[1][0],
205 self::$components[1][1],
206 self::$components[1][0],
208 $this->assertEquals($expected_processor_stack, $processor1_stack);
209 $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()
__construct(Container $dic, ilPlugin $plugin)