ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
ilInitialisationTest.php
Go to the documentation of this file.
1<?php
9 protected $backupGlobals = FALSE;
10
11 protected function setUp() {
12 PHPUnit_Framework_Error_Deprecated::$enabled = FALSE;
13
14 include_once("./Services/PHPUnit/classes/class.ilUnitUtil.php");
15 ilUnitUtil::performInitialisation();
16 }
17
21 public function test_DIC($global_name, $class_name) {
22 global $DIC;
23
24 $this->assertInstanceOf($class_name, $GLOBALS[$global_name]);
25 $this->assertInstanceOf($class_name, $DIC[$global_name]);
26 $this->assertSame($GLOBALS[$global_name], $DIC[$global_name]);
27 }
28
32 public function test_DIC_getters($class_name, $getter) {
33 global $DIC;
34
35 $service = $getter($DIC);
36 $this->assertInstanceOf($class_name, $service);
37 }
38
39 public function globalsProvider() {
40 // Add combinations of globals and their classes here...
41 return array
42 ( array("ilIliasIniFile", "ilIniFile")
43 , array("ilCtrl", "ilCtrl")
44 , array("tree", "ilTree")
45 , array("ilLog", "ilLogger")
46 , array("ilDB", "ilDBInterface")
47 );
48 }
49
50 public function getterProvider() {
51 return array
52 ( array("ilDBInterface", function ($DIC) { return $DIC->database(); })
53 , array("ilCtrl", function ($DIC) { return $DIC->ctrl(); })
54 , array("ilObjUser", function ($DIC) { return $DIC->user(); })
55 , array("ilRbacSystem", function ($DIC) { return $DIC->rbac()->system(); })
56 , array("ilRbacAdmin", function ($DIC) { return $DIC->rbac()->admin(); })
57 , array("ilRbacReview", function ($DIC) { return $DIC->rbac()->review(); })
58 , array("ilAccessHandler", function ($DIC) { return $DIC->access(); })
59 , array("ilTree", function ($DIC) { return $DIC->repositoryTree(); })
60 , array("ilLanguage", function ($DIC) { return $DIC->language(); })
61 // TODO: Can't test these until context for unit tests does not have HTML.
62 //, array("ilTemplate", function ($DIC) { return $DIC->ui()->mainTemplate(); })
63 //, array("ilToolbarGUI", function ($DIC) { return $DIC->toolbar(); })
64 //, array("ilTabsGUI", function ($DIC) { return $DIC->tabs(); })
65 //, array("ILIAS\\UI\\Factory", function ($DIC) { return $DIC->ui()->factory();})
66 //, array("ILIAS\\UI\\Renderer", function ($DIC) { return $DIC->ui()->renderer();})
67 , array("ilLogger", function ($DIC) { return $DIC->logger()->root(); })
68 , array("ilLogger", function ($DIC) { return $DIC->logger()->grp(); })
69 , array("ilLogger", function ($DIC) { return $DIC->logger()->crs(); })
70 , array("ilLogger", function ($DIC) { return $DIC->logger()->tree(); })
71 );
72 }
73}
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.
global $DIC