19declare(strict_types=1);
21require_once(__DIR__ .
"/TestComponent.php");
22require_once(__DIR__ .
"/../Base.php");
45 $dr = $this->getDefaultRenderer();
46 $r = $dr->_getRendererFor(
new Glyph(
"up",
"up"));
47 $this->assertInstanceOf(ComponentRenderer::class, $r);
52 $dr = $this->getDefaultRenderer();
53 $r1 = $dr->_getRendererFor(
new Glyph(
"up",
"up"));
54 $r2 = $dr->_getRendererFor(
new Glyph(
"up",
"up"));
55 $this->assertTrue($r1 === $r2,
"Instances not equal");
60 $this->resource_registry = parent::getResourceRegistry();
66 $dr = $this->getDefaultRenderer();
69 $dr->render($component);
71 $this->assertEquals(array(
"test.js"), $this->resource_registry->resources);
93 return match ($component->text) {
94 $component1->text => $component1->text . $glue .
$renderer->render($component2),
95 $component2->text => $component2->text . $glue .
$renderer->render($component3),
96 $component3->text => $component3->text,
102 $this->createMock(Render\Loader::class),
103 $this->createMock(JavaScriptBinding::class),
107 public array $context_history = [];
110 Render\
Loader $component_renderer_loader,
123 protected function pushContext(
Component $component):
void
125 parent::pushContext($component);
126 $this->context_history[] = $this->getContexts();
129 protected function popContext():
void
131 parent::popContext();
132 $this->context_history[] = $this->getContexts();
136 $expected_context_history = [
138 [$component1, $component2],
139 [$component1, $component2, $component3],
140 [$component1, $component2],
146 $component1->text . $glue .
147 $component2->text . $glue .
152 $this->assertEquals($expected_context_history,
$renderer->context_history);
153 $this->assertEquals($expected_html, $html);
161 $this->assertEquals(
"foo", $html);
169 $this->getTemplateFactory()->getTemplate(
"tpl.main.html",
false,
false)
173 $this->assertEquals(
"foo", $html);
180 new ilJavaScriptBinding($this->getTemplateFactory()->getTemplate(
"tpl.main.html",
false,
false))
183 $this->assertEquals(
'foo<script data-replace-marker="script">id:foo.id content:foo</script>', $html);
191 new ilJavaScriptBinding($this->getTemplateFactory()->getTemplate(
"tpl.main.html",
false,
false))
194 $this->assertEquals(
'foo<script data-replace-marker="script">id:foo.id content:foo</script>', $html);
196 $this->assertEquals(
"foo", $html);
198 $this->assertEquals(
'foo<script data-replace-marker="script">id:foo.id content:foo</script>', $html);
206 new ilJavaScriptBinding($this->getTemplateFactory()->getTemplate(
"tpl.main.html",
false,
false))
208 $html =
$renderer->renderAsync([$c1,$c1]);
209 $this->assertEquals(
'foofoo', $html);
212 #[\PHPUnit\Framework\Attributes\DataProvider('getRenderType')]
215 $this->component_renderer = $this->createMock(ComponentRenderer::class);
216 $component = $this->createMock(
C\Component::class);
218 $loader = $this->createMock(Loader::class);
219 $loader->method(
'getRendererFor')->willReturn($this->component_renderer);
223 $this->component_renderer->expects($this->once())
230 #[\PHPUnit\Framework\Attributes\DataProvider('getRenderType')]
233 $this->component_renderer = $this->createMock(ComponentRenderer::class);
234 $component = $this->createMock(
C\Component::class);
235 $root = $this->createMock(Renderer::class);
237 $loader = $this->createMock(Loader::class);
238 $loader->method(
'getRendererFor')->willReturn($this->component_renderer);
242 $this->component_renderer->expects($this->once())
244 ->with($component, $root);
246 $renderer->$render_type($component, $root);
259 $component = $this->createMock(
C\Component::class);
260 $root = $this->createMock(Renderer::class);
264 $root->expects($this->exactly(2))
270 $this->assertEquals(
"..",
$res);
testPassesOtherOnAsRoot($render_type)
testPassesSelfAsRootIfNoRootExist($render_type)
ComponentRenderer $component_renderer
testRenderAsyncWithJsTwice()
testGetRendererSuccessfully()
LoggingRegistry $resource_registry
testRenderingChainAndContextStack()
Simulates the rendering chain and tests if the contexts are properly stacked.
testComponentListUsesRootToRender()
Renderer that dispatches rendering of UI components to a Renderer found in the same namespace as the ...
Wraps global ilTemplate to provide JavaScriptBinding.
Provides common functionality for UI tests.
A component is the most general form of an entity in the UI.
An entity that renders components to a string output.
Provides methods to interface with javascript.
Loads renderers for components.
An entity that renders components to a string output.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.