ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
IliasMocks.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21use ILIAS\UI\Factory as UIFactory;
24use PHPUnit\Framework\MockObject\MockObject;
25
26trait IliasMocks
27{
35 protected function mockUIFactory(): UIFactory
36 {
37 $ui_reflection = new ReflectionClass(UIFactory::class);
38 $methods = array_map(
39 fn ($m) => $m->getName(),
40 $ui_reflection->getMethods()
41 );
42
43 $ui_factory = $this->getMockBuilder(UIFactory::class)
44 ->onlyMethods($methods)
45 ->getMock();
46
47 $signal_generator = new SignalGenerator();
48 $ui_factory->method('button')
49 ->willReturn(new CImpl\Button\Factory());
50 $ui_factory->method('viewControl')
51 ->willReturn(new CImpl\ViewControl\Factory($signal_generator));
52 $ui_factory->method('breadcrumbs')
53 ->will(
54 $this->returnCallback(function ($crumbs) {
55 return new CImpl\Breadcrumbs\Breadcrumbs($crumbs);
56 })
57 );
58 $ui_factory->method('link')
59 ->willReturn(new CImpl\Link\Factory());
60 $ui_factory->method('symbol')
61 ->willReturn(new CImpl\Symbol\Factory(
62 new CImpl\Symbol\Icon\Factory(),
63 new CImpl\Symbol\Glyph\Factory(),
64 new CImpl\Symbol\Avatar\Factory()
65 ));
66
67 return $ui_factory;
68 }
69
70
71 public function uiFactoryBreadcrumbs(...$args): CImpl\Breadcrumbs\Breadcrumbs
72 {
73 return new CImpl\Breadcrumbs\Breadcrumbs($args[0]);
74 }
75
79 protected function mockIlLanguage(): ilLanguage
80 {
81 $lng = $this->getMockBuilder(ilLanguage::class)
82 ->disableOriginalConstructor()
83 ->onlyMethods(['txt'])
84 ->getMock();
85 $lng->method('txt')
86 ->willReturn('');
87
88 return $lng;
89 }
90}
Builds a Color from either hex- or rgb values.
Definition: Factory.php:31
language handling
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: Bulky.php:21
global $lng
Definition: privfeed.php:31