ILIAS  trunk Revision v12.0_alpha-1540-g00f839d5fa1
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 ->willReturnCallback(function ($crumbs) {
54 return new CImpl\Breadcrumbs\Breadcrumbs($crumbs);
55 });
56 $ui_factory->method('link')
57 ->willReturn(new CImpl\Link\Factory());
58 $ui_factory->method('symbol')
59 ->willReturn(new CImpl\Symbol\Factory(
60 new CImpl\Symbol\Icon\Factory(),
61 new CImpl\Symbol\Glyph\Factory(),
62 new CImpl\Symbol\Avatar\Factory()
63 ));
64
65 return $ui_factory;
66 }
67
68
69 public function uiFactoryBreadcrumbs(...$args): CImpl\Breadcrumbs\Breadcrumbs
70 {
71 return new CImpl\Breadcrumbs\Breadcrumbs($args[0]);
72 }
73
77 protected function mockIlLanguage(): ilLanguage
78 {
79 $lng = $this->getMockBuilder(ilLanguage::class)
80 ->disableOriginalConstructor()
81 ->onlyMethods(['txt'])
82 ->getMock();
83 $lng->method('txt')
84 ->willReturn('');
85
86 return $lng;
87 }
88}
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:26