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