ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilInitialisationTest.php
Go to the documentation of this file.
1<?php
9{
10 protected $backupGlobals = false;
11
12 protected function setUp()
13 {
14 PHPUnit_Framework_Error_Deprecated::$enabled = false;
15
16 include_once("./Services/PHPUnit/classes/class.ilUnitUtil.php");
17 ilUnitUtil::performInitialisation();
18 }
19
23 public function test_DIC($global_name, $class_name)
24 {
25 global $DIC;
26
27 $this->assertInstanceOf($class_name, $GLOBALS[$global_name]);
28 $this->assertInstanceOf($class_name, $DIC[$global_name]);
29 $this->assertSame($GLOBALS[$global_name], $DIC[$global_name]);
30 }
31
35 public function test_DIC_getters($class_name, $getter)
36 {
37 global $DIC;
38
39 $service = $getter($DIC);
40 $this->assertInstanceOf($class_name, $service);
41 }
42
43 public function globalsProvider()
44 {
45 // Add combinations of globals and their classes here...
46 return array( array("ilIliasIniFile", "ilIniFile")
47 , array("ilCtrl", "ilCtrl")
48 , array("tree", "ilTree")
49 , array("ilLog", "ilLogger")
50 , array("ilDB", "ilDBInterface")
51 );
52 }
53
54 public function getterProvider()
55 {
56 return array( array("ilDBInterface", function ($DIC) {
57 return $DIC->database();
58 })
59 , array("ilCtrl", function ($DIC) {
60 return $DIC->ctrl();
61 })
62 , array("ilObjUser", function ($DIC) {
63 return $DIC->user();
64 })
65 , array("ilRbacSystem", function ($DIC) {
66 return $DIC->rbac()->system();
67 })
68 , array("ilRbacAdmin", function ($DIC) {
69 return $DIC->rbac()->admin();
70 })
71 , array("ilRbacReview", function ($DIC) {
72 return $DIC->rbac()->review();
73 })
74 , array("ilAccess", function ($DIC) {
75 return $DIC->access();
76 })
77 , array("ilTree", function ($DIC) {
78 return $DIC->repositoryTree();
79 })
80 , array("ilLanguage", function ($DIC) {
81 return $DIC->language();
82 })
83 // TODO: Can't test these until context for unit tests does not have HTML.
84 //, array("ilTemplate", function ($DIC) { return $DIC->ui()->mainTemplate(); })
85 //, array("ilToolbarGUI", function ($DIC) { return $DIC->toolbar(); })
86 //, array("ilTabsGUI", function ($DIC) { return $DIC->tabs(); })
87 //, array("ILIAS\\UI\\Factory", function ($DIC) { return $DIC->ui()->factory();})
88 //, array("ILIAS\\UI\\Renderer", function ($DIC) { return $DIC->ui()->renderer();})
89 , array("ilLogger", function ($DIC) {
90 return $DIC->logger()->root();
91 })
92 , array("ilLogger", function ($DIC) {
93 return $DIC->logger()->grp();
94 })
95 , array("ilLogger", function ($DIC) {
96 return $DIC->logger()->crs();
97 })
98 , array("ilLogger", function ($DIC) {
99 return $DIC->logger()->tree();
100 })
101 );
102 }
103}
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
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
$service
Definition: login.php:15
global $DIC
Definition: saml.php:7