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