ILIAS  release_7 Revision v7.30-3-g800a261c036
ComponentRendererLoaderResourceRegistryWrapperTest.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
5use PHPUnit\Framework\TestCase;
6
8{
10 {
11 $underlying = $this->getMockBuilder(\ILIAS\UI\Implementation\Render\Loader::class)
12 ->setMethods(["getRendererFor", "getRendererFactoryFor"])
13 ->getMock();
14
15 $renderer = $this->getMockBuilder(\ILIAS\UI\Implementation\Render\ComponentRenderer::class)
16 ->setMethods(["registerResources", "render"])
17 ->getMock();
18 $component = $this->getMockBuilder(\ILIAS\UI\Component\Component::class)->getMock();
19 $context = ["a", "b"];
20 $underlying
21 ->expects($this->once())
22 ->method("getRendererFor")
23 ->with($component, $context)
24 ->willReturn($renderer);
25
26 $registry = $this->getMockBuilder(\ILIAS\UI\Implementation\Render\ResourceRegistry::class)
27 ->getMock();
28
29 $l = new \ILIAS\UI\Implementation\Render\LoaderResourceRegistryWrapper($registry, $underlying);
30 $r = $l->getRendererFor($component, $context);
31
32 $this->assertSame($renderer, $r);
33 }
34
35 public function test_registerResources()
36 {
37 $underlying = $this->getMockBuilder(\ILIAS\UI\Implementation\Render\Loader::class)
38 ->setMethods(["getRendererFor", "getRendererFactoryFor"])
39 ->getMock();
40
41 $renderer = $this->getMockBuilder(\ILIAS\UI\Implementation\Render\ComponentRenderer::class)
42 ->setMethods(["registerResources", "render"])
43 ->getMock();
44 $component = $this->getMockBuilder(\ILIAS\UI\Component\Component::class)->getMock();
45 $underlying
46 ->expects($this->once())
47 ->method("getRendererFor")
48 ->with($component, [])
49 ->willReturn($renderer);
50
51 $registry = $this->getMockBuilder(\ILIAS\UI\Implementation\Render\ResourceRegistry::class)
52 ->getMock();
53
54 $renderer
55 ->expects($this->once())
56 ->method("registerResources")
57 ->with($registry);
58
59 $l = new \ILIAS\UI\Implementation\Render\LoaderResourceRegistryWrapper($registry, $underlying);
60 $r = $l->getRendererFor($component, []);
61 }
62
64 {
65 $underlying = $this->getMockBuilder(\ILIAS\UI\Implementation\Render\Loader::class)
66 ->setMethods(["getRendererFor", "getRendererFactoryFor"])
67 ->getMock();
68
69 $c1 = $this->createMock(\ILIAS\UI\Component\Component::class);
70
71 $factory = "FACTORY";
72 $underlying
73 ->expects($this->exactly(1))
74 ->method("getRendererFactoryFor")
75 ->with($c1)
76 ->willReturn($factory);
77
78 $l = new \ILIAS\UI\Implementation\Render\LoaderCachingWrapper($underlying);
79
80 $this->assertSame($factory, $l->getRendererFactoryFor($c1));
81 }
82}
An exception for terminatinating execution or to throw for unit testing.
$factory
Definition: metadata.php:58
Class ChatMainBarProvider \MainMenu\Provider.
Class Factory.
$context
Definition: webdav.php:26