ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilRPCServerSettingsTest.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21use PHPUnit\Framework\TestCase;
23
29class ilRPCServerSettingsTest extends TestCase
30{
31 protected Container $dic;
32
33 protected function setUp(): void
34 {
35 $this->initDependencies();
36 parent::setUp();
37 }
38
39 public function testConstruct(): void
40 {
41 $rpc_settings = ilRPCServerSettings::getInstance();
42 $this->assertInstanceOf(ilRPCServerSettings::class, $rpc_settings);
43 }
44
45 protected function setGlobalVariable(string $name, $value): void
46 {
47 global $DIC;
48
49 $GLOBALS[$name] = $value;
50 unset($DIC[$name]);
51 $DIC[$name] = static function (\ILIAS\DI\Container $c) use ($value) {
52 return $value;
53 };
54 }
55
56 protected function initDependencies(): void
57 {
58 $this->dic = new Container();
59 $GLOBALS['DIC'] = $this->dic;
60
61 $this->setGlobalVariable('ilSetting', $this->createMock(ilSetting::class));
62
63 $logger = $this->getMockBuilder(ilLogger::class)
64 ->disableOriginalConstructor()
65 ->getMock();
66
67 $logger_factory = $this->getMockBuilder(ilLoggerFactory::class)
68 ->disableOriginalConstructor()
69 ->onlyMethods(['getComponentLogger'])
70 ->getMock();
71 $logger_factory->method('getComponentLogger')->willReturn($logger);
72 $this->setGlobalVariable('ilLoggerFactory', $logger_factory);
73 }
74}
Customizing of pimple-DIC for ILIAS.
Definition: Container.php:36
Unit tests for class ilRPCServerSettings.
setGlobalVariable(string $name, $value)
$c
Definition: deliver.php:25
global $DIC
Definition: shib_login.php:26
$GLOBALS["DIC"]
Definition: wac.php:54