From 8575f6f3d5fd07a5f2d8b2993f2b5b03ad2eb145 Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Wed, 4 Dec 2024 10:58:47 -0800 Subject: [PATCH] Fix tests --- tests/event/listener_test.php | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/tests/event/listener_test.php b/tests/event/listener_test.php index 1bcb393..714d547 100644 --- a/tests/event/listener_test.php +++ b/tests/event/listener_test.php @@ -149,6 +149,7 @@ public function test_getSubscribedEvents() 'core.ucp_display_module_before', 'core.acp_main_notice', 'core.acp_board_config_edit_add', + 'core.acp_board_config_emoji_enabled', 'core.validate_config_variable', 'core.help_manager_add_block_after', ], array_keys(\phpbb\webpushnotifications\event\listener::getSubscribedEvents())); @@ -376,7 +377,6 @@ public function test_acp_pwa_options($mode, $display_vars, $expected_keys) $keys = array_keys($display_vars['vars']); self::assertEquals($expected_keys, $keys); - } public function validate_pwa_options_data() @@ -420,6 +420,21 @@ public function validate_pwa_options_data() [ 'pwa_options:string', ['pwa_short_name' => 'foo❤️'], + [], + ], + [ + 'pwa_options:string', + ['pwa_short_name' => 'Фаны phpBB'], + [], + ], + [ + 'pwa_options:string', + ['pwa_short_name' => 'Фаны phpBB Board'], + ['PWA_SHORT_NAME_INVALID'], + ], + [ + 'pwa_options:string', + ['pwa_short_name' => 'foo❤️bar foo bar'], ['PWA_SHORT_NAME_INVALID'], ], [ @@ -472,6 +487,24 @@ public function test_validate_pwa_options($validate, $cfg_array, $expected_error self::assertEquals($expected_error, $error); } + public function test_acp_pwa_allow_emoji() + { + $config_name_ary = ['foo']; + $expected = ['foo', 'pwa_short_name']; + + $this->set_listener(); + + $dispatcher = new \phpbb\event\dispatcher(); + $dispatcher->addListener('core.acp_board_config_emoji_enabled', [$this->listener, 'acp_pwa_allow_emoji']); + + $event_data = ['config_name_ary']; + $event_data_after = $dispatcher->trigger_event('core.acp_board_config_emoji_enabled', compact($event_data)); + + extract($event_data_after, EXTR_OVERWRITE); + + self::assertEquals($expected, $config_name_ary); + } + public function test_wpn_faq() { $this->language->add_lang('webpushnotifications_faq', 'phpbb/webpushnotifications');