ILIAS  trunk Revision v12.0_alpha-1540-g00f839d5fa1
EventTest Class Reference

Test clipboard repository. More...

+ Inheritance diagram for EventTest:
+ Collaboration diagram for EventTest:

Public Member Functions

 testEvent ()
 Test event. More...
 

Protected Member Functions

 setUp ()
 
 setGlobalVariable (string $name, $value)
 
 tearDown ()
 
 getHandler ()
 

Detailed Description

Test clipboard repository.

Author
Alexander Killing killi.nosp@m.ng@l.nosp@m.eifos.nosp@m..de

Definition at line 31 of file EventTest.php.

Member Function Documentation

◆ getHandler()

EventTest::getHandler ( )
protected

Definition at line 97 of file EventTest.php.

98 {
99 $logger = $this->createMock(ilLogger::class);
100
101 return new ilAppEventHandler($logger);
102 }
Global event handler.

Referenced by testEvent().

+ Here is the caller graph for this function:

◆ setGlobalVariable()

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

Definition at line 81 of file EventTest.php.

81 : void
82 {
83 global $DIC;
84
85 $GLOBALS[$name] = $value;
86
87 unset($DIC[$name]);
88 $DIC[$name] = static function (Container $c) use ($value) {
89 return $value;
90 };
91 }
Customizing of pimple-DIC for ILIAS.
Definition: Container.php:36
$c
Definition: deliver.php:25
global $DIC
Definition: shib_login.php:26
$GLOBALS["DIC"]
Definition: wac.php:54

References $c, $DIC, and $GLOBALS.

Referenced by setUp().

+ Here is the caller graph for this function:

◆ setUp()

EventTest::setUp ( )
protected

Definition at line 35 of file EventTest.php.

35 : void
36 {
38 $GLOBALS['DIC'] = $dic;
39
40 if (!defined("ILIAS_LOG_ENABLED")) {
41 define("ILIAS_LOG_ENABLED", false);
42 }
43
44 parent::setUp();
45
46 $db_mock = $this->createMock(ilDBInterface::class);
47 $db_mock->method("fetchAssoc")
48 ->willReturnOnConsecutiveCalls(
49 [
50 "component" => "components/ILIAS/EventHandling",
51 "id" => "MyTestComponent"
52 ],
53 null
54 );
55
56
57 $this->setGlobalVariable(
58 "ilDB",
59 $db_mock
60 );
61 $this->setGlobalVariable(
62 "ilSetting",
63 $this->createMock(ilSetting::class)
64 );
65 $component_repository = $this->createMock(ilComponentRepository::class);
66 $this->setGlobalVariable(
67 "component.repository",
68 $component_repository
69 );
70 $component_factory = $this->createMock(ilComponentFactory::class);
71 $this->setGlobalVariable(
72 "component.factory",
73 $component_factory
74 );
75 }
setGlobalVariable(string $name, $value)
Definition: EventTest.php:81
$dic
Definition: ltiresult.php:33

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

+ Here is the call graph for this function:

◆ tearDown()

EventTest::tearDown ( )
protected

Definition at line 93 of file EventTest.php.

93 : void
94 {
95 }

◆ testEvent()

EventTest::testEvent ( )

Test event.

Definition at line 107 of file EventTest.php.

107 : void
108 {
109 $handler = $this->getHandler();
110
111 $this->expectException(ilEventHandlingTestException::class);
112
113 $handler->raise(
114 "components/ILIAS/EventHandling",
115 "myEvent",
116 [
117 "par1" => "val1",
118 "par2" => "val2"
119 ]
120 );
121 }
getHandler()
Definition: EventTest.php:97
$handler
Definition: oai.php:31

References $handler, and getHandler().

+ Here is the call graph for this function:

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