19declare(strict_types=1);
21use PHPUnit\Framework\TestCase;
33 $underlying = $this->getMockBuilder(Loader::class)
34 ->onlyMethods([
"getRendererFor",
"getRendererFactoryFor"])
37 $renderer = $this->createMock(ComponentRenderer::class);
38 $component = $this->getMockBuilder(Component::class)->getMock();
41 ->expects($this->once())
42 ->method(
"getRendererFor")
47 $r = $l->getRendererFor($component,
$context);
55 ->onlyMethods([
"getRendererFor",
"getRendererFactoryFor"])
58 $renderer = $this->createMock(ComponentRenderer::class);
59 $component = $this->getMockBuilder(Component::class)->getMock();
61 ->expects($this->once())
62 ->method(
"getRendererFor")
63 ->with($component, [])
67 $r1 = $l->getRendererFor($component, []);
68 $r2 = $l->getRendererFor($component, []);
77 ->onlyMethods([
"getRendererFor",
"getRendererFactoryFor"])
80 $renderer1 = $this->createMock(ComponentRenderer::class);
81 $renderer2 = $this->createMock(ComponentRenderer::class);
82 $c1 = $this->getMockBuilder(Component::class)->getMock();
85 [$c1, [], $renderer1],
86 [$c1, [$c2], $renderer2]
89 ->expects($this->exactly(2))
90 ->method(
"getRendererFor")
92 function ($component, $contexts) use (&$consecutive) {
93 list($expected_component, $expected_contexts, $return) = array_shift($consecutive);
94 $this->assertEquals($expected_component, $component);
95 $this->assertEquals($expected_contexts, $contexts);
101 $r1 = $l->getRendererFor($c1, []);
102 $r2 = $l->getRendererFor($c1, [$c2]);
103 $r3 = $l->getRendererFor($c1, [$c2]);
104 $r4 = $l->getRendererFor($c1, []);
106 $this->assertSame($renderer1, $r1);
107 $this->assertSame($renderer2, $r2);
108 $this->assertSame($renderer2, $r3);
109 $this->assertSame($renderer1, $r4);
115 ->onlyMethods([
"getRendererFor",
"getRendererFactoryFor"])
118 $c1 = $this->createMock(Component::class);
120 $factory = $this->createMock(RendererFactory::class);
122 ->expects($this->exactly(1))
123 ->method(
"getRendererFactoryFor")
125 ->willReturn($factory);
129 $this->assertSame($factory, $l->getRendererFactoryFor($c1));
testForwardsFromUnderlying()
testPassthroughGetRendererFactory()
testCachingRespectsContexts()
Caches renderers loaded by another loader.
A component is the most general form of an entity in the UI.
An entity that renders components to a string output.
Loads renderers for components.
This is the interface that components should use if they want to load specific renderers.
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.