/** * Test set_user_preferences for other user not being admin */ public function test_set_user_preferences_other_user_not_being_admin() { $this->resetAfterTest(true); $user1 = self::getDataGenerator()->create_user(); $user2 = self::getDataGenerator()->create_user(); $this->setUser($user1); $preferences = array(array('name' => 'calendar_maxevents', 'value' => 4, 'userid' => $user2->id)); $this->expectException('required_capability_exception'); $result = core_user_external::set_user_preferences($preferences); }