10 $underlying = $this->getMockBuilder(\
ILIAS\
UI\Implementation\Render\Loader::class)
11 ->setMethods([
"getRendererFor",
"getRendererFactoryFor"])
14 $renderer = new \stdClass();
15 $component = $this->getMockBuilder(\
ILIAS\
UI\
Component\Component::class)->getMock();
16 $context = [new \ILIAS\UI\Component\Test\TestComponent(
"foo")];
18 ->expects($this->once())
19 ->method(
"getRendererFor")
20 ->with($component, $context)
21 ->willReturn($renderer);
23 $l = new \ILIAS\UI\Implementation\Render\LoaderCachingWrapper($underlying);
24 $r =
$l->getRendererFor($component, $context);
26 $this->assertSame($renderer,
$r);
31 $underlying = $this->getMockBuilder(\
ILIAS\
UI\Implementation\Render\Loader::class)
32 ->setMethods([
"getRendererFor",
"getRendererFactoryFor"])
35 $renderer = new \stdClass();
36 $component = $this->getMockBuilder(\
ILIAS\
UI\
Component\Component::class)->getMock();
38 ->expects($this->once())
39 ->method(
"getRendererFor")
40 ->with($component, [])
41 ->willReturn($renderer);
43 $l = new \ILIAS\UI\Implementation\Render\LoaderCachingWrapper($underlying);
44 $r1 =
$l->getRendererFor($component, []);
45 $r2 =
$l->getRendererFor($component, []);
47 $this->assertSame($renderer, $r1);
48 $this->assertSame($renderer, $r2);
53 $underlying = $this->getMockBuilder(\
ILIAS\
UI\Implementation\Render\Loader::class)
54 ->setMethods([
"getRendererFor",
"getRendererFactoryFor"])
57 $renderer1 = new \stdClass();
58 $renderer2 = new \stdClass();
59 $c1 = $this->getMockBuilder(\
ILIAS\
UI\
Component\Component::class)->getMock();
60 $c2 = new \ILIAS\UI\Component\Test\TestComponent(
"foo");
62 ->expects($this->exactly(2))
63 ->method(
"getRendererFor")
64 ->withConsecutive([$c1, [] ], [$c1, [$c2]])
65 ->will($this->onConsecutiveCalls($renderer1, $renderer2));
67 $l = new \ILIAS\UI\Implementation\Render\LoaderCachingWrapper($underlying);
68 $r1 =
$l->getRendererFor($c1, []);
69 $r2 =
$l->getRendererFor($c1, [$c2]);
70 $r3 =
$l->getRendererFor($c1, [$c2]);
71 $r4 =
$l->getRendererFor($c1, []);
73 $this->assertSame($renderer1, $r1);
74 $this->assertSame($renderer2, $r2);
75 $this->assertSame($renderer2, $r3);
76 $this->assertSame($renderer1, $r4);
81 $underlying = $this->getMockBuilder(\
ILIAS\
UI\Implementation\Render\Loader::class)
82 ->setMethods([
"getRendererFor",
"getRendererFactoryFor"])
89 ->expects($this->exactly(1))
90 ->method(
"getRendererFactoryFor")
94 $l = new \ILIAS\UI\Implementation\Render\LoaderCachingWrapper($underlying);
96 $this->assertSame(
$factory,
$l->getRendererFactoryFor($c1));
test_forwards_from_underlying()
test_caching_respects_contexts()
test_passthrough_getRendererFactory()