ILIAS  release_8 Revision v8.24
ilRPCServerSettingsTest.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
5use PHPUnit\Framework\TestCase;
7
13class ilRPCServerSettingsTest extends TestCase
14{
15 protected Container $dic;
16
17 protected function setUp(): void
18 {
19 $this->initDependencies();
20 parent::setUp();
21 }
22
23 public function testConstruct(): void
24 {
25 $rpc_settings = ilRPCServerSettings::getInstance();
26 $this->assertInstanceOf(ilRPCServerSettings::class, $rpc_settings);
27 }
28
29 protected function setGlobalVariable(string $name, $value): void
30 {
31 global $DIC;
32
33 $GLOBALS[$name] = $value;
34 unset($DIC[$name]);
35 $DIC[$name] = static function (\ILIAS\DI\Container $c) use ($value) {
36 return $value;
37 };
38 }
39
40 protected function initDependencies(): void
41 {
42 $this->dic = new Container();
43 $GLOBALS['DIC'] = $this->dic;
44
45 $this->setGlobalVariable('ilSetting', $this->createMock(ilSetting::class));
46
47 $logger = $this->getMockBuilder(ilLogger::class)
48 ->disableOriginalConstructor()
49 ->getMock();
50
51 $logger_factory = $this->getMockBuilder(ilLoggerFactory::class)
52 ->disableOriginalConstructor()
53 ->onlyMethods(['getComponentLogger'])
54 ->getMock();
55 $logger_factory->method('getComponentLogger')->willReturn($logger);
56 $this->setGlobalVariable('ilLoggerFactory', $logger_factory);
57 }
58}
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
Customizing of pimple-DIC for ILIAS.
Definition: Container.php:32
Unit tests for class ilRPCServerSettings.
setGlobalVariable(string $name, $value)
$c
Definition: cli.php:38
global $DIC
Definition: feed.php:28
if($format !==null) $name
Definition: metadata.php:247