From b4c75986ad7725c30014bd3ab5111935a1aa2506 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pau=20Ferrer=20Oca=C3=B1a?= Date: Wed, 29 Jan 2020 16:45:32 +0100 Subject: [PATCH] MDL-67853 message: Adapt tests removing online/offline settings --- admin/tool/mobile/tests/api_test.php | 2 +- .../monitor/tests/behat/subscription.feature | 4 +- badges/tests/badgeslib_test.php | 2 +- lib/tests/message_test.php | 4 +- lib/tests/messagelib_test.php | 26 ++-- .../airnotifier/classes/privacy/provider.php | 2 +- message/output/airnotifier/externallib.php | 1 - .../airnotifier/tests/externallib_test.php | 22 +-- .../behat/notification_popover_unread.feature | 5 +- message/tests/api_test.php | 8 +- ...ge_manage_notification_preferences.feature | 143 +++++++++++++++++- .../tests/behat/message_preferences.feature | 5 +- message/tests/externallib_test.php | 18 +-- message/tests/privacy/provider_test.php | 15 +- mod/forum/tests/mail_test.php | 3 +- 15 files changed, 188 insertions(+), 72 deletions(-) diff --git a/admin/tool/mobile/tests/api_test.php b/admin/tool/mobile/tests/api_test.php index 9099b12ee45e7..fa2a22aa15dd5 100644 --- a/admin/tool/mobile/tests/api_test.php +++ b/admin/tool/mobile/tests/api_test.php @@ -107,7 +107,7 @@ public function test_pre_processor_message_send_callback() { set_config('allowedemaildomains', 'example.com'); $DB->set_field_select('message_processors', 'enabled', 0, "name <> 'email'"); - set_user_preference('message_provider_moodle_instantmessage_loggedoff', 'email', $user2); + set_user_preference('message_provider_moodle_instantmessage_enabled', 'email', $user2); // Extra content for all types of messages. $message = new \core\message\message(); diff --git a/admin/tool/monitor/tests/behat/subscription.feature b/admin/tool/monitor/tests/behat/subscription.feature index 3b881b4b6252d..d0ff66a9983cf 100644 --- a/admin/tool/monitor/tests/behat/subscription.feature +++ b/admin/tool/monitor/tests/behat/subscription.feature @@ -103,7 +103,7 @@ Feature: tool_monitor_subscriptions Given I log in as "admin" And I follow "Preferences" in the user menu And I click on "Notification preferences" "link" in the "#page-content" "css_element" - And I click on "//td[@data-processor-name='popup']//label[@data-state='loggedin']" "xpath_element" in the "Notifications of rule subscriptions" "table_row" + And I click on "//td[@data-processor-name='popup']//div[@class='preference-state']" "xpath_element" in the "Notifications of rule subscriptions" "table_row" And I wait until the page is ready And I follow "Preferences" in the user menu And I follow "Event monitoring" @@ -124,7 +124,7 @@ Feature: tool_monitor_subscriptions Given I log in as "teacher1" And I follow "Preferences" in the user menu And I click on "Notification preferences" "link" in the "#page-content" "css_element" - And I click on "//td[@data-processor-name='popup']//label[@data-state='loggedin']" "xpath_element" in the "Notifications of rule subscriptions" "table_row" + And I click on "//td[@data-processor-name='popup']//div[@class='preference-state']" "xpath_element" in the "Notifications of rule subscriptions" "table_row" And I wait until the page is ready And I follow "Preferences" in the user menu And I follow "Event monitoring" diff --git a/badges/tests/badgeslib_test.php b/badges/tests/badgeslib_test.php index 8becec48113fc..e1469437d45f9 100644 --- a/badges/tests/badgeslib_test.php +++ b/badges/tests/badgeslib_test.php @@ -305,7 +305,7 @@ public function test_badge_awards() { $sink = $this->redirectMessages(); $DB->set_field_select('message_processors', 'enabled', 0, "name <> 'email'"); - set_user_preference('message_provider_moodle_badgerecipientnotice_loggedoff', 'email', $user1); + set_user_preference('message_provider_moodle_badgerecipientnotice_enabled', 'email', $user1); $badge->issue($user1->id, false); $this->assertDebuggingCalled(); // Expect debugging while baking a badge via phpunit. diff --git a/lib/tests/message_test.php b/lib/tests/message_test.php index eefd415a42d4e..b6e8fa2714d41 100644 --- a/lib/tests/message_test.php +++ b/lib/tests/message_test.php @@ -144,7 +144,7 @@ public function test_send_message() { $this->assertFileExists("$CFG->dirroot/message/output/popup/version.php"); $DB->set_field_select('message_processors', 'enabled', 0, "name <> 'email'"); - set_user_preference('message_provider_moodle_instantmessage_loggedoff', 'email', $user2); + set_user_preference('message_provider_moodle_instantmessage_enabled', 'email', $user2); // Extra content for all types of messages. $message = new \core\message\message(); @@ -241,7 +241,7 @@ public function test_send_message_with_prefix() { $this->assertFileExists("$CFG->dirroot/message/output/popup/version.php"); $DB->set_field_select('message_processors', 'enabled', 0, "name <> 'email'"); - set_user_preference('message_provider_moodle_instantmessage_loggedoff', 'email', $user2); + set_user_preference('message_provider_moodle_instantmessage_enabled', 'email', $user2); // Check that prefix is ammended to the subject of the email. $message = new \core\message\message(); diff --git a/lib/tests/messagelib_test.php b/lib/tests/messagelib_test.php index b77b08f7b13e7..1f15471f29d67 100644 --- a/lib/tests/messagelib_test.php +++ b/lib/tests/messagelib_test.php @@ -412,7 +412,7 @@ public function test_send_message() { $eventsink = $this->redirectEvents(); // Will always use the pop-up processor. - set_user_preference('message_provider_moodle_instantmessage_loggedoff', 'none', $user2); + set_user_preference('message_provider_moodle_instantmessage_enabled', 'none', $user2); $message = new \core\message\message(); $message->courseid = 1; @@ -500,7 +500,7 @@ public function test_send_message() { $eventsink->clear(); // Will always use the pop-up processor. - set_user_preference('message_provider_moodle_instantmessage_loggedoff', 'email', $user2); + set_user_preference('message_provider_moodle_instantmessage_enabled', 'email', $user2); $message = new \core\message\message(); $message->courseid = 1; @@ -533,7 +533,7 @@ public function test_send_message() { $user2->emailstop = '0'; // Will always use the pop-up processor. - set_user_preference('message_provider_moodle_instantmessage_loggedoff', 'email', $user2); + set_user_preference('message_provider_moodle_instantmessage_enabled', 'email', $user2); $message = new \core\message\message(); $message->courseid = 1; @@ -566,7 +566,7 @@ public function test_send_message() { $this->assertInstanceOf('\core\event\message_sent', $events[0]); $eventsink->clear(); - set_user_preference('message_provider_moodle_instantmessage_loggedoff', 'email,popup', $user2); + set_user_preference('message_provider_moodle_instantmessage_enabled', 'email,popup', $user2); $message = new \core\message\message(); $message->courseid = 1; @@ -600,7 +600,7 @@ public function test_send_message() { $this->assertInstanceOf('\core\event\message_sent', $events[0]); $eventsink->clear(); - set_user_preference('message_provider_moodle_instantmessage_loggedoff', 'popup', $user2); + set_user_preference('message_provider_moodle_instantmessage_enabled', 'popup', $user2); $message = new \core\message\message(); $message->courseid = 1; @@ -635,7 +635,7 @@ public function test_send_message() { $transaction->allow_commit(); // Will always use the pop-up processor. - set_user_preference('message_provider_moodle_instantmessage_loggedoff', 'none', $user2); + set_user_preference('message_provider_moodle_instantmessage_enabled', 'none', $user2); $message = new \core\message\message(); $message->courseid = 1; @@ -668,7 +668,7 @@ public function test_send_message() { $this->assertInstanceOf('\core\event\message_sent', $events[0]); // Will always use the pop-up processor. - set_user_preference('message_provider_moodle_instantmessage_loggedoff', 'email', $user2); + set_user_preference('message_provider_moodle_instantmessage_enabled', 'email', $user2); $message = new \core\message\message(); $message->courseid = 1; @@ -783,7 +783,7 @@ public function test_message_send_to_conversation_individual() { // Ensure we're going to hit the email processor for this user. $DB->set_field_select('message_processors', 'enabled', 0, "name <> 'email'"); - set_user_preference('message_provider_moodle_instantmessage_loggedoff', 'email', $user2); + set_user_preference('message_provider_moodle_instantmessage_enabled', 'email', $user2); // Now, send a message and verify the message processors (in this case, email) are hit. $sink = $this->redirectEmails(); @@ -869,7 +869,7 @@ public function test_message_send_to_self_conversation() { // Ensure we're going to hit the email processor for this user. $DB->set_field_select('message_processors', 'enabled', 0, "name <> 'email'"); - set_user_preference('message_provider_moodle_instantmessage_loggedoff', 'email', $user1); + set_user_preference('message_provider_moodle_instantmessage_enabled', 'email', $user1); // Now, send a message and verify the message processors are empty (self-conversations are not processed for now). $sink = $this->redirectEmails(); @@ -941,8 +941,8 @@ public function test_message_send_to_conversation_group() { // Ensure the email processor is enabled for the recipient users. $DB->set_field_select('message_processors', 'enabled', 0, "name <> 'email'"); - set_user_preference('message_provider_moodle_instantmessage_loggedoff', 'email', $user2); - set_user_preference('message_provider_moodle_instantmessage_loggedoff', 'email', $user3); + set_user_preference('message_provider_moodle_instantmessage_enabled', 'email', $user2); + set_user_preference('message_provider_moodle_instantmessage_enabled', 'email', $user3); // Now, send a message and verify the email processor are hit. $messageid = message_send($message); @@ -1016,8 +1016,8 @@ public function test_send_message_to_conversation_group_with_buffering() { $eventsink = $this->redirectEvents(); // Will always use the pop-up processor. - set_user_preference('message_provider_moodle_instantmessage_loggedoff', 'email', $user2); - set_user_preference('message_provider_moodle_instantmessage_loggedoff', 'email', $user3); + set_user_preference('message_provider_moodle_instantmessage_enabled', 'email', $user2); + set_user_preference('message_provider_moodle_instantmessage_enabled', 'email', $user3); $message = new \core\message\message(); $message->courseid = 1; diff --git a/message/output/airnotifier/classes/privacy/provider.php b/message/output/airnotifier/classes/privacy/provider.php index a02672c92c8e6..27d062372764b 100644 --- a/message/output/airnotifier/classes/privacy/provider.php +++ b/message/output/airnotifier/classes/privacy/provider.php @@ -68,7 +68,7 @@ public static function get_metadata(collection $collection) : collection { 'smallmessage' => 'privacy:metadata:smallmessage', 'fullmessage' => 'privacy:metadata:fullmessage' ], 'privacy:metadata:externalpurpose'); - // This system is unaware of user preferences such as message_provider_moodle_instantmessage_loggedin. + // This system is unaware of user preferences such as message_provider_moodle_instantmessage_enabled. return $collection; } diff --git a/message/output/airnotifier/externallib.php b/message/output/airnotifier/externallib.php index 255dda9b69a2e..a5275ec20221c 100644 --- a/message/output/airnotifier/externallib.php +++ b/message/output/airnotifier/externallib.php @@ -149,7 +149,6 @@ public static function are_notification_preferences_configured($userids) { break; } - $prefstocheck = []; $prefname = 'message_provider_'.$provider->component.'_'.$provider->name.'_enabled'; diff --git a/message/output/airnotifier/tests/externallib_test.php b/message/output/airnotifier/tests/externallib_test.php index a4fbbf8524501..86e44ed23ed9e 100644 --- a/message/output/airnotifier/tests/externallib_test.php +++ b/message/output/airnotifier/tests/externallib_test.php @@ -86,10 +86,8 @@ public function test_are_notification_preferences_configured() { self::setUser($user1); - set_user_preference('message_provider_moodle_instantmessage_loggedin', 'airnotifier', $user1); - set_user_preference('message_provider_moodle_instantmessage_loggedoff', 'airnotifier', $user1); - set_user_preference('message_provider_moodle_instantmessage_loggedin', 'airnotifier', $user2); - set_user_preference('message_provider_moodle_instantmessage_loggedin', 'airnotifier', $user3); + set_user_preference('message_provider_moodle_instantmessage_enabled', 'airnotifier', $user1); + set_user_preference('message_provider_moodle_instantmessage_enabled', 'airnotifier', $user2); $params = array($user1->id, $user2->id, $user3->id); @@ -116,23 +114,11 @@ public function test_are_notification_preferences_configured() { $this->assertEquals($expected, $preferences['users']); $this->assertEquals(2, count($preferences['warnings'])); - // Now, remove one user1 preference (the user still has one prefernce for airnotifier). - unset_user_preference('message_provider_moodle_instantmessage_loggedin', $user1); + // Now, remove one user1 preference (the user still has one preference for airnotifier). + unset_user_preference('message_provider_moodle_instantmessage_enabled', $user1); $preferences = message_airnotifier_external::are_notification_preferences_configured($params); $preferences = external_api::clean_returnvalue($returnsdescription, $preferences); $this->assertEquals($expected, $preferences['users']); - - // Delete the last user1 preference. - unset_user_preference('message_provider_moodle_instantmessage_loggedoff', $user1); - $preferences = message_airnotifier_external::are_notification_preferences_configured($params); - $preferences = external_api::clean_returnvalue($returnsdescription, $preferences); - $expected = array( - array( - 'userid' => $user1->id, - 'configured' => 1 - ) - ); - $this->assertEquals($expected, $preferences['users']); } /** diff --git a/message/output/popup/tests/behat/notification_popover_unread.feature b/message/output/popup/tests/behat/notification_popover_unread.feature index 0fbec12e49203..51c37cca75a94 100644 --- a/message/output/popup/tests/behat/notification_popover_unread.feature +++ b/message/output/popup/tests/behat/notification_popover_unread.feature @@ -13,9 +13,8 @@ Feature: Notification popover unread notifications | Course 1 | C1 | 0 | 1 | # Make sure the popup notifications are enabled for assignments. And the following config values are set as admin: - | popup_provider_mod_assign_assign_notification_permitted | permitted | message | - | message_provider_mod_assign_assign_notification_loggedin | popup | message | - | message_provider_mod_assign_assign_notification_loggedoff | popup | message | + | popup_provider_mod_assign_assign_notification_locked | 0 | message | + | message_provider_mod_assign_assign_notification_enabled | popup | message | And the following "users" exist: | username | firstname | lastname | email | | teacher1 | Teacher | 1 | teacher1@example.com | diff --git a/message/tests/api_test.php b/message/tests/api_test.php index dfcdf5c163444..a099a7db38ba0 100644 --- a/message/tests/api_test.php +++ b/message/tests/api_test.php @@ -2967,15 +2967,15 @@ public function test_get_all_message_preferences() { $this->setUser($user); // Set a couple of preferences to test. - set_user_preference('message_provider_mod_assign_assign_notification_loggedin', 'popup', $user); - set_user_preference('message_provider_mod_assign_assign_notification_loggedoff', 'email', $user); + set_user_preference('message_provider_mod_assign_assign_notification_enabled', 'popup', $user); + set_user_preference('message_provider_mod_feedback_submission_enabled', 'email', $user); $processors = get_message_processors(); $providers = message_get_providers_for_user($user->id); $prefs = \core_message\api::get_all_message_preferences($processors, $providers, $user); - $this->assertEquals(1, $prefs->mod_assign_assign_notification_loggedin['popup']); - $this->assertEquals(1, $prefs->mod_assign_assign_notification_loggedoff['email']); + $this->assertEquals(1, $prefs->mod_assign_assign_notification_enabled['popup']); + $this->assertEquals(1, $prefs->mod_feedback_submission_enabled['email']); } /** diff --git a/message/tests/behat/message_manage_notification_preferences.feature b/message/tests/behat/message_manage_notification_preferences.feature index f27e116acf1fb..b66050b81a23e 100644 --- a/message/tests/behat/message_manage_notification_preferences.feature +++ b/message/tests/behat/message_manage_notification_preferences.feature @@ -8,6 +8,7 @@ Feature: Manage notification preferences - Email Given the following "users" exist: | username | firstname | lastname | email | | student1 | Student | 1 | student1@example.com | + | student2 | Student | 2 | student2@example.com | And the following config values are set as admin: | messaging | 1 | @@ -27,8 +28,7 @@ Feature: Manage notification preferences - Email # Disable email default value Given the following "user preferences" exist: | user | preference | value | - | student1 | message_provider_moodle_instantmessage_loggedin | none | - | student1 | message_provider_moodle_instantmessage_loggedoff | none | + | student1 | message_provider_moodle_instantmessage_enabled | none | When I log in as "admin" And I navigate to "Messaging > Notification settings" in site administration And I set the field "email" to "1" @@ -61,3 +61,142 @@ Feature: Manage notification preferences - Email And I follow "Preferences" in the user menu And I click on "Message preferences" "link" And the field "Email" matches value "0" + + Scenario: Disable email notifications for Assignment notifications + Given I log in as "admin" + When I navigate to "Messaging > Notification settings" in site administration + And I set the field "email" to "1" + And I press "Save changes" + Then the field "email" matches value "1" + And I set the field "mod_assign_assign_notification_disable" to "0" + And I press "Save changes" + And the field "mod_assign_assign_notification_disable" matches value "0" + And I follow "Preferences" in the user menu + And I click on "Notification preferences" "link" in the "#page-content" "css_element" + And I should not see "Assignment notifications" + + Scenario: Lock email notifications for Forum providers + Given I log in as "admin" + When I navigate to "Messaging > Notification settings" in site administration + And I set the field "email" to "1" + And I press "Save changes" + Then the field "email" matches value "1" + And I set the field "mod_forum_posts_enabled[email]" to "1" + And I set the field "mod_forum_posts_locked[email]" to "1" + And I set the field "mod_forum_digests_enabled[email]" to "0" + And I set the field "mod_forum_digests_locked[email]" to "1" + And I press "Save changes" + And the field "mod_forum_posts_enabled[email]" matches value "1" + And the field "mod_forum_posts_locked[email]" matches value "1" + And the field "mod_forum_digests_enabled[email]" matches value "0" + And the field "mod_forum_digests_locked[email]" matches value "1" + And I follow "Preferences" in the user menu + And I click on "Notification preferences" "link" in the "#page-content" "css_element" + And I should see "Locked" in the "[data-preference-key=message_provider_mod_forum_posts]" "css_element" + And I should see "Disallowed" in the "[data-preference-key=message_provider_mod_forum_digests]" "css_element" + + Scenario: User can disable notification preferences + Given the following "courses" exist: + | fullname | shortname | category | groupmode | + | Course 1 | C1 | 0 | 1 | + And the following "course enrolments" exist: + | user | course | role | + | student1 | C1 | student | + | student2 | C1 | student | + And the following config values are set as admin: + | popup_provider_mod_assign_assign_notification_locked | 0 | message | + | message_provider_mod_assign_assign_notification_enabled | popup | message | + And the following "user preferences" exist: + | user | preference | value | + | student1 | message_provider_mod_assign_assign_notification_enabled | none | + | student2 | message_provider_mod_assign_assign_notification_enabled | popup | + And the following "activity" exists: + | activity | assign | + | course | C1 | + | name | Test assignment name | + | assignsubmission_onlinetext_enabled | 1 | + | assignsubmission_file_enabled | 0 | + | submissiondrafts | 0 | + # This should generate a notification. + And the following "mod_assign > submissions" exist: + | assign | user | onlinetext | + | Test assignment name | student1 | I'm the student1 submission | + | Test assignment name | student2 | I'm the student2 submission | + When I log in as "student1" + # Confirm the popover is not showing any unread notifications. + Then I should not see "1" in the "#nav-notification-popover-container [data-region='count-container']" "css_element" + # Open the popover. + And I open the notification popover + # Confirm the submission notification is NOT visible. + And I should not see "You have submitted your assignment submission for Test assignment name" in the "#nav-notification-popover-container" "css_element" + And I log in as "student2" + # Confirm the popover is showing the unread notifications. + Then I should see "1" in the "#nav-notification-popover-container [data-region='count-container']" "css_element" + # Open the popover. + And I open the notification popover + # Confirm the submission notification is visible. + And I should see "You have submitted your assignment submission for Test assignment name" in the "#nav-notification-popover-container" "css_element" + + Scenario: User cannot disable forced notification preferences + Given the following "courses" exist: + | fullname | shortname | category | groupmode | + | Course 1 | C1 | 0 | 1 | + And the following "course enrolments" exist: + | user | course | role | + | student1 | C1 | student | + And the following config values are set as admin: + | popup_provider_mod_assign_assign_notification_locked | 1 | message | + | message_provider_mod_assign_assign_notification_enabled | popup | message | + And the following "user preferences" exist: + | user | preference | value | + | student1 | message_provider_mod_assign_assign_notification_enabled | none | + And the following "activity" exists: + | activity | assign | + | course | C1 | + | name | Test assignment name | + | assignsubmission_onlinetext_enabled | 1 | + | assignsubmission_file_enabled | 0 | + | submissiondrafts | 0 | + # This should generate a notification. + And the following "mod_assign > submissions" exist: + | assign | user | onlinetext | + | Test assignment name | student1 | I'm the student1 submission | + When I log in as "student1" + # Confirm the popover is saying 1 unread notifications. + Then I should see "1" in the "#nav-notification-popover-container [data-region='count-container']" "css_element" + # Open the popover. + And I open the notification popover + # Confirm the submission notification is visible. + And I should see "You have submitted your assignment submission for Test assignment name" in the "#nav-notification-popover-container" "css_element" + + Scenario: User cannot disable disallowed notification preferences + Given the following "courses" exist: + | fullname | shortname | category | groupmode | + | Course 1 | C1 | 0 | 1 | + And the following "course enrolments" exist: + | user | course | role | + | student1 | C1 | student | + And the following config values are set as admin: + | popup_provider_mod_assign_assign_notification_locked | 1 | message | + | message_provider_mod_assign_assign_notification_enabled | none | message | + And the following "user preferences" exist: + | user | preference | value | + | student1 | message_provider_mod_assign_assign_notification_enabled | popup | + And the following "activity" exists: + | activity | assign | + | course | C1 | + | name | Test assignment name | + | assignsubmission_onlinetext_enabled | 1 | + | assignsubmission_file_enabled | 0 | + | submissiondrafts | 0 | + # This should generate a notification. + And the following "mod_assign > submissions" exist: + | assign | user | onlinetext | + | Test assignment name | student1 | I'm the student1 submission | + When I log in as "student1" + # Confirm the popover is not showing any unread notifications. + Then I should not see "1" in the "#nav-notification-popover-container [data-region='count-container']" "css_element" + # Open the popover. + And I open the notification popover + # Confirm the submission notification is NOT visible. + And I should not see "You have submitted your assignment submission for Test assignment name" in the "#nav-notification-popover-container" "css_element" diff --git a/message/tests/behat/message_preferences.feature b/message/tests/behat/message_preferences.feature index e12ee118b631c..a8e530340e888 100644 --- a/message/tests/behat/message_preferences.feature +++ b/message/tests/behat/message_preferences.feature @@ -9,8 +9,7 @@ Feature: To be able to see and save user message preferences as admin | student1 | Student | 1 | student1@emample.com | And the following "user preferences" exist: | user | preference | value | - | student1 | message_provider_moodle_instantmessage_loggedin | none | - | student1 | message_provider_moodle_instantmessage_loggedoff | email | + | student1 | message_provider_moodle_instantmessage_enabled | email | @javascript Scenario: As an admin I can view and edit message preferences for a user @@ -22,7 +21,7 @@ Feature: To be able to see and save user message preferences as admin And I click on "Student 1" "link" in the "Student 1" "table_row" And I click on "Preferences" "link" in the "#region-main-box" "css_element" And I click on "Message preferences" "link" in the "#region-main-box" "css_element" - And I click on "//label[@data-state='loggedoff']" "xpath_element" + And I click on "//div[@class='preference-state']" "xpath_element" And I log out And I log in as "student1" And I follow "Preferences" in the user menu diff --git a/message/tests/externallib_test.php b/message/tests/externallib_test.php index f716e85703ccb..30441c3e8de09 100644 --- a/message/tests/externallib_test.php +++ b/message/tests/externallib_test.php @@ -1977,8 +1977,7 @@ public function test_get_user_notification_preferences() { $this->setUser($user); // Set a couple of preferences to test. - set_user_preference('message_provider_mod_assign_assign_notification_loggedin', 'popup', $user); - set_user_preference('message_provider_mod_assign_assign_notification_loggedoff', 'email', $user); + set_user_preference('message_provider_mod_assign_assign_notification_enabled', 'popup', $user); $prefs = core_message_external::get_user_notification_preferences(); $prefs = external_api::clean_returnvalue(core_message_external::get_user_notification_preferences_returns(), $prefs); @@ -1998,16 +1997,13 @@ public function test_get_user_notification_preferences() { } foreach ($prefdata['processors'] as $processor) { if ($processor['name'] == 'popup') { - $this->assertTrue($processor['loggedin']['checked']); - $found++; - } else if ($processor['name'] == 'email') { - $this->assertTrue($processor['loggedoff']['checked']); - $found++; + $this->assertTrue($processor['enabled']); + $found = 1; } } } } - $this->assertEquals(2, $found); + $this->assertEquals(1, $found); } /** @@ -3491,8 +3487,7 @@ public function test_get_user_message_preferences() { set_config('messagingallusers', true); // Set a couple of preferences to test. - set_user_preference('message_provider_moodle_instantmessage_loggedin', 'email', $user); - set_user_preference('message_provider_moodle_instantmessage_loggedoff', 'email', $user); + set_user_preference('message_provider_moodle_instantmessage_enabled', 'email', $user); set_user_preference('message_blocknoncontacts', \core_message\api::MESSAGE_PRIVACY_SITE, $user); $prefs = core_message_external::get_user_message_preferences(); @@ -3512,8 +3507,7 @@ public function test_get_user_message_preferences() { } foreach ($prefdata['processors'] as $processor) { if ($processor['name'] == 'email') { - $this->assertTrue($processor['loggedin']['checked']); - $this->assertTrue($processor['loggedoff']['checked']); + $this->assertTrue($processor['enabled']); $found = true; } } diff --git a/message/tests/privacy/provider_test.php b/message/tests/privacy/provider_test.php index f3e19c0fa1d73..9863c5906b3ea 100644 --- a/message/tests/privacy/provider_test.php +++ b/message/tests/privacy/provider_test.php @@ -170,11 +170,12 @@ public function test_export_user_preferences() { $user = $this->getDataGenerator()->create_user(); // Set some message user preferences. - set_user_preference('message_provider_moodle_instantmessage_loggedin', 'airnotifier', $USER->id); - set_user_preference('message_provider_moodle_instantmessage_loggedoff', 'popup', $USER->id); + set_user_preference('message_provider_moodle_instantmessage_enabled', 'airnotifier', $USER->id); + set_user_preference('message_provider_mod_feedback_submission_enabled', 'popup', $USER->id); + set_user_preference('message_blocknoncontacts', \core_message\api::MESSAGE_PRIVACY_ONLYCONTACTS, $USER->id); set_user_preference('message_entertosend', true, $USER->id); - set_user_preference('message_provider_moodle_instantmessage_loggedoff', 'inbound', $user->id); + set_user_preference('message_provider_moodle_instantmessage_enabled', 'inbound', $user->id); // Set an unrelated preference. set_user_preference('some_unrelated_preference', 'courses', $USER->id); @@ -189,15 +190,15 @@ public function test_export_user_preferences() { // Check only 3 preferences exist. $this->assertCount(4, $prefs); - $this->assertArrayHasKey('message_provider_moodle_instantmessage_loggedin', $prefs); - $this->assertArrayHasKey('message_provider_moodle_instantmessage_loggedoff', $prefs); + $this->assertArrayHasKey('message_provider_moodle_instantmessage_enabled', $prefs); + $this->assertArrayHasKey('message_provider_mod_feedback_submission_enabled', $prefs); $this->assertArrayHasKey('message_blocknoncontacts', $prefs); $this->assertArrayHasKey('message_entertosend', $prefs); foreach ($prefs as $key => $pref) { - if ($key == 'message_provider_moodle_instantmessage_loggedin') { + if ($key == 'message_provider_moodle_instantmessage_enabled') { $this->assertEquals('airnotifier', $pref->value); - } else if ($key == 'message_provider_moodle_instantmessage_loggedoff') { + } else if ($key == 'message_provider_mod_feedback_submission_enabled') { $this->assertEquals('popup', $pref->value); } else { $this->assertEquals(1, $pref->value); diff --git a/mod/forum/tests/mail_test.php b/mod/forum/tests/mail_test.php index c9d0247b8b832..4a60c7646d152 100644 --- a/mod/forum/tests/mail_test.php +++ b/mod/forum/tests/mail_test.php @@ -865,8 +865,7 @@ public function test_forum_message_inbound_multiple_posts() { $this->helper_spoof_message_inbound_setup(); $author->emailstop = '0'; - set_user_preference('message_provider_mod_forum_posts_loggedoff', 'email', $author); - set_user_preference('message_provider_mod_forum_posts_loggedin', 'email', $author); + set_user_preference('message_provider_mod_forum_posts_enabled', 'email', $author); // Run cron and check that the expected number of users received the notification. // Clear the mailsink, and close the messagesink.