MDL-81456 core: Use DI for all hook access
Using DI for all hook access means that it becomes significantly easier to mock hooks and callbacks for unit testing without fundamentally altering the structure of the code purely for the purposes of unit testing.
This commit is contained in:
@@ -23,6 +23,11 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
use core\{
|
||||
di,
|
||||
hook,
|
||||
};
|
||||
|
||||
require_once(__DIR__.'/../../testing/classes/util.php');
|
||||
require_once(__DIR__ . "/coverage_info.php");
|
||||
|
||||
@@ -105,7 +110,7 @@ class phpunit_util extends testing_util {
|
||||
global $DB, $CFG, $USER, $SITE, $COURSE, $PAGE, $OUTPUT, $SESSION, $FULLME, $FILTERLIB_PRIVATE;
|
||||
|
||||
// Stop all hook redirections.
|
||||
\core\hook\manager::get_instance()->phpunit_stop_redirections();
|
||||
di::get(hook\manager::class)->phpunit_stop_redirections();
|
||||
|
||||
// Reset the hook manager instance.
|
||||
\core\hook\manager::phpunit_reset_instance();
|
||||
|
||||
Reference in New Issue
Block a user