ILIAS  trunk Revision v12.0_alpha-1221-g4e438232683
ilRepositoryTreeTest Class Reference
+ Inheritance diagram for ilRepositoryTreeTest:
+ Collaboration diagram for ilRepositoryTreeTest:

Public Member Functions

 testTreeConstruct ()
 
 testInitLanguage ()
 

Protected Member Functions

 setUp ()
 
 setGlobalVariable (string $name, $value)
 
 initRepositoryTreeDependencies ()
 

Protected Attributes

Container $dic
 

Detailed Description

Definition at line 24 of file ilRepositoryTreeTest.php.

Member Function Documentation

◆ initRepositoryTreeDependencies()

ilRepositoryTreeTest::initRepositoryTreeDependencies ( )
protected

Definition at line 89 of file ilRepositoryTreeTest.php.

89 : void
90 {
91 $this->dic = new Container();
92 $GLOBALS['DIC'] = $this->dic;
93
94 $this->setGlobalVariable('ilDB', $this->createMock(ilDBInterface::class));
95 $this->setGlobalVariable('ilAppEventHandler', $this->createMock(ilAppEventHandler::class));
96
97 $logger = $this->getMockBuilder(ilLogger::class)
98 ->disableOriginalConstructor()
99 ->getMock();
100
101 $logger_factory = $this->getMockBuilder(ilLoggerFactory::class)
102 ->disableOriginalConstructor()
103 ->onlyMethods(['getComponentLogger'])
104 ->getMock();
105 $logger_factory->method('getComponentLogger')->willReturn($logger);
106 $this->setGlobalVariable('ilLoggerFactory', $logger_factory);
107 }
Customizing of pimple-DIC for ILIAS.
Definition: Container.php:36
setGlobalVariable(string $name, $value)
$GLOBALS["DIC"]
Definition: wac.php:54

References $dic, $GLOBALS, and setGlobalVariable().

Referenced by setUp().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setGlobalVariable()

ilRepositoryTreeTest::setGlobalVariable ( string  $name,
  $value 
)
protected
Parameters
string$name
mixed$value

Definition at line 78 of file ilRepositoryTreeTest.php.

78 : void
79 {
80 global $DIC;
81
82 $GLOBALS[$name] = $value;
83 unset($DIC[$name]);
84 $DIC[$name] = static function (\ILIAS\DI\Container $c) use ($value) {
85 return $value;
86 };
87 }
$c
Definition: deliver.php:25
global $DIC
Definition: shib_login.php:26

References $c, $DIC, and $GLOBALS.

Referenced by initRepositoryTreeDependencies(), and testInitLanguage().

+ Here is the caller graph for this function:

◆ setUp()

ilRepositoryTreeTest::setUp ( )
protected

Definition at line 28 of file ilRepositoryTreeTest.php.

28 : void
29 {
31 parent::setUp();
32 if (!defined("ROOT_FOLDER_ID")) {
33 define("ROOT_FOLDER_ID", 8);
34 }
35 if (!defined("ILIAS_LOG_ENABLED")) {
36 define("ILIAS_LOG_ENABLED", false);
37 }
38 if (!defined("ILIAS_LOG_DIR")) {
39 define("ILIAS_LOG_DIR", '/var/log');
40 }
41 if (!defined("ILIAS_LOG_FILE")) {
42 define("ILIAS_LOG_FILE", '/var/log/ilias.log');
43 }
44 }

References initRepositoryTreeDependencies().

+ Here is the call graph for this function:

◆ testInitLanguage()

ilRepositoryTreeTest::testInitLanguage ( )

Definition at line 52 of file ilRepositoryTreeTest.php.

52 : void
53 {
54 // no global user available
55 $tree = new ilTree(1);
56 $tree->initLangCode();
57 $tree_reflection = new ReflectionProperty($tree, 'lang_code');
58 $this->assertEquals('en', $tree_reflection->getValue($tree));
59
60 // user getCurrentLanguage() from session is empty
61 $tree = new ilTree(1);
62
63 $user = $this->getMockBuilder(ilObjUser::class)
64 ->disableOriginalConstructor()
65 ->onlyMethods(['getCurrentLanguage'])
66 ->getMock();
67 $user->method('getCurrentLanguage')->willReturn('');
68 $this->setGlobalVariable('ilUser', $user);
69 $tree->initLangCode();
70 $tree_reflection = new ReflectionProperty($tree, 'lang_code');
71 $this->assertEquals('en', $tree_reflection->getValue($tree));
72 }
Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco...

References setGlobalVariable().

+ Here is the call graph for this function:

◆ testTreeConstruct()

ilRepositoryTreeTest::testTreeConstruct ( )

Definition at line 46 of file ilRepositoryTreeTest.php.

46 : void
47 {
48 $tree = new ilTree(1);
49 $this->assertTrue($tree instanceof ilTree);
50 }

Field Documentation

◆ $dic

Container ilRepositoryTreeTest::$dic
protected

Definition at line 26 of file ilRepositoryTreeTest.php.

Referenced by initRepositoryTreeDependencies().


The documentation for this class was generated from the following file: