ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
ilInitialisationTest.php
Go to the documentation of this file.
1<?php
2
3use PHPUnit\Framework\TestCase;
4
11class ilInitialisationTest extends TestCase
12{
13 protected $backupGlobals = false;
14
15 protected function setUp() : void
16 {
17 include_once("./Services/PHPUnit/classes/class.ilUnitUtil.php");
18 ilUnitUtil::performInitialisation();
19 }
20
24 public function test_DIC($global_name, $class_name)
25 {
26 global $DIC;
27
28 $this->assertInstanceOf($class_name, $GLOBALS[$global_name]);
29 $this->assertInstanceOf($class_name, $DIC[$global_name]);
30 $this->assertSame($GLOBALS[$global_name], $DIC[$global_name]);
31 }
32
36 public function test_DIC_getters($class_name, $getter)
37 {
38 global $DIC;
39
40 $service = $getter($DIC);
41 $this->assertInstanceOf($class_name, $service);
42 }
43
44 public function globalsProvider()
45 {
46 // Add combinations of globals and their classes here...
47 return array( array("ilIliasIniFile", "ilIniFile")
48 , array("ilCtrl", "ilCtrl")
49 , array("tree", "ilTree")
50 , array("ilLog", "ilLogger")
51 , array("ilDB", "ilDBInterface")
52 );
53 }
54
55 public function getterProvider()
56 {
57 return array( array("ilDBInterface", function ($DIC) {
58 return $DIC->database();
59 })
60 , array("ilCtrl", function ($DIC) {
61 return $DIC->ctrl();
62 })
63 , array("ilObjUser", function ($DIC) {
64 return $DIC->user();
65 })
66 , array("ilRbacSystem", function ($DIC) {
67 return $DIC->rbac()->system();
68 })
69 , array("ilRbacAdmin", function ($DIC) {
70 return $DIC->rbac()->admin();
71 })
72 , array("ilRbacReview", function ($DIC) {
73 return $DIC->rbac()->review();
74 })
75 , array("ilAccess", function ($DIC) {
76 return $DIC->access();
77 })
78 , array("ilTree", function ($DIC) {
79 return $DIC->repositoryTree();
80 })
81 , array("ilLanguage", function ($DIC) {
82 return $DIC->language();
83 })
84 // TODO: Can't test these until context for unit tests does not have HTML.
85 //, array("ilTemplate", function ($DIC) { return $DIC->ui()->mainTemplate(); })
86 //, array("ilToolbarGUI", function ($DIC) { return $DIC->toolbar(); })
87 //, array("ilTabsGUI", function ($DIC) { return $DIC->tabs(); })
88 //, array("ILIAS\\UI\\Factory", function ($DIC) { return $DIC->ui()->factory();})
89 //, array("ILIAS\\UI\\Renderer", function ($DIC) { return $DIC->ui()->renderer();})
90 , array("ilLogger", function ($DIC) {
91 return $DIC->logger()->root();
92 })
93 , array("ilLogger", function ($DIC) {
94 return $DIC->logger()->grp();
95 })
96 , array("ilLogger", function ($DIC) {
97 return $DIC->logger()->crs();
98 })
99 , array("ilLogger", function ($DIC) {
100 return $DIC->logger()->tree();
101 })
102 );
103 }
104}
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
An exception for terminatinating execution or to throw for unit testing.
TestCase for the ilContext @group needsInstalledILIAS.
test_DIC_getters($class_name, $getter)
@dataProvider getterProvider
test_DIC($global_name, $class_name)
@dataProvider globalsProvider
$service
Definition: result.php:17
$DIC
Definition: xapitoken.php:46