ILIAS  release_8 Revision v8.24
ilMDTest.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4/*
5 +-----------------------------------------------------------------------------+
6 | ILIAS open source |
7 +-----------------------------------------------------------------------------+
8 | Copyright (c) 1998-2006 ILIAS open source, University of Cologne |
9 | |
10 | This program is free software; you can redistribute it and/or |
11 | modify it under the terms of the GNU General Public License |
12 | as published by the Free Software Foundation; either version 2 |
13 | of the License, or (at your option) any later version. |
14 | |
15 | This program is distributed in the hope that it will be useful, |
16 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
18 | GNU General Public License for more details. |
19 | |
20 | You should have received a copy of the GNU General Public License |
21 | along with this program; if not, write to the Free Software |
22 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
23 +-----------------------------------------------------------------------------+
24*/
25
26use PHPUnit\Framework\TestCase;
28
37class ilMDTest extends TestCase
38{
39 protected Container $dic;
40
41 protected function setUp(): void
42 {
43 $this->initDependencies();
44 parent::setUp();
45 }
46
47 public function testMDConstruct(): void
48 {
49 $md = new ilMD();
50 $this->assertInstanceOf(ilMD::class, $md);
51 }
52
53 protected function setGlobalVariable(string $name, $value): void
54 {
55 global $DIC;
56
57 $GLOBALS[$name] = $value;
58 unset($DIC[$name]);
59 $DIC[$name] = static function (\ILIAS\DI\Container $c) use ($value) {
60 return $value;
61 };
62 }
63
64 protected function initDependencies(): void
65 {
66 $this->dic = new Container();
67 $GLOBALS['DIC'] = $this->dic;
68
69 $this->setGlobalVariable('ilDB', $this->createMock(ilDBInterface::class));
70
71 $logger = $this->getMockBuilder(ilLogger::class)
72 ->disableOriginalConstructor()
73 ->getMock();
74
75 $logger_factory = $this->getMockBuilder(ilLoggerFactory::class)
76 ->disableOriginalConstructor()
77 ->onlyMethods(['getComponentLogger'])
78 ->getMock();
79 $logger_factory->method('getComponentLogger')->willReturn($logger);
80 $this->setGlobalVariable('ilLoggerFactory', $logger_factory);
81 }
82}
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 tree table.
Definition: ilMDTest.php:38
setGlobalVariable(string $name, $value)
Definition: ilMDTest.php:53
Container $dic
Definition: ilMDTest.php:39
testMDConstruct()
Definition: ilMDTest.php:47
initDependencies()
Definition: ilMDTest.php:64
$c
Definition: cli.php:38
global $DIC
Definition: feed.php:28
if($format !==null) $name
Definition: metadata.php:247