diff --git a/.upgradenotes/MDL-82287-2024062501330649.yml b/.upgradenotes/MDL-82287-2024062501330649.yml new file mode 100644 index 00000000000..e1bfa14b872 --- /dev/null +++ b/.upgradenotes/MDL-82287-2024062501330649.yml @@ -0,0 +1,40 @@ +issueNumber: MDL-82287 +notes: + core: + - message: > + The following methods have been formally deprecated: + + + - `get_core_subsystems` + + - `get_plugin_types` + + - `get_plugin_list` + + - `get_plugin_list_with_class` + + - `get_plugin_directory` + + - `normalize_component` + + - `get_component_directory` + + - `get_context_instance` + + + Note: These methods have been deprecated for a long time, but previously + did not emit any deprecation notice. + type: deprecated + - message: > + The following methods have been finally deprecated and will now throw an + exception if called: + + + - `get_context_instance` + + - `can_use_rotated_text` + + - `get_system_context` + + - `print_arrow` + type: deprecated diff --git a/lib/classes/grades_external.php b/lib/classes/grades_external.php index 671351f9ea2..20f36442f42 100644 --- a/lib/classes/grades_external.php +++ b/lib/classes/grades_external.php @@ -122,7 +122,7 @@ class core_grades_external extends external_api { ) ); - list($itemtype, $itemmodule) = normalize_component($params['component']); + list($itemtype, $itemmodule) = \core_component::normalize_component($params['component']); if (! $cm = get_coursemodule_from_id($itemmodule, $activityid)) { throw new moodle_exception('invalidcoursemodule'); diff --git a/lib/deprecatedlib.php b/lib/deprecatedlib.php index 8f694eabf32..b0efea86737 100644 --- a/lib/deprecatedlib.php +++ b/lib/deprecatedlib.php @@ -1,5 +1,4 @@ (string|null)location */ +#[\core\attribute\deprecated('core_component::get_core_subsystems', since: '4.5', mdl: 'MDL-82287')] function get_core_subsystems($fullpaths = false) { + \core\deprecation::emit_deprecation_if_present(__FUNCTION__); global $CFG; - // NOTE: do not add any other debugging here, keep forever. - $subsystems = core_component::get_core_subsystems(); if ($fullpaths) { @@ -78,15 +74,14 @@ function get_core_subsystems($fullpaths = false) { * Lists all plugin types. * * @deprecated since 2.6, use core_component::get_plugin_types() - * * @param bool $fullpaths false means relative paths from dirroot * @return array Array of strings - name=>location */ +#[\core\attribute\deprecated('core_component::get_plugin_types', since: '4.5', mdl: 'MDL-82287')] function get_plugin_types($fullpaths = true) { + \core\deprecation::emit_deprecation_if_present(__FUNCTION__); global $CFG; - // NOTE: do not add any other debugging here, keep forever. - $types = core_component::get_plugin_types(); if ($fullpaths) { @@ -112,13 +107,12 @@ function get_plugin_types($fullpaths = true) { * Use when listing real plugins of one type. * * @deprecated since 2.6, use core_component::get_plugin_list() - * * @param string $plugintype type of plugin * @return array name=>fulllocation pairs of plugins of given type */ +#[\core\attribute\deprecated('core_component::get_plugin_list', since: '4.5', mdl: 'MDL-82287')] function get_plugin_list($plugintype) { - - // NOTE: do not add any other debugging here, keep forever. + \core\deprecation::emit_deprecation_if_present(__FUNCTION__); if ($plugintype === '') { $plugintype = 'mod'; @@ -132,7 +126,6 @@ function get_plugin_list($plugintype) { * in a certain file. The plugin component names and class names are returned. * * @deprecated since 2.6, use core_component::get_plugin_list_with_class() - * * @param string $plugintype the type of plugin, e.g. 'mod' or 'report'. * @param string $class the part of the name of the class after the * frankenstyle prefix. e.g 'thing' if you are looking for classes with @@ -142,10 +135,9 @@ function get_plugin_list($plugintype) { * @return array with frankenstyle plugin names as keys (e.g. 'report_courselist', 'mod_forum') * and the class names as values (e.g. 'report_courselist_thing', 'qtype_multichoice'). */ +#[\core\attribute\deprecated('core_component::get_plugin_list_with_class', since: '4.5', mdl: 'MDL-82287')] function get_plugin_list_with_class($plugintype, $class, $file) { - - // NOTE: do not add any other debugging here, keep forever. - + \core\deprecation::emit_deprecation_if_present(__FUNCTION__); return core_component::get_plugin_list_with_class($plugintype, $class, $file); } @@ -153,15 +145,13 @@ function get_plugin_list_with_class($plugintype, $class, $file) { * Returns the exact absolute path to plugin directory. * * @deprecated since 2.6, use core_component::get_plugin_directory() - * * @param string $plugintype type of plugin * @param string $name name of the plugin * @return string full path to plugin directory; NULL if not found */ +#[\core\attribute\deprecated('core_component::get_plugin_directory', since: '4.5', mdl: 'MDL-82287')] function get_plugin_directory($plugintype, $name) { - - // NOTE: do not add any other debugging here, keep forever. - + \core\deprecation::emit_deprecation_if_present(__FUNCTION__); if ($plugintype === '') { $plugintype = 'mod'; } @@ -173,14 +163,12 @@ function get_plugin_directory($plugintype, $name) { * Normalize the component name using the "frankenstyle" names. * * @deprecated since 2.6, use core_component::normalize_component() - * * @param string $component * @return array two-items list of [(string)type, (string|null)name] */ +#[\core\attribute\deprecated('core_component::normalize_component', since: '4.5', mdl: 'MDL-82287')] function normalize_component($component) { - - // NOTE: do not add any other debugging here, keep forever. - + \core\deprecation::emit_deprecation_if_present(__FUNCTION__); return core_component::normalize_component($component); } @@ -192,66 +180,34 @@ function normalize_component($component) { * @param string $component name such as 'moodle', 'mod_forum' * @return string full path to component directory; NULL if not found */ +#[\core\attribute\deprecated('core_component::get_component_directory', since: '4.5', mdl: 'MDL-82287')] function get_component_directory($component) { - - // NOTE: do not add any other debugging here, keep forever. - + \core\deprecation::emit_deprecation_if_present(__FUNCTION__); return core_component::get_component_directory($component); } /** - * Get the context instance as an object. This function will create the - * context instance if it does not exist yet. - * * @deprecated since 2.2, use context_course::instance() or other relevant class instead - * @todo This will be deleted in Moodle 2.8, refer MDL-34472 - * @param integer $contextlevel The context level, for example CONTEXT_COURSE, or CONTEXT_MODULE. - * @param integer $instance The instance id. For $level = CONTEXT_COURSE, this would be $course->id, - * for $level = CONTEXT_MODULE, this would be $cm->id. And so on. Defaults to 0 - * @param int $strictness IGNORE_MISSING means compatible mode, false returned if record not found, debug message if more found; - * MUST_EXIST means throw exception if no record or multiple records found - * @return context The context object. */ -function get_context_instance($contextlevel, $instance = 0, $strictness = IGNORE_MISSING) { - - debugging('get_context_instance() is deprecated, please use context_xxxx::instance() instead.', DEBUG_DEVELOPER); - - $instances = (array)$instance; - $contexts = array(); - - $classname = context_helper::get_class_for_level($contextlevel); - - // we do not load multiple contexts any more, PAGE should be responsible for any preloading - foreach ($instances as $inst) { - $contexts[$inst] = $classname::instance($inst, $strictness); - } - - if (is_array($instance)) { - return $contexts; - } else { - return $contexts[$instance]; - } +#[\core\attribute\deprecated('\core\context::instance', since: '2.2', mdl: 'MDL-34472', final: true)] +function get_context_instance() { + \core\deprecation::emit_deprecation_if_present(__FUNCTION__); } -/* === End of long term deprecated api list === */ /** * @deprecated since 2.5 - do not use, the textrotate.js will work it out automatically */ +#[\core\attribute\deprecated('Not replaced', since: '2.0', mdl: 'MDL-19756', final: true)] function can_use_rotated_text() { - debugging('can_use_rotated_text() is removed. JS feature detection is used automatically.'); + \core\deprecation::emit_deprecation_if_present(__FUNCTION__); } /** - * Returns system context or null if can not be created yet. - * - * @see context_system::instance() * @deprecated since 2.2 - * @param bool $cache use caching - * @return context system context (null if context table not created yet) */ -function get_system_context($cache = true) { - debugging('get_system_context() is deprecated, please use context_system::instance() instead.', DEBUG_DEVELOPER); - return context_system::instance(0, IGNORE_MISSING, $cache); +#[\core\attribute\deprecated('\core\context\system::instance', since: '2.2', mdl: 'MDL-34472', final: true)] +function get_system_context() { + \core\deprecation::emit_deprecation_if_present(__FUNCTION__); } /** @@ -259,56 +215,10 @@ function get_system_context($cache = true) { * provide this function with the language strings for sortasc and sortdesc. * * @deprecated use $OUTPUT->arrow() instead. - * @todo final deprecation of this function once MDL-45448 is resolved - * - * If no sort string is associated with the direction, an arrow with no alt text will be printed/returned. - * - * @global object - * @param string $direction 'up' or 'down' - * @param string $strsort The language string used for the alt attribute of this image - * @param bool $return Whether to print directly or return the html string - * @return string|void depending on $return - * */ -function print_arrow($direction='up', $strsort=null, $return=false) { - global $OUTPUT; - - debugging('print_arrow() is deprecated. Please use $OUTPUT->arrow() instead.', DEBUG_DEVELOPER); - - if (!in_array($direction, array('up', 'down', 'right', 'left', 'move'))) { - return null; - } - - $return = null; - - switch ($direction) { - case 'up': - $sortdir = 'asc'; - break; - case 'down': - $sortdir = 'desc'; - break; - case 'move': - $sortdir = 'asc'; - break; - default: - $sortdir = null; - break; - } - - // Prepare language string - $strsort = ''; - if (empty($strsort) && !empty($sortdir)) { - $strsort = get_string('sort' . $sortdir, 'grades'); - } - - $return = ' ' . $OUTPUT->pix_icon('t/' . $direction, $strsort) . ' '; - - if ($return) { - return $return; - } else { - echo $return; - } +#[\core\attribute\deprecated('OUTPUT->[l|r]arrow', since: '2.0', mdl: 'MDL-19756', final: true)] +function print_arrow() { + \core\deprecation::emit_deprecation_if_present(__FUNCTION__); } /** diff --git a/lib/tests/accesslib_test.php b/lib/tests/accesslib_test.php index be464e2f660..37a5b6da656 100644 --- a/lib/tests/accesslib_test.php +++ b/lib/tests/accesslib_test.php @@ -4045,26 +4045,6 @@ class accesslib_test extends advanced_testcase { context_user::instance($testusers[102]); $this->assertEquals($prevsize + 1, context_inspection::check_context_cache_size()); unset($testusers); - - - - // Test basic test of legacy functions. - // Note: watch out, the fake site might be pretty borked already. - - $this->assertEquals(get_system_context(), context_system::instance()); - $this->assertDebuggingCalled('get_system_context() is deprecated, please use context_system::instance() instead.', DEBUG_DEVELOPER); - - foreach ($DB->get_records('context') as $contextid => $record) { - $context = context::instance_by_id($contextid); - $this->assertEquals($context, get_context_instance($record->contextlevel, $record->instanceid)); - $this->assertDebuggingCalled('get_context_instance() is deprecated, please use context_xxxx::instance() instead.', DEBUG_DEVELOPER); - } - - // Make sure a debugging is thrown. - get_context_instance($record->contextlevel, $record->instanceid); - $this->assertDebuggingCalled('get_context_instance() is deprecated, please use context_xxxx::instance() instead.', DEBUG_DEVELOPER); - get_system_context(); - $this->assertDebuggingCalled('get_system_context() is deprecated, please use context_system::instance() instead.', DEBUG_DEVELOPER); } /** diff --git a/lib/tests/component_test.php b/lib/tests/component_test.php index 97b6a31fdc1..c511952f775 100644 --- a/lib/tests/component_test.php +++ b/lib/tests/component_test.php @@ -99,11 +99,16 @@ final class component_test extends advanced_testcase { $subsystems = core_component::get_core_subsystems(); $this->assertSame($subsystems, get_core_subsystems(true)); + $this->assertDebuggingCalled(); + $this->resetDebugging(); $realsubsystems = get_core_subsystems(); - $this->assertDebuggingCalled(); + $this->assertdebuggingcalledcount(2); + $this->resetDebugging(); + $this->assertSame($realsubsystems, get_core_subsystems(false)); - $this->assertDebuggingCalled(); + $this->assertdebuggingcalledcount(2); + $this->resetDebugging(); $this->assertEquals(count($subsystems), count($realsubsystems)); @@ -138,10 +143,16 @@ final class component_test extends advanced_testcase { $plugintypes = core_component::get_plugin_types(); $this->assertSame($plugintypes, get_plugin_types()); + $this->assertDebuggingCalled(); + $this->resetDebugging(); + $this->assertSame($plugintypes, get_plugin_types(true)); + $this->assertDebuggingCalled(); + $this->resetDebugging(); $realplugintypes = get_plugin_types(false); - $this->assertDebuggingCalled(); + $this->assertdebuggingcalledcount(2); + $this->resetDebugging(); foreach ($plugintypes as $plugintype => $fulldir) { $this->assertSame($fulldir, $CFG->dirroot . '/' . $realplugintypes[$plugintype]); @@ -175,6 +186,8 @@ final class component_test extends advanced_testcase { foreach ($plugintypes as $plugintype => $fulldir) { $plugins = core_component::get_plugin_list($plugintype); $this->assertSame($plugins, get_plugin_list($plugintype)); + $this->assertDebuggingCalled(); + $this->resetDebugging(); } } @@ -199,6 +212,8 @@ final class component_test extends advanced_testcase { core_component::get_plugin_directory($plugintype, $pluginname), get_plugin_directory($plugintype, $pluginname), ); + $this->assertDebuggingCalled(); + $this->resetDebugging(); } } } @@ -308,92 +323,83 @@ final class component_test extends advanced_testcase { ); } - public function test_normalize_component(): void { - // Moodle core. - $this->assertSame(['core', null], core_component::normalize_component('core')); - $this->assertSame(['core', null], core_component::normalize_component('moodle')); - $this->assertSame(['core', null], core_component::normalize_component('')); - - // Moodle core subsystems. - $this->assertSame(['core', 'admin'], core_component::normalize_component('admin')); - $this->assertSame(['core', 'admin'], core_component::normalize_component('core_admin')); - $this->assertSame(['core', 'admin'], core_component::normalize_component('moodle_admin')); - - // Activity modules and their subplugins. - $this->assertSame(['mod', 'workshop'], core_component::normalize_component('workshop')); - $this->assertSame(['mod', 'workshop'], core_component::normalize_component('mod_workshop')); - $this->assertSame(['workshopform', 'accumulative'], core_component::normalize_component('workshopform_accumulative')); - $this->assertSame(['mod', 'quiz'], core_component::normalize_component('quiz')); - $this->assertSame(['quiz', 'grading'], core_component::normalize_component('quiz_grading')); - $this->assertSame(['mod', 'data'], core_component::normalize_component('data')); - $this->assertSame(['datafield', 'checkbox'], core_component::normalize_component('datafield_checkbox')); - - // Other plugin types. - $this->assertSame(['auth', 'mnet'], core_component::normalize_component('auth_mnet')); - $this->assertSame(['enrol', 'self'], core_component::normalize_component('enrol_self')); - $this->assertSame(['block', 'html'], core_component::normalize_component('block_html')); - $this->assertSame(['block', 'mnet_hosts'], core_component::normalize_component('block_mnet_hosts')); - $this->assertSame(['local', 'amos'], core_component::normalize_component('local_amos')); - $this->assertSame(['local', 'admin'], core_component::normalize_component('local_admin')); - - // Unknown words without underscore are supposed to be activity modules. + /** + * Test \core_component::normalize_component function. + * + * @dataProvider normalise_component_provider + * @param array $expected + * @param string $args + */ + public function test_normalize_component(array $expected, string $args): void { $this->assertSame( - ['mod', 'whoonearthwouldcomewithsuchastupidnameofcomponent'], - core_component::normalize_component('whoonearthwouldcomewithsuchastupidnameofcomponent') - ); - // Module names can not contain underscores, this must be a subplugin. - $this->assertSame( - ['whoonearth', 'wouldcomewithsuchastupidnameofcomponent'], - core_component::normalize_component('whoonearth_wouldcomewithsuchastupidnameofcomponent') - ); - $this->assertSame( - ['whoonearth', 'would_come_withsuchastupidnameofcomponent'], - core_component::normalize_component('whoonearth_would_come_withsuchastupidnameofcomponent') + $expected, + core_component::normalize_component($args), ); } - public function test_deprecated_normalize_component(): void { - // Moodle core. - $this->assertSame(['core', null], normalize_component('core')); - $this->assertSame(['core', null], normalize_component('')); - $this->assertSame(['core', null], normalize_component('moodle')); - - // Moodle core subsystems. - $this->assertSame(['core', 'admin'], normalize_component('admin')); - $this->assertSame(['core', 'admin'], normalize_component('core_admin')); - $this->assertSame(['core', 'admin'], normalize_component('moodle_admin')); - - // Activity modules and their subplugins. - $this->assertSame(['mod', 'workshop'], normalize_component('workshop')); - $this->assertSame(['mod', 'workshop'], normalize_component('mod_workshop')); - $this->assertSame(['workshopform', 'accumulative'], normalize_component('workshopform_accumulative')); - $this->assertSame(['mod', 'quiz'], normalize_component('quiz')); - $this->assertSame(['quiz', 'grading'], normalize_component('quiz_grading')); - $this->assertSame(['mod', 'data'], normalize_component('data')); - $this->assertSame(['datafield', 'checkbox'], normalize_component('datafield_checkbox')); - - // Other plugin types. - $this->assertSame(['auth', 'mnet'], normalize_component('auth_mnet')); - $this->assertSame(['enrol', 'self'], normalize_component('enrol_self')); - $this->assertSame(['block', 'html'], normalize_component('block_html')); - $this->assertSame(['block', 'mnet_hosts'], normalize_component('block_mnet_hosts')); - $this->assertSame(['local', 'amos'], normalize_component('local_amos')); - $this->assertSame(['local', 'admin'], normalize_component('local_admin')); - - // Unknown words without underscore are supposed to be activity modules. + /** + * Test the deprecated normalize_component function. + * + * @dataProvider normalise_component_provider + * @param array $expected + * @param string $args + */ + public function test_deprecated_normalize_component(array $expected, string $args): void { $this->assertSame( - ['mod', 'whoonearthwouldcomewithsuchastupidnameofcomponent'], - normalize_component('whoonearthwouldcomewithsuchastupidnameofcomponent') - ); - // Module names can not contain underscores, this must be a subplugin. - $this->assertSame( - ['whoonearth', 'wouldcomewithsuchastupidnameofcomponent'], - normalize_component('whoonearth_wouldcomewithsuchastupidnameofcomponent') - ); - $this->assertSame( - ['whoonearth', 'would_come_withsuchastupidnameofcomponent'], - normalize_component('whoonearth_would_come_withsuchastupidnameofcomponent') + $expected, + normalize_component($args), ); + + $this->assertDebuggingCalled(); + } + + /** + * Data provider for the normalize_component function. + */ + public static function normalise_component_provider(): array { + return [ + // Moodle core. + [['core', null], 'core'], + [['core', null], ''], + [['core', null], 'moodle'], + + // Moodle core subsystems. + [['core', 'admin'], 'admin'], + [['core', 'admin'], 'core_admin'], + [['core', 'admin'], 'moodle_admin'], + + // Activity modules and their subplugins. + [['mod', 'workshop'], 'workshop'], + [['mod', 'workshop'], 'mod_workshop'], + [['workshopform', 'accumulative'], 'workshopform_accumulative'], + [['mod', 'quiz'], 'quiz'], + [['quiz', 'grading'], 'quiz_grading'], + [['mod', 'data'], 'data'], + [['datafield', 'checkbox'], 'datafield_checkbox'], + + // Other plugin types. + [['auth', 'mnet'], 'auth_mnet'], + [['enrol', 'self'], 'enrol_self'], + [['block', 'html'], 'block_html'], + [['block', 'mnet_hosts'], 'block_mnet_hosts'], + [['local', 'amos'], 'local_amos'], + [['local', 'admin'], 'local_admin'], + + // Unknown words without underscore are supposed to be activity modules. + [ + ['mod', 'whoonearthwouldcomewithsuchastupidnameofcomponent'], + 'whoonearthwouldcomewithsuchastupidnameofcomponent', + ], + // Module names can not contain underscores, this must be a subplugin. + [ + ['whoonearth', 'wouldcomewithsuchastupidnameofcomponent'], + 'whoonearth_wouldcomewithsuchastupidnameofcomponent', + ], + [ + ['whoonearth', 'would_come_withsuchastupidnameofcomponent'], + 'whoonearth_would_come_withsuchastupidnameofcomponent', + ], + ]; } public function test_get_component_directory(): void { @@ -484,12 +490,16 @@ final class component_test extends advanced_testcase { $plugins = core_component::get_plugin_list($plugintype); foreach ($plugins as $pluginname => $plugindir) { $this->assertSame($plugindir, get_component_directory(($plugintype . '_' . $pluginname))); + $this->assertDebuggingCalled(); + $this->resetDebugging(); } } $subsystems = core_component::get_core_subsystems(); foreach ($subsystems as $subsystem => $fulldir) { $this->assertSame($fulldir, get_component_directory(('core_' . $subsystem))); + $this->assertDebuggingCalled(); + $this->resetDebugging(); } } diff --git a/lib/tests/csslib_test.php b/lib/tests/csslib_test.php deleted file mode 100644 index 11c4b83dfd8..00000000000 --- a/lib/tests/csslib_test.php +++ /dev/null @@ -1,51 +0,0 @@ -. - -namespace core; - -defined('MOODLE_INTERNAL') || die(); - -global $CFG; -require_once($CFG->libdir . '/csslib.php'); - -/** - * CSS optimiser test class. - * - * @package core - * @category test - * @copyright 2012 Sam Hemelryk - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ -class csslib_test extends \advanced_testcase { - - /** - * Test that css_is_colour function throws an exception. - */ - public function test_css_is_colour(): void { - $this->expectException('coding_exception'); - $this->expectExceptionMessage('css_is_colour() can not be used anymore.'); - css_is_colour(); - } - - /** - * Test that css_is_width function throws an exception. - */ - public function test_css_is_width(): void { - $this->expectException('coding_exception'); - $this->expectExceptionMessage('css_is_width() can not be used anymore.'); - css_is_width(); - } -} diff --git a/lib/tests/event/base_test.php b/lib/tests/event/base_test.php index 6b47fe16fcc..088ae9eca2e 100644 --- a/lib/tests/event/base_test.php +++ b/lib/tests/event/base_test.php @@ -573,56 +573,6 @@ class base_test extends \advanced_testcase { $this->assertSame($event::LEVEL_TEACHING, $event->edulevel); } - public function test_legacy(): void { - global $DB, $CFG; - - $this->resetAfterTest(true); - - $observers = array( - array( - 'eventname' => '\core_tests\event\unittest_executed', - 'callback' => '\core_tests\event\unittest_observer::observe_one', - ), - array( - 'eventname' => '*', - 'callback' => '\core_tests\event\unittest_observer::observe_all', - 'includefile' => null, - 'internal' => 1, - 'priority' => 9999, - ), - ); - - $DB->delete_records('log', array()); - $this->expectException(\coding_exception::class); - events_update_definition('unittest'); - - $DB->delete_records_select('events_handlers', "component <> 'unittest'"); - - $this->assertDebuggingCalled(self::DEBUGGING_MSG, DEBUG_DEVELOPER); - $this->assertEquals(3, $DB->count_records('events_handlers')); - set_config('loglifetime', 60*60*24*5); - - \core\event\manager::phpunit_replace_observers($observers); - \core_tests\event\unittest_observer::reset(); - - $event1 = \core_tests\event\unittest_executed::create(array('context'=>\context_system::instance(), 'other'=>array('sample'=>5, 'xx'=>10))); - $event1->trigger(); - - $event2 = \core_tests\event\unittest_executed::create(array('context'=>\context_system::instance(), 'other'=>array('sample'=>6, 'xx'=>11))); - $event2->nest = true; - $event2->trigger(); - - $this->assertSame( - array('observe_all-5', 'observe_one-5', 'observe_all-nesting-6', 'observe_one-6', 'observe_all-666', 'observe_one-666'), - \core_tests\event\unittest_observer::$info); - - $this->assertSame($event1, \core_tests\event\unittest_observer::$event[0]); - $this->assertSame($event1, \core_tests\event\unittest_observer::$event[1]); - - $logs = $DB->get_records('log', array(), 'id ASC'); - $this->assertCount(0, $logs); - } - public function test_restore_event(): void { $event1 = \core_tests\event\unittest_executed::create(array('context'=>\context_system::instance(), 'other'=>array('sample'=>1, 'xx'=>10))); $data1 = $event1->get_data(); diff --git a/message/tests/messagelib_test.php b/message/tests/messagelib_test.php index 15103d9087a..18f963225fa 100644 --- a/message/tests/messagelib_test.php +++ b/message/tests/messagelib_test.php @@ -115,26 +115,6 @@ class messagelib_test extends \advanced_testcase { return $DB->insert_record('messages', $record); } - /** - * Test message_get_blocked_users throws an exception because has been removed. - */ - public function test_message_get_blocked_users(): void { - $this->expectException('coding_exception'); - $this->expectExceptionMessage( - 'message_get_blocked_users() has been removed, please use \core_message\api::get_blocked_users() instead.' - ); - message_get_blocked_users(); - } - - /** - * Test message_get_contacts throws an exception because has been removed. - */ - public function test_message_get_contacts(): void { - $this->expectException('coding_exception'); - $this->expectExceptionMessage('message_get_contacts() has been removed.'); - message_get_contacts(); - } - /** * Test message_search_users. */ diff --git a/tag/tests/taglib_test.php b/tag/tests/taglib_test.php index 1f9efba5133..275952ed4b4 100644 --- a/tag/tests/taglib_test.php +++ b/tag/tests/taglib_test.php @@ -40,39 +40,6 @@ class taglib_test extends \advanced_testcase { $this->resetAfterTest(); } - /** - * Test that the tag_set function throws an exception. - * This function was deprecated in 3.1 - */ - public function test_tag_set_get(): void { - $this->expectException('coding_exception'); - $this->expectExceptionMessage('tag_set() can not be used anymore. Please use ' . - 'core_tag_tag::set_item_tags().'); - tag_set(); - } - - /** - * Test that tag_set_add function throws an exception. - * This function was deprecated in 3.1 - */ - public function test_tag_set_add(): void { - $this->expectException('coding_exception'); - $this->expectExceptionMessage('tag_set_add() can not be used anymore. Please use ' . - 'core_tag_tag::add_item_tag().'); - tag_set_add(); - } - - /** - * Test that tag_set_delete function returns an exception. - * This function was deprecated in 3.1 - */ - public function test_tag_set_delete(): void { - $this->expectException('coding_exception'); - $this->expectExceptionMessage('tag_set_delete() can not be used anymore. Please use ' . - 'core_tag_tag::remove_item_tag().'); - tag_set_delete(); - } - /** * Test the core_tag_tag::add_item_tag() and core_tag_tag::remove_item_tag() functions. */ @@ -143,17 +110,6 @@ class taglib_test extends \advanced_testcase { $this->assertEquals(1, $DB->get_field('tag_instance', 'ordering', ['id' => $ti5])); } - /** - * Test that tag_assign function throws an exception. - * This function was deprecated in 3.1 - */ - public function test_tag_assign(): void { - $this->expectException(\coding_exception::class); - $this->expectExceptionMessage('tag_assign() can not be used anymore. Please use core_tag_tag::set_item_tags() ' . - 'or core_tag_tag::add_item_tag() instead.'); - tag_assign(); - } - /** * Test the tag cleanup function used by the cron. */ @@ -834,17 +790,6 @@ class taglib_test extends \advanced_testcase { $this->assertEquals($collid2, $user2tags[2]->tagcollid); } - /** - * Tests that tag_normalize function throws an exception. - * This function was deprecated in 3.1 - */ - public function test_normalize(): void { - $this->expectException(\coding_exception::class); - $this->expectExceptionMessage('tag_normalize() can not be used anymore. Please use ' . - 'core_tag_tag::normalize().'); - tag_normalize(); - } - /** * Test functions core_tag_tag::create_if_missing() and core_tag_tag::get_by_name_bulk(). */