ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ilGroupEventHandlerTest.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  +-----------------------------------------------------------------------------+
7  | ILIAS open source |
8  +-----------------------------------------------------------------------------+
9  | Copyright (c) 1998-2006 ILIAS open source, University of Cologne |
10  | |
11  | This program is free software; you can redistribute it and/or |
12  | modify it under the terms of the GNU General Public License |
13  | as published by the Free Software Foundation; either version 2 |
14  | of the License, or (at your option) any later version. |
15  | |
16  | This program is distributed in the hope that it will be useful, |
17  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
18  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
19  | GNU General Public License for more details. |
20  | |
21  | You should have received a copy of the GNU General Public License |
22  | along with this program; if not, write to the Free Software |
23  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
24  +-----------------------------------------------------------------------------+
25 */
26 
29 
35 class ilGroupEventHandlerTest extends TestCase
36 {
37  protected $backupGlobals = false;
38 
39  protected Container $dic;
40 
41  protected function setUp(): void
42  {
43  $this->initDependencies();
44  parent::setUp();
45  }
46 
47  public function testConstruct(): void
48  {
49  $listener = new ilGroupAppEventListener();
50  $this->assertTrue($listener instanceof ilGroupAppEventListener);
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  $logger = $this->getMockBuilder(ilLogger::class)
70  ->disableOriginalConstructor()
71  ->getMock();
72 
73  $logger_factory = $this->getMockBuilder(ilLoggerFactory::class)
74  ->disableOriginalConstructor()
75  ->onlyMethods(['getComponentLogger'])
76  ->getMock();
77  $logger_factory->method('getComponentLogger')->willReturn($logger);
78  $this->setGlobalVariable('ilLoggerFactory', $logger_factory);
79  }
80 }
$c
Definition: cli.php:38
Unit tests for tree table.
Customizing of pimple-DIC for ILIAS.
Definition: Container.php:31
global $DIC
Definition: feed.php:28
if($format !==null) $name
Definition: metadata.php:247
setGlobalVariable(string $name, $value)
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64