[ Index ] |
PHP Cross Reference of DokuWiki |
[Summary view] [Print] [Text view]
1 <?php 2 3 use dokuwiki\Extension\Event; 4 5 /** 6 * This tests if event handlers can trigger the same event again. 7 * This is used by plugins that modify cache handling and use metadata 8 * for checking cache validity which triggers another cache use event. 9 */ 10 class events_nested_test extends DokuWikiTest { 11 function test_nested_events() { 12 global $EVENT_HANDLER; 13 $firstcount = 0; 14 $secondcount = 0; 15 16 $EVENT_HANDLER->register_hook('NESTED_EVENT', 'BEFORE', null, 17 function() use (&$firstcount) { 18 $firstcount++; 19 if ($firstcount == 1) { 20 $param = array(); 21 Event::createAndTrigger('NESTED_EVENT', $param); 22 } 23 } 24 ); 25 26 $EVENT_HANDLER->register_hook('NESTED_EVENT', 'BEFORE', null, 27 function() use (&$secondcount) { 28 $secondcount++; 29 } 30 ); 31 32 $param = array(); 33 Event::createAndTrigger('NESTED_EVENT', $param); 34 35 $this->assertEquals(2, $firstcount); 36 $this->assertEquals(2, $secondcount); 37 } 38 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body