ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ilRBACTest.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
23 
29 class ilRBACTest extends TestCase
30 {
31  protected $backupGlobals = false;
32 
33  protected Container $dic;
34 
35  protected function setUp(): void
36  {
37  $this->initACDependencies();
38  parent::setUp();
39  }
40 
41  public function testConstruct(): void
42  {
43  $system = ilRbacSystem::getInstance();
44  $this->assertTrue($system instanceof ilRbacSystem);
45 
46  $admin = new ilRbacAdmin();
47  $this->assertTrue($admin instanceof ilRbacAdmin);
48 
49  $review = new ilRbacReview();
50  $this->assertTrue($review instanceof ilRbacReview);
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 initACDependencies(): void
65  {
66  $this->dic = new Container();
67  $GLOBALS['DIC'] = $this->dic;
68 
69  $this->setGlobalVariable('ilDB', $this->createMock(ilDBInterface::class));
70  $this->setGlobalVariable('ilUser', $this->createMock(ilObjUser::class));
71  $this->setGlobalVariable('rbacreview', $this->createMock(ilRbacReview::class));
72  $this->setGlobalVariable('ilObjDataCache', $this->createMock(ilObjectDataCache::class));
73  $this->setGlobalVariable('tree', $this->createMock(ilTree::class));
74  $this->setGlobalVariable('http', $this->createMock(\ILIAS\HTTP\Services::class));
75  $this->setGlobalVariable('refinery', $this->createMock(\ILIAS\Refinery\Factory::class));
76 
77  $logger = $this->getMockBuilder(ilLogger::class)
78  ->disableOriginalConstructor()
79  ->getMock();
80 
81  $logger_factory = $this->getMockBuilder(ilLoggerFactory::class)
82  ->disableOriginalConstructor()
83  ->onlyMethods(['getComponentLogger'])
84  ->getMock();
85  $logger_factory->method('getComponentLogger')->willReturn($logger);
86  $this->setGlobalVariable('ilLoggerFactory', $logger_factory);
87  }
88 }
$c
Definition: cli.php:38
Class ChatMainBarProvider .
initACDependencies()
Definition: ilRBACTest.php:64
Customizing of pimple-DIC for ILIAS.
Definition: Container.php:31
global $DIC
Definition: feed.php:28
if($format !==null) $name
Definition: metadata.php:247
Unit tests for tree table.
Definition: ilRBACTest.php:29
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
Class ilRbacAdmin Core functions for role based access control.
setGlobalVariable(string $name, $value)
Definition: ilRBACTest.php:53
Container $dic
Definition: ilRBACTest.php:33