MDL-83424 core: Fix failing unit test

This commit is contained in:
Andrew Nicols
2025-07-12 17:51:40 +08:00
parent 0e961688e7
commit efe3582d4a
16 changed files with 41 additions and 41 deletions
+1 -2
View File
@@ -273,7 +273,7 @@ if (empty($parallelrun)) {
}
// Execute all commands, relative to moodle root directory.
$processes = cli_execute_parallel($cmds, __DIR__ . "/../../../../", BEHAT_PARALLEL_START_DELAY);
$processes = cli_execute_parallel($cmds, __DIR__ . "/../../../../../", BEHAT_PARALLEL_START_DELAY);
$stoponfail = empty($options['stop-on-failure']) ? false : true;
// Print header.
@@ -525,4 +525,3 @@ function get_status_lines_from_run_op(Symfony\Component\Process\Process $process
return $statusstr;
}
@@ -51,13 +51,13 @@ blackfriday:
relativeURLs: true
publishDir: "./admin/tool/componentlibrary/docs"
archetypeDir: "./admin/tool/componentlibrary/hugo/archetypes"
assetDir: "./admin/tool/componentlibrary/hugo/assets"
contentDir: "./admin/tool/componentlibrary/content"
dataDir: "./admin/tool/componentlibrary/hugo/site/data"
layoutDir: "./admin/tool/componentlibrary/hugo/site/layouts"
staticDir: "./admin/tool/componentlibrary/content/static"
publishDir: "./public/admin/tool/componentlibrary/docs"
archetypeDir: "./public/admin/tool/componentlibrary/hugo/archetypes"
assetDir: "./public/admin/tool/componentlibrary/hugo/assets"
contentDir: "./public/admin/tool/componentlibrary/content"
dataDir: "./public/admin/tool/componentlibrary/hugo/site/data"
layoutDir: "./public/admin/tool/componentlibrary/hugo/site/layouts"
staticDir: "./public/admin/tool/componentlibrary/content/static"
params:
moodleroot: "MOODLEROOT"
@@ -118,15 +118,15 @@ Cards usually don't really look great without images. That's why we show a place
{{< example show_markup="false">}}
<div class="card-deck">
{{< root.inline >}}
{{- $pl1 := readFile "admin/tool/componentlibrary/content/static/moodle/components/coursecards/placeholder-1.txt" -}}
{{- $pl2 := readFile "admin/tool/componentlibrary/content/static/moodle/components/coursecards/placeholder-2.txt" -}}
{{- $pl3 := readFile "admin/tool/componentlibrary/content/static/moodle/components/coursecards/placeholder-3.txt" -}}
{{- $pl4 := readFile "admin/tool/componentlibrary/content/static/moodle/components/coursecards/placeholder-4.txt" -}}
{{- $pl5 := readFile "admin/tool/componentlibrary/content/static/moodle/components/coursecards/placeholder-5.txt" -}}
{{- $pl6 := readFile "admin/tool/componentlibrary/content/static/moodle/components/coursecards/placeholder-6.txt" -}}
{{- $pl7 := readFile "admin/tool/componentlibrary/content/static/moodle/components/coursecards/placeholder-7.txt" -}}
{{- $pl8 := readFile "admin/tool/componentlibrary/content/static/moodle/components/coursecards/placeholder-8.txt" -}}
{{- $pl9 := readFile "admin/tool/componentlibrary/content/static/moodle/components/coursecards/placeholder-9.txt" -}}
{{- $pl1 := readFile "public/admin/tool/componentlibrary/content/static/moodle/components/coursecards/placeholder-1.txt" -}}
{{- $pl2 := readFile "public/admin/tool/componentlibrary/content/static/moodle/components/coursecards/placeholder-2.txt" -}}
{{- $pl3 := readFile "public/admin/tool/componentlibrary/content/static/moodle/components/coursecards/placeholder-3.txt" -}}
{{- $pl4 := readFile "public/admin/tool/componentlibrary/content/static/moodle/components/coursecards/placeholder-4.txt" -}}
{{- $pl5 := readFile "public/admin/tool/componentlibrary/content/static/moodle/components/coursecards/placeholder-5.txt" -}}
{{- $pl6 := readFile "public/admin/tool/componentlibrary/content/static/moodle/components/coursecards/placeholder-6.txt" -}}
{{- $pl7 := readFile "public/admin/tool/componentlibrary/content/static/moodle/components/coursecards/placeholder-7.txt" -}}
{{- $pl8 := readFile "public/admin/tool/componentlibrary/content/static/moodle/components/coursecards/placeholder-8.txt" -}}
{{- $pl9 := readFile "public/admin/tool/componentlibrary/content/static/moodle/components/coursecards/placeholder-9.txt" -}}
<div class="card mb-2 justify-content-center align-items-center d-flex text-center" style="flex: 0 0 20%; height: 150px; background-image: url('{{- $pl1 -}}')">
</div>
+1 -1
View File
@@ -118,7 +118,7 @@ Options:
-h, --help Print out this help
Example:
\$ php ".testing_cli_argument_path('/admin/tool/phpunit/cli/util.php')." --install
\$ php ".testing_cli_argument_path('/public/admin/tool/phpunit/cli/util.php')." --install
";
echo $help;
exit(0);
@@ -111,7 +111,7 @@ final class course_delete_modules_test extends \advanced_testcase {
$this->assertStringContainsString('course/lib.php', $errormsg);
$this->assertStringContainsString('mod/TestModuleToDelete/lib.php is missing', $errormsg);
// Get line numbers array which contains the exception name.
$lines = array_keys(preg_grep("/cannotdeletemodulemissinglib/", file('course/lib.php')));
$lines = array_keys(preg_grep("/cannotdeletemodulemissinglib/", file(dirname(__DIR__) . '/lib.php')));
// Increase 1 to keys to convert to actual line number.
$lines = array_map(function($key) {
return ++$key;
@@ -135,6 +135,7 @@ class behat_command {
$command = 'php ' . $pathprefix . 'admin' . $separator . 'tool' . $separator . 'behat' . $separator . 'cli'
. $separator . 'run.php';
}
return $command;
}
+4 -4
View File
@@ -66,11 +66,11 @@ function behat_error($errorcode, $text = '') {
$text = 'Behat permissions problem: ' . $text . ', check the permissions';
break;
case BEHAT_EXITCODE_REINSTALL:
$path = testing_cli_argument_path('/admin/tool/behat/cli/init.php');
$path = testing_cli_argument_path('/public/admin/tool/behat/cli/init.php');
$text = "Reinstall Behat: ".$text.", use:\n php ".$path;
break;
case BEHAT_EXITCODE_INSTALL:
$path = testing_cli_argument_path('/admin/tool/behat/cli/init.php');
$path = testing_cli_argument_path('/public/admin/tool/behat/cli/init.php');
$text = "Install Behat before enabling it, use:\n php ".$path;
break;
case BEHAT_EXITCODE_INSTALLED:
@@ -214,7 +214,7 @@ function behat_clean_init_config() {
global $CFG;
$allowed = array_flip(array(
'wwwroot', 'dataroot', 'dirroot', 'admin', 'directorypermissions', 'filepermissions',
'wwwroot', 'dataroot', 'root', 'dirroot', 'admin', 'directorypermissions', 'filepermissions',
'umaskpermissions', 'dbtype', 'dblibrary', 'dbhost', 'dbname', 'dbuser', 'dbpass', 'prefix',
'dboptions', 'proxyhost', 'proxyport', 'proxytype', 'proxyuser', 'proxypassword',
'proxybypass', 'pathtogs', 'pathtophp', 'pathtodu', 'aspellpath', 'pathtodot', 'skiplangupgrade',
@@ -530,7 +530,7 @@ function behat_get_run_process() {
* @return array list of processes.
*/
function cli_execute_parallel($cmds, $cwd = null, $delay = 0) {
require_once(__DIR__ . "/../../vendor/autoload.php");
require_once(__DIR__ . "/../../../vendor/autoload.php");
$processes = array();
+2 -2
View File
@@ -483,7 +483,7 @@ final class external_api_test extends \advanced_testcase {
// which is necessary to test things like class autoloading.
$this->add_full_mocked_plugintype(
plugintype: 'fake',
path: 'lib/tests/fixtures/fakeplugins/fake',
path: 'public/lib/tests/fixtures/fakeplugins/fake',
);
$this->deprecate_full_mocked_plugintype('fake');
external_update_descriptions('fake_fullfeatured');
@@ -515,7 +515,7 @@ final class external_api_test extends \advanced_testcase {
// which is necessary to test things like class autoloading.
$this->add_full_mocked_plugintype(
plugintype: 'fake',
path: 'lib/tests/fixtures/fakeplugins/fake',
path: 'public/lib/tests/fixtures/fakeplugins/fake',
);
$this->delete_full_mocked_plugintype('fake');
external_update_descriptions('fake_fullfeatured');
+2 -2
View File
@@ -65,11 +65,11 @@ function phpunit_bootstrap_error($errorcode, $text = '') {
$text = "Moodle PHPUnit environment configuration warning:\n".$text;
break;
case PHPUNIT_EXITCODE_INSTALL:
$path = testing_cli_argument_path('/admin/tool/phpunit/cli/init.php');
$path = testing_cli_argument_path('/public/admin/tool/phpunit/cli/init.php');
$text = "Moodle PHPUnit environment is not initialised, please use:\n php $path";
break;
case PHPUNIT_EXITCODE_REINSTALL:
$path = testing_cli_argument_path('/admin/tool/phpunit/cli/init.php');
$path = testing_cli_argument_path('/public/admin/tool/phpunit/cli/init.php');
$text = "Moodle PHPUnit environment was initialised for different version, please use:\n php $path";
break;
default:
+1 -1
View File
@@ -79,7 +79,7 @@ function get_whoops(): ?\Whoops\Run {
return null;
}
$composerautoload = "{$CFG->dirroot}/vendor/autoload.php";
$composerautoload = "{$CFG->dirroot}/../vendor/autoload.php";
if (file_exists($composerautoload)) {
require_once($composerautoload);
}
+1 -1
View File
@@ -58,7 +58,7 @@ function testing_cli_argument_path($moodlepath) {
$cwd = substr($cwd, -1);
}
$path = realpath($CFG->dirroot.$moodlepath);
$path = realpath(dirname($CFG->dirroot).$moodlepath);
// We need standrad directory seperator for path and cwd, so it can be compared.
$cwd = testing_cli_fix_directory_separator($cwd);
+1 -1
View File
@@ -44,7 +44,7 @@ final class manager_test extends \advanced_testcase {
// This 'fake_fullfeatured' plugin is an available plugin at this stage (not yet deprecated).
$this->add_full_mocked_plugintype(
plugintype: 'fake',
path: 'lib/tests/fixtures/fakeplugins/fake',
path: 'public/lib/tests/fixtures/fakeplugins/fake',
);
$observers = array_filter(
+1 -1
View File
@@ -498,7 +498,7 @@ final class manager_test extends \advanced_testcase {
// This 'fake_fullfeatured' plugin is an available plugin at this stage (not yet deprecated).
$this->add_full_mocked_plugintype(
plugintype: 'fake',
path: 'lib/tests/fixtures/fakeplugins/fake',
path: 'public/lib/tests/fixtures/fakeplugins/fake',
);
// Force reset the static instance cache \core\hook\manager::$instance so that a fresh instance is instantiated, ensuring
+2 -2
View File
@@ -5740,7 +5740,7 @@ EOT;
// which is necessary to test things like class autoloading, required for class callbacks checks.
$this->add_full_mocked_plugintype(
plugintype: 'fake',
path: 'lib/tests/fixtures/fakeplugins/fake',
path: 'public/lib/tests/fixtures/fakeplugins/fake',
);
$this->deprecate_full_mocked_plugintype('fake');
@@ -5783,7 +5783,7 @@ EOT;
// which is necessary to test things like class autoloading, required for class callbacks checks.
$this->add_full_mocked_plugintype(
plugintype: 'fake',
path: 'lib/tests/fixtures/fakeplugins/fake',
path: 'public/lib/tests/fixtures/fakeplugins/fake',
);
$this->delete_full_mocked_plugintype('fake');
+4 -4
View File
@@ -804,7 +804,7 @@ final class plugin_manager_test extends \advanced_testcase {
// Inject the mock plugin 'fake_fullfeatured' and deprecate it.
$this->add_full_mocked_plugintype(
plugintype: 'fake',
path: 'lib/tests/fixtures/fakeplugins/fake',
path: 'public/lib/tests/fixtures/fakeplugins/fake',
);
$this->deprecate_full_mocked_plugintype('fake');
@@ -867,7 +867,7 @@ final class plugin_manager_test extends \advanced_testcase {
// 3. fulldeletedsubtype_demo: a deleted subplugin type.
$this->add_full_mocked_plugintype(
plugintype: 'fake',
path: 'lib/tests/fixtures/fakeplugins/fake',
path: 'public/lib/tests/fixtures/fakeplugins/fake',
subpluginsupport: true
);
@@ -934,7 +934,7 @@ final class plugin_manager_test extends \advanced_testcase {
// Inject the mock plugin 'fake_fullfeatured', and deprecate it.
$this->add_full_mocked_plugintype(
plugintype: 'fake',
path: 'lib/tests/fixtures/fakeplugins/fake',
path: 'public/lib/tests/fixtures/fakeplugins/fake',
);
$this->delete_full_mocked_plugintype('fake');
@@ -999,7 +999,7 @@ final class plugin_manager_test extends \advanced_testcase {
// 3. fulldeletedsubtype_demo: a deleted subplugin type.
$this->add_full_mocked_plugintype(
plugintype: 'fake',
path: 'lib/tests/fixtures/fakeplugins/fake',
path: 'public/lib/tests/fixtures/fakeplugins/fake',
subpluginsupport: true
);
@@ -151,9 +151,9 @@ final class entries_export_test extends \advanced_testcase {
// file stored in a file and picture field.
// So we expect that this file has to have the same content as sample.png.
// Also, the default value for the subdirectory in the zip archive containing the files is 'files/'.
'files/samplefile.png' => 'mod/data/field/picture/pix/sample.png',
'files/samplefile_1.png' => 'mod/data/field/picture/pix/sample.png',
'files/picturefile.png' => 'mod/data/field/picture/pix/sample.png',
'files/samplefile.png' => 'public/mod/data/field/picture/pix/sample.png',
'files/samplefile_1.png' => 'public/mod/data/field/picture/pix/sample.png',
'files/picturefile.png' => 'public/mod/data/field/picture/pix/sample.png',
// By checking that the content of the exported csv is identical to the fixture file it is verified
// that the filenames in the csv file correspond to the names of the exported file.
// It also verifies that files with identical file names in different fields (or records) will be numbered