ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
RendererTest.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
23use PHPUnit\Framework\TestCase;
29
30class RendererTest extends TestCase
31{
32 protected Reader $reader;
35
36 public function setUp(): void
37 {
38 $this->reader = new Reader(
40 );
41 $this->resolver = new Resolver();
42 $this->renderer = new Renderer();
43 }
44
45 #[\PHPUnit\Framework\Attributes\DataProvider('scenarios')]
46 public function testScenario($scenario_file, $result_file, $components)
47 {
48 require_once(__DIR__ . "/scenarios/$scenario_file");
49
50 $components = array_map(fn($c) => $this->reader->read(new $c()), $components);
51 $resolved = $this->resolver->resolveDependencies([], ...$components);
52
53 $result = $this->renderer->render(...$resolved);
54
55 $expected = file_get_contents(__DIR__ . "/scenarios/$result_file");
56 $this->assertEquals($expected, $result);
57 }
58
59 public static function scenarios()
60 {
61 return [
62 "no dependencies" => ["scenario1.php", "result1.php",
63 [
64 \ILIAS\Component\Tests\Dependencies\Scenario1\ComponentA::class
65 ]
66 ],
67 "pull dependency" => ["scenario2.php", "result2.php",
68 [
69 \ILIAS\Component\Tests\Dependencies\Scenario2\ComponentA::class,
70 \ILIAS\Component\Tests\Dependencies\Scenario2\ComponentB::class
71 ]
72 ],
73 "use dependency" => ["scenario3.php", "result3.php",
74 [
75 \ILIAS\Component\Tests\Dependencies\Scenario3\ComponentA::class,
76 \ILIAS\Component\Tests\Dependencies\Scenario3\ComponentB::class
77 ]
78 ],
79 "seek dependency" => ["scenario4.php", "result4.php",
80 [
81 \ILIAS\Component\Tests\Dependencies\Scenario4\ComponentA::class,
82 \ILIAS\Component\Tests\Dependencies\Scenario4\ComponentB::class,
83 \ILIAS\Component\Tests\Dependencies\Scenario4\ComponentC::class
84 ]
85 ],
86 "render entry points" => ["scenario5.php", "result5.php",
87 [
88 \ILIAS\Component\Tests\Dependencies\Scenario5\ComponentA::class
89 ]
90 ]
91 ];
92 }
93}
renderer()
$components
This takes a (hopefully resolved...) dependency tree and renders it in PHP to be used for initialisat...
Definition: Renderer.php:28
testScenario($scenario_file, $result_file, $components)