/** * Test getting unread conversation count as other user without proper capability. */ public function test_get_unread_conversations_count_as_other_user_without_cap() { $this->resetAfterTest(true); // Create some users. $user1 = self::getDataGenerator()->create_user(); $user2 = self::getDataGenerator()->create_user(); // The person wanting the conversation count. $this->setUser($user1); // Ensure an exception is thrown. $this->expectException('moodle_exception'); core_message_external::get_unread_conversations_count($user2->id); }