ILIAS  trunk Revision v11.0_alpha-2658-ge2404539063
RendererTest.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
28 
29 class RendererTest extends TestCase
30 {
31  protected Reader $reader;
32  protected Resolver $resolver;
33  protected Renderer $renderer;
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()
$c
Definition: deliver.php:25
$components
testScenario($scenario_file, $result_file, $components)