19 declare(strict_types=1);
21 require_once(__DIR__ .
"/TestComponent.php");
22 require_once(__DIR__ .
"/../Base.php");
43 $r = $dr->_getRendererFor(
new Glyph(
"up",
"up"));
44 $this->assertInstanceOf(ComponentRenderer::class,
$r);
50 $r1 = $dr->_getRendererFor(
new Glyph(
"up",
"up"));
51 $r2 = $dr->_getRendererFor(
new Glyph(
"up",
"up"));
52 $this->assertTrue($r1 === $r2,
"Instances not equal");
57 $this->resource_registry = parent::getResourceRegistry();
66 $dr->render($component);
68 $this->assertEquals(array(
"test.js"), $this->resource_registry->resources);
75 $dr2 = $dr->withAdditionalContext($component);
76 $this->assertNotSame($dr, $dr2);
85 ->withAdditionalContext($c1)
86 ->withAdditionalContext($c2);
87 $this->assertEquals([], $dr->_getContexts());
88 $this->assertEquals([$c1, $c2], $dr2->_getContexts());
94 ->getMockBuilder(Loader::class)
95 ->onlyMethods([
"getRendererFor",
"getRendererFactoryFor"])
103 $renderer = $renderer
104 ->withAdditionalContext($c1)
105 ->withAdditionalContext($c2);
108 ->expects($this->once())
109 ->method(
"getRendererFor")
110 ->with($c1, [$c1, $c2]);
112 $renderer->_getRendererFor($c1);
119 $html = $renderer->render($c1);
120 $this->assertEquals(
"foo", $html);
131 $html = $renderer->renderAsync($c1);
132 $this->assertEquals(
"foo", $html);
141 $html = $renderer->renderAsync($c1);
142 $this->assertEquals(
'foo<script data-replace-marker="script">id:foo.id content:foo</script>', $html);
152 $html = $renderer->renderAsync($c2);
153 $this->assertEquals(
'foo<script data-replace-marker="script">id:foo.id content:foo</script>', $html);
154 $html = $renderer->renderAsync($c1);
155 $this->assertEquals(
"foo", $html);
156 $html = $renderer->renderAsync($c2);
157 $this->assertEquals(
'foo<script data-replace-marker="script">id:foo.id content:foo</script>', $html);
167 $html = $renderer->renderAsync([$c1,$c1]);
168 $this->assertEquals(
'foofoo', $html);
176 $this->component_renderer = $this->createMock(ComponentRenderer::class);
177 $component = $this->createMock(
C\Component::class);
187 return $this->
self->component_renderer;
190 protected function getJSCodeForAsyncRenderingFor(
C\
Component $component)
196 $this->component_renderer->expects($this->once())
198 ->with($component, $renderer);
200 $renderer->$render_type($component);
208 $this->component_renderer = $this->createMock(ComponentRenderer::class);
209 $component = $this->createMock(
C\Component::class);
210 $root = $this->createMock(Renderer::class);
220 return $this->
self->component_renderer;
223 protected function getJSCodeForAsyncRenderingFor(
C\
Component $component)
229 $this->component_renderer->expects($this->once())
231 ->with($component, $root);
233 $renderer->$render_type($component, $root);
246 $component = $this->createMock(
C\Component::class);
247 $root = $this->createMock(Renderer::class);
251 $root->expects($this->exactly(2))
256 $res = $renderer->render([$component, $component], $root);
257 $this->assertEquals(
"..",
$res);
getDefaultRenderer(JavaScriptBinding $js_binding=null, array $with_stub_renderings=[])
testWithAdditionalContextClones()
Class ChatMainBarProvider .
An entity that renders components to a string output.
Wraps global ilTemplate to provide JavaScriptBinding.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
testGetRendererSuccessfully()
ComponentRenderer $component_renderer
Provides common functionality for UI tests.
testComponentListUsesRootToRender()
testPassesSelfAsRootIfNoRootExist($render_type)
getRenderType
LoggingRegistry $resource_registry
testPassesOtherOnAsRoot($render_type)
getRenderType
testRenderAsyncWithJsTwice()
testPassesContextsToComponentRendererLoader()