ILIAS  trunk Revision v11.0_alpha-1715-g7fc467680fb
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ComponentRendererLoaderCachingWrapperTest Class Reference
+ Inheritance diagram for ComponentRendererLoaderCachingWrapperTest:
+ Collaboration diagram for ComponentRendererLoaderCachingWrapperTest:

Public Member Functions

 testForwardsFromUnderlying ()
 
 testCaches ()
 
 testCachingRespectsContexts ()
 
 testPassthroughGetRendererFactory ()
 

Detailed Description

Member Function Documentation

◆ testCaches()

ComponentRendererLoaderCachingWrapperTest::testCaches ( )

Definition at line 52 of file ComponentRendererLoaderCachingWrapperTest.php.

References $renderer.

52  : void
53  {
54  $underlying = $this->getMockBuilder(\ILIAS\UI\Implementation\Render\Loader::class)
55  ->onlyMethods(["getRendererFor", "getRendererFactoryFor"])
56  ->getMock();
57 
58  $renderer = $this->createMock(ComponentRenderer::class);
59  $component = $this->getMockBuilder(Component::class)->getMock();
60  $underlying
61  ->expects($this->once())
62  ->method("getRendererFor")
63  ->with($component, [])
64  ->willReturn($renderer);
65 
66  $l = new LoaderCachingWrapper($underlying);
67  $r1 = $l->getRendererFor($component, []);
68  $r2 = $l->getRendererFor($component, []);
69 
70  $this->assertSame($renderer, $r1);
71  $this->assertSame($renderer, $r2);
72  }
$renderer
Interface Observer Contains several chained tasks and infos about them.
Caches renderers loaded by another loader.

◆ testCachingRespectsContexts()

ComponentRendererLoaderCachingWrapperTest::testCachingRespectsContexts ( )

Definition at line 74 of file ComponentRendererLoaderCachingWrapperTest.php.

74  : void
75  {
76  $underlying = $this->getMockBuilder(\ILIAS\UI\Implementation\Render\Loader::class)
77  ->onlyMethods(["getRendererFor", "getRendererFactoryFor"])
78  ->getMock();
79 
80  $renderer1 = $this->createMock(ComponentRenderer::class);
81  $renderer2 = $this->createMock(ComponentRenderer::class);
82  $c1 = $this->getMockBuilder(Component::class)->getMock();
83  $c2 = new TestComponent("foo");
84  $consecutive = [
85  [$c1, [], $renderer1],
86  [$c1, [$c2], $renderer2]
87  ];
88  $underlying
89  ->expects($this->exactly(2))
90  ->method("getRendererFor")
91  ->willReturnCallback(
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);
96  return $return;
97  }
98  );
99 
100  $l = new LoaderCachingWrapper($underlying);
101  $r1 = $l->getRendererFor($c1, []);
102  $r2 = $l->getRendererFor($c1, [$c2]);
103  $r3 = $l->getRendererFor($c1, [$c2]);
104  $r4 = $l->getRendererFor($c1, []);
105 
106  $this->assertSame($renderer1, $r1);
107  $this->assertSame($renderer2, $r2);
108  $this->assertSame($renderer2, $r3);
109  $this->assertSame($renderer1, $r4);
110  }
Interface Observer Contains several chained tasks and infos about them.
Caches renderers loaded by another loader.

◆ testForwardsFromUnderlying()

ComponentRendererLoaderCachingWrapperTest::testForwardsFromUnderlying ( )

Definition at line 31 of file ComponentRendererLoaderCachingWrapperTest.php.

References $context, $r, and $renderer.

31  : void
32  {
33  $underlying = $this->getMockBuilder(Loader::class)
34  ->onlyMethods(["getRendererFor", "getRendererFactoryFor"])
35  ->getMock();
36 
37  $renderer = $this->createMock(ComponentRenderer::class);
38  $component = $this->getMockBuilder(Component::class)->getMock();
39  $context = [new TestComponent("foo")];
40  $underlying
41  ->expects($this->once())
42  ->method("getRendererFor")
43  ->with($component, $context)
44  ->willReturn($renderer);
45 
46  $l = new LoaderCachingWrapper($underlying);
47  $r = $l->getRendererFor($component, $context);
48 
49  $this->assertSame($renderer, $r);
50  }
$renderer
$context
Definition: webdav.php:31
Caches renderers loaded by another loader.
$r

◆ testPassthroughGetRendererFactory()

ComponentRendererLoaderCachingWrapperTest::testPassthroughGetRendererFactory ( )

Definition at line 112 of file ComponentRendererLoaderCachingWrapperTest.php.

112  : void
113  {
114  $underlying = $this->getMockBuilder(\ILIAS\UI\Implementation\Render\Loader::class)
115  ->onlyMethods(["getRendererFor", "getRendererFactoryFor"])
116  ->getMock();
117 
118  $c1 = $this->createMock(Component::class);
119 
120  $factory = $this->createMock(RendererFactory::class);
121  $underlying
122  ->expects($this->exactly(1))
123  ->method("getRendererFactoryFor")
124  ->with($c1)
125  ->willReturn($factory);
126 
127  $l = new LoaderCachingWrapper($underlying);
128 
129  $this->assertSame($factory, $l->getRendererFactoryFor($c1));
130  }
Interface Observer Contains several chained tasks and infos about them.
Caches renderers loaded by another loader.

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