diff --git a/lib/classes/plugininfo/base.php b/lib/classes/plugininfo/base.php index b7ce65ff9bf..910c5b2959c 100644 --- a/lib/classes/plugininfo/base.php +++ b/lib/classes/plugininfo/base.php @@ -77,6 +77,12 @@ abstract class base { /** @var int Move a plugin down in the plugin order */ public const MOVE_DOWN = 1; + /** @var array hold $plugin->supported in version.php */ + public $supported; + + /** @var int hold $plugin->incompatible in version.php */ + public $incompatible; + /** * Whether this plugintype supports its plugins being disabled. * diff --git a/lib/tests/behat/behat_accessibility.php b/lib/tests/behat/behat_accessibility.php index 022a7aed7f1..454cf790982 100644 --- a/lib/tests/behat/behat_accessibility.php +++ b/lib/tests/behat/behat_accessibility.php @@ -142,7 +142,7 @@ EOF; } if ($results->exception !== null) { - throw new ExpectationException($results->exception, $this->session); + throw new ExpectationException($results->exception, $this->getSession()); } $violations = $results->violations; diff --git a/lib/tests/component_test.php b/lib/tests/component_test.php index 9463ca885d7..bdf3638973a 100644 --- a/lib/tests/component_test.php +++ b/lib/tests/component_test.php @@ -23,6 +23,7 @@ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * * @covers \core_component + * @runTestsInSeparateProcesses */ class component_test extends advanced_testcase { @@ -33,25 +34,6 @@ class component_test extends advanced_testcase { */ const SUBSYSTEMCOUNT = 77; - public function setUp(): void { - $psr0namespaces = new ReflectionProperty('core_component', 'psr0namespaces'); - $psr0namespaces->setAccessible(true); - $this->oldpsr0namespaces = $psr0namespaces->getValue(null); - - $psr4namespaces = new ReflectionProperty('core_component', 'psr4namespaces'); - $psr4namespaces->setAccessible(true); - $this->oldpsr4namespaces = $psr4namespaces->getValue(null); - } - public function tearDown(): void { - $psr0namespaces = new ReflectionProperty('core_component', 'psr0namespaces'); - $psr0namespaces->setAccessible(true); - $psr0namespaces->setValue(null, $this->oldpsr0namespaces); - - $psr4namespaces = new ReflectionProperty('core_component', 'psr4namespaces'); - $psr4namespaces->setAccessible(true); - $psr4namespaces->setValue(null, $this->oldpsr4namespaces); - } - public function test_get_core_subsystems() { global $CFG; diff --git a/lib/tests/fixtures/test_renderer_factory.php b/lib/tests/fixtures/test_renderer_factory.php index a3a1079ee8d..4d32622c496 100644 --- a/lib/tests/fixtures/test_renderer_factory.php +++ b/lib/tests/fixtures/test_renderer_factory.php @@ -43,7 +43,7 @@ class test_output_factory extends renderer_factory_base { * */ public function __construct() { - $this->prefixes = array('theme_child', 'theme_parent'); + // Leave the construct empty to override the parent. } /** @@ -93,6 +93,7 @@ class test_output_factory extends renderer_factory_base { * @return string[] of classnames */ public function get_theme_overridden_renderer_factory_search_paths($component, $subtype = null, $target = null) { + $themeprefixes = ['theme_child', 'theme_parent']; $searchtargets = array(); $classnames = $this->standard_renderer_classnames($component, $subtype); @@ -102,7 +103,7 @@ class test_output_factory extends renderer_factory_base { // when loading the theme configs. // First try the renderers with correct suffix. - foreach ($this->prefixes as $prefix) { + foreach ($themeprefixes as $prefix) { foreach ($classnames as $classnamedetails) { if ($classnamedetails['validwithprefix']) { if ($classnamedetails['autoloaded']) { @@ -122,7 +123,7 @@ class test_output_factory extends renderer_factory_base { } // Then try general renderer. - foreach ($this->prefixes as $prefix) { + foreach ($themeprefixes as $prefix) { foreach ($classnames as $classnamedetails) { if ($classnamedetails['validwithprefix']) { if ($classnamedetails['autoloaded']) { diff --git a/lib/tests/myprofilelib_test.php b/lib/tests/myprofilelib_test.php index 04a96be0609..a444ef28da2 100644 --- a/lib/tests/myprofilelib_test.php +++ b/lib/tests/myprofilelib_test.php @@ -44,14 +44,12 @@ class myprofilelib_test extends \advanced_testcase { * @var \core_user\output\myprofile\tree The navigation tree. */ private $tree; - public function setUp(): void { // Set the $PAGE->url value so core_myprofile_navigation() doesn't complain. global $PAGE; $PAGE->set_url('/test'); $this->user = $this->getDataGenerator()->create_user(); - $this->user2 = $this->getDataGenerator()->create_user(); $this->course = $this->getDataGenerator()->create_course(); $this->tree = new \core_user\output\myprofile\tree(); $this->resetAfterTest(); @@ -87,7 +85,8 @@ class myprofilelib_test extends \advanced_testcase { * profile of another another user. */ public function test_core_myprofile_navigation_course_without_permission() { - $this->setUser($this->user2); + // User without permission. + $this->setUser($this->getDataGenerator()->create_user()); $iscurrentuser = false; core_myprofile_navigation($this->tree, $this->user, $iscurrentuser, $this->course); @@ -146,7 +145,7 @@ class myprofilelib_test extends \advanced_testcase { */ public function test_core_myprofile_navigation_preference_without_permission() { // Login as link for a user who doesn't have the capability to login as. - $this->setUser($this->user2); + $this->setUser($this->getDataGenerator()->create_user()); $iscurrentuser = false; core_myprofile_navigation($this->tree, $this->user, $iscurrentuser, $this->course); @@ -211,7 +210,7 @@ class myprofilelib_test extends \advanced_testcase { $identityfields = explode(',', $CFG->showuseridentity); // User without permission. - $this->setUser($this->user2); + $this->setUser($this->getDataGenerator()->create_user()); core_myprofile_navigation($this->tree, $this->user, $iscurrentuser, null); $reflector = new \ReflectionObject($this->tree); $nodes = $reflector->getProperty('nodes'); @@ -300,7 +299,7 @@ class myprofilelib_test extends \advanced_testcase { public function test_core_myprofile_navigationn_login_activity_without_permission() { // User without permission. set_config("hiddenuserfields", "firstaccess,lastaccess,lastip"); - $this->setUser($this->user2); + $this->setUser($this->getDataGenerator()->create_user()); $iscurrentuser = false; core_myprofile_navigation($this->tree, $this->user, $iscurrentuser, null); diff --git a/lib/tests/navigationlib_test.php b/lib/tests/navigationlib_test.php index 3b75dabddf8..ed875a7a8e1 100644 --- a/lib/tests/navigationlib_test.php +++ b/lib/tests/navigationlib_test.php @@ -711,7 +711,6 @@ class exposed_global_navigation extends global_navigation { $page = $PAGE; } parent::__construct($page); - $this->cache = new navigation_cache('unittest_nav'); } public function __call($method, $arguments) { if (strpos($method, $this->exposedkey) !== false) { @@ -763,9 +762,9 @@ class mock_initialise_global_navigation extends global_navigation { */ class exposed_navbar extends navbar { protected $exposedkey = 'exposed_'; + public function __construct(\moodle_page $page) { parent::__construct($page); - $this->cache = new navigation_cache('unittest_nav'); } public function __call($method, $arguments) { if (strpos($method, $this->exposedkey) !== false) { @@ -793,7 +792,6 @@ class exposed_settings_navigation extends settings_navigation { public function __construct() { global $PAGE; parent::__construct($PAGE); - $this->cache = new navigation_cache('unittest_nav'); } public function __call($method, $arguments) { if (strpos($method, $this->exposedkey) !== false) { diff --git a/lib/tests/persistent_test.php b/lib/tests/persistent_test.php index 8d03320569e..78f5b52a4b9 100644 --- a/lib/tests/persistent_test.php +++ b/lib/tests/persistent_test.php @@ -700,6 +700,27 @@ class core_testable_persistent extends persistent { const TABLE = 'phpunit_persistent'; + /** @var bool before validate status. */ + public ?bool $beforevalidate; + + /** @var bool before create status. */ + public ?bool $beforecreate; + + /** @var bool before update status. */ + public ?bool $beforeupdate; + + /** @var bool before delete status. */ + public ?bool $beforedelete; + + /** @var bool after create status. */ + public ?bool $aftercreate; + + /** @var bool after update status. */ + public ?bool $afterupdate; + + /** @var bool after delete status. */ + public ?bool $afterdelete; + protected static function define_properties() { return array( 'shortname' => array(