diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/event/dispatcher_test.php | 16 | ||||
-rw-r--r-- | tests/event/fixtures/event_migration.test | 30 | ||||
-rw-r--r-- | tests/event/php_exporter_test.php | 19 |
3 files changed, 65 insertions, 0 deletions
diff --git a/tests/event/dispatcher_test.php b/tests/event/dispatcher_test.php index 7bba5bf337..da28d24daa 100644 --- a/tests/event/dispatcher_test.php +++ b/tests/event/dispatcher_test.php @@ -29,5 +29,21 @@ class phpbb_event_dispatcher_test extends phpbb_test_case $result = $dispatcher->trigger_event('core.test_event', compact($vars)); $this->assertSame(array('foo' => 'foo2', 'bar' => 'bar2'), $result); + + // Test migrating events + $dispatcher->addListener('core.foo_br', function(\phpbb\event\data $event) { + $event['pi'] = '3.14159'; + }); + $dispatcher->addListener('core.foo_bar', function(\phpbb\event\data $event) { + $event['pi'] = '3.1'; + }); + + + $pi = '3'; + + $vars = array('pi'); + $result = $dispatcher->trigger_event(['core.foo_bar', 'core.foo_br'], compact($vars)); + + $this->assertSame(array('pi' => '3.14159'), $result); } } diff --git a/tests/event/fixtures/event_migration.test b/tests/event/fixtures/event_migration.test new file mode 100644 index 0000000000..b2df9f95df --- /dev/null +++ b/tests/event/fixtures/event_migration.test @@ -0,0 +1,30 @@ +<?php + + /** + * Modify pm and sender data before it is assigned to the template + * + * @event core.ucp_pm_view_message + * @var mixed id Active module category (can be int or string) + * @var string mode Active module + * @var int folder_id ID of the folder the message is in + * @var int msg_id ID of the private message + * @var array folder Array with data of user's message folders + * @var array message_row Array with message data + * @var array cp_row Array with senders custom profile field data + * @var array msg_data Template array with message data + * @var array user_info User data of the sender + * @since 3.1.0-a1 + * @changed 3.1.6-RC1 Added user_info into event + */ + $vars = array( + 'id', + 'mode', + 'folder_id', + 'msg_id', + 'folder', + 'message_row', + 'cp_row', + 'msg_data', + 'user_info', + ); + extract($phpbb_dispatcher->trigger_event(['core.ucp_pm_view_message', 'core.ucp_pm_view_messsage'], compact($vars))); diff --git a/tests/event/php_exporter_test.php b/tests/event/php_exporter_test.php index 692a57f93c..21dbb1e1d4 100644 --- a/tests/event/php_exporter_test.php +++ b/tests/event/php_exporter_test.php @@ -38,6 +38,18 @@ class phpbb_event_php_exporter_test extends phpbb_test_case ), ), array( + 'event_migration.test', + array( + 'core.ucp_pm_view_message' => array( + 'event' => 'core.ucp_pm_view_message', + 'file' => 'event_migration.test', + 'arguments' => array('cp_row', 'folder', 'folder_id', 'id', 'message_row', 'mode', 'msg_data', 'msg_id', 'user_info'), + 'since' => '3.1.0-a1', + 'description' => 'Modify pm and sender data before it is assigned to the template', + ), + ), + ), + array( 'extra_description.test', array( 'extra_description.dispatch' => array( @@ -240,6 +252,8 @@ class phpbb_event_php_exporter_test extends phpbb_test_case array("\t\$phpbb_dispatcher->dispatch('dispatch.one2.thr_ee4');", 'dispatch.one2.thr_ee4'), array("\$this->dispatcher->dispatch('dispatch.one2');", 'dispatch.one2'), array("\$phpbb_dispatcher->dispatch('dis_patch.one');", 'dis_patch.one'), + array("\$phpbb_dispatcher->dispatch(['dis_patch.one', 'dis_patch.one2']);", 'dis_patch.one'), + array("\$phpbb_dispatcher->dispatch(['dis_patch.one', 'dis_patch.one2', 'dis_patch.two3']);", 'dis_patch.one'), ); } @@ -259,6 +273,8 @@ class phpbb_event_php_exporter_test extends phpbb_test_case array("\$phpbb_dispatcher->dispatch('');"), array("\$phpbb_dispatcher->dispatch('dispatch.2one');"), array("\$phpbb_dispatcher->dispatch('dispatch');"), + array("\$phpbb_dispatcher->dispatch(['dispatch.one']);"), + array("\$phpbb_dispatcher->dispatch(array('dispatch.one', 'dispatch.one2'));"), ); } @@ -279,6 +295,8 @@ class phpbb_event_php_exporter_test extends phpbb_test_case array("\textract(\$phpbb_dispatcher->trigger_event('dispatch.one2.thr_ee4', compact(\$vars)));", 'dispatch.one2.thr_ee4'), array("extract(\$this->dispatcher->trigger_event('dispatch.one2', compact(\$vars)));", 'dispatch.one2'), array("extract(\$phpbb_dispatcher->trigger_event('dis_patch.one', compact(\$vars)));", 'dis_patch.one'), + array("extract(\$phpbb_dispatcher->trigger_event(['dis_patch.one', 'dis_patch.one2'], compact(\$vars)));", 'dis_patch.one'), + array("extract(\$phpbb_dispatcher->trigger_event(['dis_patch.one', 'dis_patch.one2', 'dis_patch.two3'], compact(\$vars)));", 'dis_patch.one'), ); } @@ -301,6 +319,7 @@ class phpbb_event_php_exporter_test extends phpbb_test_case array("extract(\$phpbb_dispatcher->trigger_event('dispatch.one', \$vars));"), array("extract(\$phpbb_dispatcher->trigger_event('dispatch.one', compact(\$var)));"), array("extract(\$phpbb_dispatcher->trigger_event('dispatch.one', compact(\$array)));"), + array("extract(\$phpbb_dispatcher->trigger_event(['dispatch.one'], compact(\$vars)));"), array("\$phpbb_dispatcher->trigger_event('dis_patch.one', compact(\$vars));", 'dis_patch.one'), ); } |