ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilRTEBaseTestCase.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
23use PHPUnit\Framework\TestCase;
24use ILIAS\HTTP\Services as HttpServiceImpl;
25
30abstract class ilRTEBaseTestCase extends TestCase
31{
32 protected function setUp(): void
33 {
34 $GLOBALS['DIC'] = new Container();
35 $this->setMocks();
36
37 parent::setUp();
38 }
39
44 protected function setGlobalVariable(string $name, $value): void
45 {
46 global $DIC;
47
48 $GLOBALS[$name] = $value;
49
50 unset($DIC[$name]);
51 $DIC[$name] = static function ($c) use ($name) {
52 return $GLOBALS[$name];
53 };
54 }
55
56 protected function setMocks(): void
57 {
58 $tpl_mock = $this->createMock(ilGlobalTemplateInterface::class);
59 $this->setGlobalVariable('tpl', $tpl_mock);
60
61 $lng = $this
62 ->getMockBuilder(ilLanguage::class)
63 ->disableOriginalConstructor()
64 ->onlyMethods(['txt', 'getInstalledLanguages', 'loadLanguageModule'])
65 ->getMock();
66 $this->setGlobalVariable('lng', $lng);
67
68 $this->setGlobalVariable(
69 'ilCtrl',
70 $this->getMockBuilder(ilCtrlInterface::class)->disableOriginalConstructor()->getMock()
71 );
72
73 $this->setGlobalVariable(
74 'ilClientIniFile',
75 $this->getMockBuilder(ilIniFile::class)->disableOriginalConstructor()->getMock()
76 );
77
78 $this->setGlobalVariable(
79 'ilUser',
80 $this->getMockBuilder(ilObjUser::class)->disableOriginalConstructor()->getMock()
81 );
82
83 $http = $this
84 ->getMockBuilder(HttpServiceImpl::class)
85 ->disableOriginalConstructor()
86 ->onlyMethods(['agent'])
87 ->getMock();
88 $http
89 ->method('agent')
90 ->willReturn(new AgentDetermination());
91 $this->setGlobalVariable('http', $http);
92 }
93}
Customizing of pimple-DIC for ILIAS.
Definition: Container.php:36
This library is borrowed from the phpGroupWare API http://www.phpgroupware.org/api Modifications made...
Class Services.
Definition: Services.php:38
Class ilRTEBaseTestCase.
setGlobalVariable(string $name, $value)
$http
Definition: deliver.php:30
$c
Definition: deliver.php:25
global $lng
Definition: privfeed.php:31
global $DIC
Definition: shib_login.php:26
$GLOBALS["DIC"]
Definition: wac.php:54