ILIAS  trunk Revision v11.0_alpha-1749-g1a06bdef097
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
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 
45  public function testScenario($scenario_file, $result_file, $components)
46  {
47  require_once(__DIR__ . "/scenarios/$scenario_file");
48 
49  $components = array_map(fn($c) => $this->reader->read(new $c()), $components);
50  $resolved = $this->resolver->resolveDependencies([], ...$components);
51 
52  $result = $this->renderer->render(...$resolved);
53 
54  $expected = file_get_contents(__DIR__ . "/scenarios/$result_file");
55  $this->assertEquals($expected, $result);
56  }
57 
58  public static function scenarios()
59  {
60  return [
61  "no dependencies" => ["scenario1.php", "result1.php",
62  [
63  \ILIAS\Component\Tests\Dependencies\Scenario1\ComponentA::class
64  ]
65  ],
66  "pull dependency" => ["scenario2.php", "result2.php",
67  [
68  \ILIAS\Component\Tests\Dependencies\Scenario2\ComponentA::class,
69  \ILIAS\Component\Tests\Dependencies\Scenario2\ComponentB::class
70  ]
71  ],
72  "use dependency" => ["scenario3.php", "result3.php",
73  [
74  \ILIAS\Component\Tests\Dependencies\Scenario3\ComponentA::class,
75  \ILIAS\Component\Tests\Dependencies\Scenario3\ComponentB::class
76  ]
77  ],
78  "seek dependency" => ["scenario4.php", "result4.php",
79  [
80  \ILIAS\Component\Tests\Dependencies\Scenario4\ComponentA::class,
81  \ILIAS\Component\Tests\Dependencies\Scenario4\ComponentB::class,
82  \ILIAS\Component\Tests\Dependencies\Scenario4\ComponentC::class
83  ]
84  ],
85  "render entry points" => ["scenario5.php", "result5.php",
86  [
87  \ILIAS\Component\Tests\Dependencies\Scenario5\ComponentA::class
88  ]
89  ]
90  ];
91  }
92 }
renderer()
$c
Definition: deliver.php:25
$components
testScenario($scenario_file, $result_file, $components)
scenarios