/** * Tests retrieving contacts with messaging disabled. */ public function test_messagearea_contacts_messaging_disabled() { global $CFG; $this->resetAfterTest(true); // Create some skeleton data just so we can call the WS. $user = self::getDataGenerator()->create_user(); // The person retrieving the contacts. $this->setUser($user); // Disable messaging. $CFG->messaging = 0; // Perform the WS call and ensure we are shown that it is disabled. $this->expectException('moodle_exception'); core_message_external::data_for_messagearea_contacts($user->id); }