Skip to content

Commit

Permalink
Merge branch 'MDL-78167-402' of https://github.com/meirzamoodle/moodle
Browse files Browse the repository at this point in the history
…into MOODLE_402_STABLE
  • Loading branch information
snake committed Jun 12, 2023
2 parents c6d04cb + 0e7a731 commit cd7b952
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 32 deletions.
6 changes: 6 additions & 0 deletions lib/classes/plugininfo/base.php
Expand Up @@ -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.
*
Expand Down
2 changes: 1 addition & 1 deletion lib/tests/behat/behat_accessibility.php
Expand Up @@ -142,7 +142,7 @@ protected function run_axe_for_tags(array $standardtags = [], array $extratags =
}

if ($results->exception !== null) {
throw new ExpectationException($results->exception, $this->session);
throw new ExpectationException($results->exception, $this->getSession());
}

$violations = $results->violations;
Expand Down
20 changes: 1 addition & 19 deletions lib/tests/component_test.php
Expand Up @@ -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 {

Expand All @@ -33,25 +34,6 @@ class component_test extends advanced_testcase {
*/
const SUBSYSTEMCOUNT = 76;

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;

Expand Down
7 changes: 4 additions & 3 deletions lib/tests/fixtures/test_renderer_factory.php
Expand Up @@ -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.
}

/**
Expand Down Expand Up @@ -93,6 +93,7 @@ public function get_standard_renderer_factory_search_paths($component, $subtype
* @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);

Expand All @@ -102,7 +103,7 @@ public function get_theme_overridden_renderer_factory_search_paths($component, $
// 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']) {
Expand All @@ -122,7 +123,7 @@ public function get_theme_overridden_renderer_factory_search_paths($component, $
}

// Then try general renderer.
foreach ($this->prefixes as $prefix) {
foreach ($themeprefixes as $prefix) {
foreach ($classnames as $classnamedetails) {
if ($classnamedetails['validwithprefix']) {
if ($classnamedetails['autoloaded']) {
Expand Down
11 changes: 5 additions & 6 deletions lib/tests/myprofilelib_test.php
Expand Up @@ -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();
Expand Down Expand Up @@ -87,7 +85,8 @@ public function test_core_myprofile_navigation_as_admin() {
* 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);
Expand Down Expand Up @@ -146,7 +145,7 @@ public function test_core_myprofile_navigation_preference_as_admin() {
*/
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);
Expand Down Expand Up @@ -211,7 +210,7 @@ public function test_core_myprofile_navigation_contact_field_without_permission(
$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');
Expand Down Expand Up @@ -300,7 +299,7 @@ public function test_core_myprofile_navigation_login_activity() {
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);
Expand Down
4 changes: 1 addition & 3 deletions lib/tests/navigationlib_test.php
Expand Up @@ -711,7 +711,6 @@ public function __construct(\moodle_page $page=null) {
$page = $PAGE;
}
parent::__construct($page);
$this->cache = new navigation_cache('unittest_nav');
}
public function __call($method, $arguments) {
if (strpos($method, $this->exposedkey) !== false) {
Expand Down Expand Up @@ -763,9 +762,9 @@ public function load_for_user($user=null, $forceforcontext=false) {
*/
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) {
Expand Down Expand Up @@ -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) {
Expand Down
21 changes: 21 additions & 0 deletions lib/tests/persistent_test.php
Expand Up @@ -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(
Expand Down

0 comments on commit cd7b952

Please sign in to comment.