ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ComponentRendererLoaderCachingWrapperTest Class Reference
+ Inheritance diagram for ComponentRendererLoaderCachingWrapperTest:
+ Collaboration diagram for ComponentRendererLoaderCachingWrapperTest:

Public Member Functions

 test_forwards_from_underlying ()
 
 test_caches ()
 
 test_caching_respects_contexts ()
 
 test_passthrough_getRendererFactory ()
 

Detailed Description

Definition at line 6 of file ComponentRendererLoaderCachingWrapperTest.php.

Member Function Documentation

◆ test_caches()

ComponentRendererLoaderCachingWrapperTest::test_caches ( )

Definition at line 29 of file ComponentRendererLoaderCachingWrapperTest.php.

30 {
31 $underlying = $this->getMockBuilder(\ILIAS\UI\Implementation\Render\Loader::class)
32 ->setMethods(["getRendererFor", "getRendererFactoryFor"])
33 ->getMock();
34
35 $renderer = new \stdClass();
36 $component = $this->getMockBuilder(\ILIAS\UI\Component\Component::class)->getMock();
37 $underlying
38 ->expects($this->once())
39 ->method("getRendererFor")
40 ->with($component, [])
41 ->willReturn($renderer);
42
43 $l = new \ILIAS\UI\Implementation\Render\LoaderCachingWrapper($underlying);
44 $r1 = $l->getRendererFor($component, []);
45 $r2 = $l->getRendererFor($component, []);
46
47 $this->assertSame($renderer, $r1);
48 $this->assertSame($renderer, $r2);
49 }
global $l
Definition: afr.php:30
Class BaseForm.
once($eventName, callable $callBack, $priority=100)
Subscribe to an event exactly once.
Class Factory.

References $l, and Sabre\Event\once().

+ Here is the call graph for this function:

◆ test_caching_respects_contexts()

ComponentRendererLoaderCachingWrapperTest::test_caching_respects_contexts ( )

Definition at line 51 of file ComponentRendererLoaderCachingWrapperTest.php.

52 {
53 $underlying = $this->getMockBuilder(\ILIAS\UI\Implementation\Render\Loader::class)
54 ->setMethods(["getRendererFor", "getRendererFactoryFor"])
55 ->getMock();
56
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");
61 $underlying
62 ->expects($this->exactly(2))
63 ->method("getRendererFor")
64 ->withConsecutive([$c1, [] ], [$c1, [$c2]])
65 ->will($this->onConsecutiveCalls($renderer1, $renderer2));
66
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, []);
72
73 $this->assertSame($renderer1, $r1);
74 $this->assertSame($renderer2, $r2);
75 $this->assertSame($renderer2, $r3);
76 $this->assertSame($renderer1, $r4);
77 }

References $l.

◆ test_forwards_from_underlying()

ComponentRendererLoaderCachingWrapperTest::test_forwards_from_underlying ( )

Definition at line 8 of file ComponentRendererLoaderCachingWrapperTest.php.

9 {
10 $underlying = $this->getMockBuilder(\ILIAS\UI\Implementation\Render\Loader::class)
11 ->setMethods(["getRendererFor", "getRendererFactoryFor"])
12 ->getMock();
13
14 $renderer = new \stdClass();
15 $component = $this->getMockBuilder(\ILIAS\UI\Component\Component::class)->getMock();
16 $context = [new \ILIAS\UI\Component\Test\TestComponent("foo")];
17 $underlying
18 ->expects($this->once())
19 ->method("getRendererFor")
20 ->with($component, $context)
21 ->willReturn($renderer);
22
23 $l = new \ILIAS\UI\Implementation\Render\LoaderCachingWrapper($underlying);
24 $r = $l->getRendererFor($component, $context);
25
26 $this->assertSame($renderer, $r);
27 }
$r
Definition: example_031.php:79
$context
Definition: webdav.php:25

References $context, $l, $r, and Sabre\Event\once().

+ Here is the call graph for this function:

◆ test_passthrough_getRendererFactory()

ComponentRendererLoaderCachingWrapperTest::test_passthrough_getRendererFactory ( )

Definition at line 79 of file ComponentRendererLoaderCachingWrapperTest.php.

80 {
81 $underlying = $this->getMockBuilder(\ILIAS\UI\Implementation\Render\Loader::class)
82 ->setMethods(["getRendererFor", "getRendererFactoryFor"])
83 ->getMock();
84
85 $c1 = $this->createMock(\ILIAS\UI\Component\Component::class);
86
87 $factory = "FACTORY";
88 $underlying
89 ->expects($this->exactly(1))
90 ->method("getRendererFactoryFor")
91 ->with($c1)
92 ->willReturn($factory);
93
94 $l = new \ILIAS\UI\Implementation\Render\LoaderCachingWrapper($underlying);
95
96 $this->assertSame($factory, $l->getRendererFactoryFor($c1));
97 }
$factory
Definition: metadata.php:43

References $factory, and $l.


The documentation for this class was generated from the following file: