3 declare(strict_types=1);
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")
44 ->willReturn($renderer);
47 $r = $l->getRendererFor($component,
$context);
49 $this->assertSame($renderer, $r);
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, [])
64 ->willReturn($renderer);
67 $r1 = $l->getRendererFor($component, []);
68 $r2 = $l->getRendererFor($component, []);
70 $this->assertSame($renderer, $r1);
71 $this->assertSame($renderer, $r2);
77 ->onlyMethods([
"getRendererFor",
"getRendererFactoryFor"])
80 $renderer1 = $this->createMock(ComponentRenderer::class);
81 $renderer2 = $this->createMock(ComponentRenderer::class);
82 $c1 = $this->getMockBuilder(Component::class)->getMock();
85 ->expects($this->exactly(2))
86 ->method(
"getRendererFor")
87 ->withConsecutive([$c1, [] ], [$c1, [$c2]])
88 ->will($this->onConsecutiveCalls($renderer1, $renderer2));
91 $r1 = $l->getRendererFor($c1, []);
92 $r2 = $l->getRendererFor($c1, [$c2]);
93 $r3 = $l->getRendererFor($c1, [$c2]);
94 $r4 = $l->getRendererFor($c1, []);
96 $this->assertSame($renderer1, $r1);
97 $this->assertSame($renderer2, $r2);
98 $this->assertSame($renderer2, $r3);
99 $this->assertSame($renderer1, $r4);
105 ->onlyMethods([
"getRendererFor",
"getRendererFactoryFor"])
108 $c1 = $this->createMock(Component::class);
110 $factory = $this->createMock(RendererFactory::class);
112 ->expects($this->exactly(1))
113 ->method(
"getRendererFactoryFor")
119 $this->assertSame(
$factory, $l->getRendererFactoryFor($c1));
test_forwards_from_underlying()
test_caching_respects_contexts()
Class ChatMainBarProvider .
Caches renderers loaded by another loader.
test_passthrough_getRendererFactory()