ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ComponentRendererFSLoaderTest.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 2017 Richard Klees <richard.klees@concepts-and-training.de> Extended GPL, see docs/LICENSE */
4
5require_once(__DIR__ . "/TestComponent.php");
6
8{
9 public function _instantiateRendererFor($class)
10 {
11 return $this->instantiateRendererFor($class);
12 }
13}
14
16{
17 protected function getComponentRendererFSLoader()
18 {
19 $ui_factory = $this->getMockBuilder(ILIAS\UI\Factory::class)->getMock();
20 $tpl_factory = $this->getMockBuilder(ILIAS\UI\Implementation\Render\TemplateFactory::class)->getMock();
21 $lng = $this->getMockBuilder(\ilLanguage::class)->disableOriginalConstructor()->getMock();
22 $js_binding = $this->getMockBuilder(ILIAS\UI\Implementation\Render\JavaScriptBinding::class)->getMock();
23 $default_renderer_factory = new \ILIAS\UI\Implementation\Render\DefaultRendererFactory($ui_factory, $tpl_factory, $lng, $js_binding);
24 return new ComponentRendererFSLoaderTesting($default_renderer_factory);
25 }
26
28 {
29 // There should be a renderer for Glyph...
30 $f = $this->getComponentRendererFSLoader();
31 $r = $f->getRendererFor(new \ILIAS\UI\Implementation\Component\Glyph\Glyph("up", "up"), []);
32 $this->assertInstanceOf(\ILIAS\UI\Implementation\Render\ComponentRenderer::class, $r);
33 }
34
36 {
37 $loader = $this->getMockBuilder(ILIAS\UI\Implementation\Render\FSLoader::class)
38 ->setMethods(["getRendererFactoryFor", "getContextNames"])
39 ->disableOriginalConstructor()
40 ->getMock();
41 $factory = $this->getMockBuilder(ILIAS\UI\Implementation\RendererFactory::class)
42 ->setMethods(["getRendererInContext"])
43 ->getMock();
44
45 $rendered_component = $this->createMock(ILIAS\UI\Component\Component::class);
46
47 $component1 = $this->createMock(ILIAS\UI\Component\Component::class);
48 $component2 = $this->createMock(ILIAS\UI\Component\Component::class);
49 $component_name1 = "COMPONENT 1";
50 $component_name2 = "COMPONENT 2";
51
53 ->expects($this->once())
54 ->method("getContextNames")
55 ->with([$component1, $component2])
56 ->willReturn([$component_name1, $component_name2]);
57
59 ->expects($this->once())
60 ->method("getRendererFactoryFor")
61 ->with($rendered_component)
62 ->willReturn($factory);
63
64 $renderer = "RENDERER";
66 ->expects($this->once())
67 ->method("getRendererInContext")
68 ->with($rendered_component, [$component_name1, $component_name2])
69 ->willReturn($renderer);
70
71 $renderer2 = $loader->getRendererFor($rendered_component, [$component1, $component2]);
72 $this->assertEquals($renderer, $renderer2);
73 }
74}
$factory
Definition: metadata.php:47
An exception for terminatinating execution or to throw for unit testing.
Loads renderers for components from the file system.
Definition: FSLoader.php:21
$r
Definition: example_031.php:79
Class BaseForm.
Class Factory.
global $lng
Definition: privfeed.php:17