aboutsummaryrefslogtreecommitdiffstats
path: root/tests/event
diff options
context:
space:
mode:
authorMaat <maat-pub@mageia.biz>2020-05-08 21:52:11 +0200
committerMaat <maat-pub@mageia.biz>2020-05-08 21:52:11 +0200
commit8ea437e30605e0f66b5220bf904a61d7c1d11ddd (patch)
treee0db2bb4a012d5b06a633160b19f62f4868ecd28 /tests/event
parent36bc1870f21fac04736a1049c1d5b8e127d729f4 (diff)
parent2fdd46b36431ae0f58bb2e78e42553168db9a0ff (diff)
downloadforums-8ea437e30605e0f66b5220bf904a61d7c1d11ddd.tar
forums-8ea437e30605e0f66b5220bf904a61d7c1d11ddd.tar.gz
forums-8ea437e30605e0f66b5220bf904a61d7c1d11ddd.tar.bz2
forums-8ea437e30605e0f66b5220bf904a61d7c1d11ddd.tar.xz
forums-8ea437e30605e0f66b5220bf904a61d7c1d11ddd.zip
Merge remote-tracking branch 'upstream/prep-release-3.2.9'
Diffstat (limited to 'tests/event')
-rw-r--r--tests/event/dispatcher_test.php16
-rw-r--r--tests/event/exception_listener_test.php10
-rw-r--r--tests/event/fixtures/event_migration.test30
-rw-r--r--tests/event/fixtures/extra_description.test2
-rw-r--r--tests/event/md_exporter_test.php12
-rw-r--r--tests/event/php_exporter_test.php21
6 files changed, 74 insertions, 17 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/exception_listener_test.php b/tests/event/exception_listener_test.php
index 4d3453cd83..08679a3ed8 100644
--- a/tests/event/exception_listener_test.php
+++ b/tests/event/exception_listener_test.php
@@ -11,8 +11,6 @@
*
*/
-require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
-
class exception_listener extends phpbb_test_case
{
public function phpbb_exception_data()
@@ -79,10 +77,12 @@ class exception_listener extends phpbb_test_case
->disableOriginalConstructor()
->getMock();
- $user = new \phpbb\user('\phpbb\datetime');
- $user->add_lang('common');
+ global $phpbb_root_path, $phpEx;
+
+ $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx);
+ $lang = new \phpbb\language\language($lang_loader);
- $exception_listener = new \phpbb\event\kernel_exception_subscriber($template, $user);
+ $exception_listener = new \phpbb\event\kernel_exception_subscriber($template, $lang);
$event = new \Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent($this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface'), $request, \Symfony\Component\HttpKernel\HttpKernelInterface::MASTER_REQUEST, $exception);
$exception_listener->on_kernel_exception($event);
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/fixtures/extra_description.test b/tests/event/fixtures/extra_description.test
index ce8f97ce89..e93a1044ac 100644
--- a/tests/event/fixtures/extra_description.test
+++ b/tests/event/fixtures/extra_description.test
@@ -3,7 +3,7 @@
/**
* Description
*
-* NOTE: This will not be exported
+* NOTE: This will also be exported
*
* @event extra_description.dispatch
* @since 3.1.0-b2
diff --git a/tests/event/md_exporter_test.php b/tests/event/md_exporter_test.php
index 1a51204cbe..2eeb48ea05 100644
--- a/tests/event/md_exporter_test.php
+++ b/tests/event/md_exporter_test.php
@@ -11,8 +11,6 @@
*
*/
-require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
-
class phpbb_event_md_exporter_test extends phpbb_test_case
{
static public function crawl_eventsmd_data()
@@ -23,7 +21,6 @@ class phpbb_event_md_exporter_test extends phpbb_test_case
'event' => 'acp_bbcodes_actions_append',
'files' => array(
'prosilver' => array(),
- 'subsilver2' => array(),
'adm' => array('acp_bbcodes.html'),
),
'since' => '3.1.0-a3',
@@ -36,7 +33,6 @@ class phpbb_event_md_exporter_test extends phpbb_test_case
'event' => 'acp_bbcodes_actions_prepend',
'files' => array(
'prosilver' => array(),
- 'subsilver2' => array(),
'adm' => array('acp_bbcodes.html'),
),
'since' => '3.1.0-a5',
@@ -47,7 +43,6 @@ class phpbb_event_md_exporter_test extends phpbb_test_case
'event' => 'acp_bbcodes_actions_prepend2',
'files' => array(
'prosilver' => array(),
- 'subsilver2' => array(),
'adm' => array('acp_bbcodes.html'),
),
'since' => '3.1.0-a4',
@@ -63,7 +58,6 @@ class phpbb_event_md_exporter_test extends phpbb_test_case
'event' => 'acp_bbcodes_actions_prepend',
'files' => array(
'prosilver' => array(),
- 'subsilver2' => array(),
'adm' => array('acp_bbcodes.html'),
),
'since' => '3.1.0-a5',
@@ -74,7 +68,6 @@ class phpbb_event_md_exporter_test extends phpbb_test_case
'event' => 'acp_bbcodes_actions_prepend2',
'files' => array(
'prosilver' => array(),
- 'subsilver2' => array(),
'adm' => array('acp_bbcodes.html'),
),
'since' => '3.1.0-a4',
@@ -99,7 +92,7 @@ class phpbb_event_md_exporter_test extends phpbb_test_case
public function test_crawl_eventsmd($file, $min_version, $max_version, $events)
{
$exporter = new \phpbb\event\md_exporter(dirname(__FILE__) . '/fixtures/', null, $min_version, $max_version);
- $this->assertSame(sizeof($events), $exporter->crawl_eventsmd($file, 'adm'));
+ $this->assertSame(count($events), $exporter->crawl_eventsmd($file, 'adm'));
$this->assertEquals($events, $exporter->get_events());
}
@@ -130,7 +123,6 @@ class phpbb_event_md_exporter_test extends phpbb_test_case
$styles = array(
'adm/style/' => 'adm',
'styles/prosilver/template/' => 'styles',
- 'styles/subsilver2/template/' => 'styles',
);
foreach ($styles as $path => $filter)
{
@@ -154,7 +146,7 @@ class phpbb_event_md_exporter_test extends phpbb_test_case
$exporter->crawl_eventsmd('docs/events.md', $filter);
$events = $exporter->crawl_file_for_events($file);
- $this->assertGreaterThanOrEqual(0, sizeof($events));
+ $this->assertGreaterThanOrEqual(0, count($events));
$this->assertTrue($exporter->validate_events_from_file($file, $events));
}
}
diff --git a/tests/event/php_exporter_test.php b/tests/event/php_exporter_test.php
index 692a57f93c..c6670e1340 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(
@@ -45,7 +57,7 @@ class phpbb_event_php_exporter_test extends phpbb_test_case
'file' => 'extra_description.test',
'arguments' => array(),
'since' => '3.1.0-b2',
- 'description' => 'Description',
+ 'description' => 'Description<br/><br/>NOTE: This will also be exported',
),
),
),
@@ -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'),
);
}