mirror of
https://github.com/phpbb/phpbb.git
synced 2025-07-30 13:30:25 +02:00
[feature/event-dispatcher] Change phpbb_event_dispatcher to inheritance, tests
PHPBB3-9550
This commit is contained in:
29
tests/event/dispatcher_test.php
Normal file
29
tests/event/dispatcher_test.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* @package testing
|
||||
* @copyright (c) 2010 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
class phpbb_event_dispatcher_test extends phpbb_test_case
|
||||
{
|
||||
public function test_trigger_event()
|
||||
{
|
||||
$dispatcher = new phpbb_event_dispatcher();
|
||||
|
||||
$dispatcher->addListener('core.test_event', function (phpbb_event_data $event) {
|
||||
$event['foo'] = $event['foo'] . '2';
|
||||
$event['bar'] = $event['bar'] . '2';
|
||||
});
|
||||
|
||||
$foo = 'foo';
|
||||
$bar = 'bar';
|
||||
|
||||
$vars = array('foo', 'bar');
|
||||
$result = $dispatcher->trigger_event('core.test_event', compact($vars));
|
||||
|
||||
$this->assertSame(array('foo' => 'foo2', 'bar' => 'bar2'), $result);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user