blob: fe5e395bb174699bd4ae5a18c97575aa9ce871b8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
<?php
/**
* This tests if event handlers can trigger the same event again.
* This is used by plugins that modify cache handling and use metadata
* for checking cache validity which triggers another cache use event.
*/
class events_nested_test extends DokuWikiTest {
function test_nested_events() {
global $EVENT_HANDLER;
$firstcount = 0;
$secondcount = 0;
$EVENT_HANDLER->register_hook('NESTED_EVENT', 'BEFORE', null,
function() use (&$firstcount) {
$firstcount++;
if ($firstcount == 1) {
$param = array();
trigger_event('NESTED_EVENT', $param);
}
}
);
$EVENT_HANDLER->register_hook('NESTED_EVENT', 'BEFORE', null,
function() use (&$secondcount) {
$secondcount++;
}
);
$param = array();
trigger_event('NESTED_EVENT', $param);
$this->assertEquals(2, $firstcount);
$this->assertEquals(2, $secondcount);
}
}
|