mirror of
https://github.com/moodle/moodle.git
synced 2025-04-21 08:22:07 +02:00
Merge branch 'MDL-83811-main' of https://github.com/junpataleta/moodle
This commit is contained in:
commit
3db0bb1436
2
.github/workflows/windows.yml
vendored
2
.github/workflows/windows.yml
vendored
@ -128,7 +128,7 @@ jobs:
|
||||
|
||||
- name: Setting up redis service
|
||||
run: |
|
||||
choco install redis-64 --version 3.0.503 --no-progress
|
||||
choco install redis --version 5.0.7 --no-progress
|
||||
nssm install redis redis-server
|
||||
nssm start redis
|
||||
|
||||
|
@ -158,19 +158,18 @@ final class dml_mysqli_read_replica_test extends \database_driver_testcase {
|
||||
$this->resetDebugging();
|
||||
$db2 = \moodle_database::get_driver_instance($cfg->dbtype, $cfg->dblibrary);
|
||||
$db2->connect($cfg->dbhost, $cfg->dbuser, $cfg->dbpass, $cfg->dbname, $cfg->prefix, $cfg->dboptions);
|
||||
$this->assertTrue(count($db2->get_records('user')) > 0);
|
||||
$this->assertNotEmpty($db2->get_records('user'));
|
||||
|
||||
$debugging = array_map(function ($d) {
|
||||
return $d->message;
|
||||
}, $this->getDebuggingMessages());
|
||||
$this->resetDebugging();
|
||||
$this->assertEquals(2, count($debugging));
|
||||
$this->assertCount(2, $debugging);
|
||||
$this->assertMatchesRegularExpression(
|
||||
sprintf(
|
||||
'/%s%s/',
|
||||
preg_quote("Readonly db connection failed for host {$invalidhost}:"),
|
||||
'.* Name or service not known',
|
||||
$cfg->dbname
|
||||
'.*'
|
||||
),
|
||||
$debugging[0]
|
||||
);
|
||||
@ -214,22 +213,23 @@ final class dml_mysqli_read_replica_test extends \database_driver_testcase {
|
||||
return $d->message;
|
||||
}, $this->getDebuggingMessages());
|
||||
$this->resetDebugging();
|
||||
$this->assertEquals(2, count($debugging));
|
||||
$this->assertCount(2, $debugging);
|
||||
// Read-only attempt to connect to the non-existent replica database will fail.
|
||||
// Note: The expected regex pattern is a bit generic because the actual error message may vary between operating systems.
|
||||
$this->assertMatchesRegularExpression(
|
||||
sprintf(
|
||||
'/%s%s/',
|
||||
preg_quote("Readonly db connection failed for host {$cfg->dbhost}: "),
|
||||
"Access denied for user .* to database '$invaliddb'",
|
||||
$cfg->dbname
|
||||
".* database '$invaliddb'"
|
||||
),
|
||||
$debugging[0]
|
||||
);
|
||||
// Read-write attempt to connect to the non-existent replica database will also fail.
|
||||
$this->assertMatchesRegularExpression(
|
||||
sprintf(
|
||||
'/%s%s/',
|
||||
preg_quote("Readwrite db connection failed for host {$cfg->dbhost}: "),
|
||||
'Access denied for user .* '.preg_quote("to database '$invaliddb'"),
|
||||
$cfg->dbname
|
||||
".* '$invaliddb"
|
||||
),
|
||||
$debugging[1]
|
||||
);
|
||||
|
@ -282,22 +282,24 @@ class dml_pgsql_read_replica_test extends \advanced_testcase {
|
||||
$this->resetDebugging();
|
||||
$db2 = moodle_database::get_driver_instance($cfg->dbtype, $cfg->dblibrary);
|
||||
$db2->connect($cfg->dbhost, $cfg->dbuser, $cfg->dbpass, $cfg->dbname, $cfg->prefix, $cfg->dboptions);
|
||||
$this->assertTrue(count($db2->get_records('user')) > 0);
|
||||
$this->assertNotEmpty($db2->get_records('user'));
|
||||
|
||||
$debugging = array_map(function ($d) {
|
||||
return $d->message;
|
||||
}, $this->getDebuggingMessages());
|
||||
$this->resetDebugging();
|
||||
$this->assertEquals(2, count($debugging));
|
||||
$this->assertCount(2, $debugging);
|
||||
// Attempt to connect to the non-existent replica host will fail.
|
||||
// Note: The expected regex pattern is a bit generic because the actual error message may vary between operating systems.
|
||||
$this->assertMatchesRegularExpression(
|
||||
sprintf(
|
||||
'/%s%s/',
|
||||
preg_quote("Readonly db connection failed for host {$invalidhost}: "),
|
||||
'.* Name or service not known',
|
||||
$cfg->dbname
|
||||
'.*'
|
||||
),
|
||||
$debugging[0]
|
||||
);
|
||||
// Attempt to connect to the existing DB host will succeed.
|
||||
$this->assertEquals("Readwrite db connection succeeded for host {$cfg->dbhost}", $debugging[1]);
|
||||
}
|
||||
}
|
||||
|
@ -1349,10 +1349,10 @@ final class component_test extends \advanced_testcase {
|
||||
|
||||
foreach ($paths as $path) {
|
||||
// The composer.json can specify any arbitrary directory within the folder.
|
||||
// It always contains a leading slash (/).
|
||||
// It always contains a leading slash (/) or backslash (\) on Windows.
|
||||
// It may also have an optional trailing slash (/).
|
||||
// Concatenate the parts and removes the slashes.
|
||||
$relativenamespacepath = trim("{$relativepath}/{$path}", '/');
|
||||
$relativenamespacepath = trim("{$relativepath}/{$path}", '/\\');
|
||||
|
||||
// The Moodle PSR-4 autoloader data has two formats:
|
||||
// - a string, for a single source; or
|
||||
@ -1377,7 +1377,7 @@ final class component_test extends \advanced_testcase {
|
||||
// The Moodle composer file autoloads are a simple string[].
|
||||
$autoloadnamefiles = $rc->getProperty('composerautoloadfiles')->getValue(null);
|
||||
foreach ($composer['autoload']['files'] as $file) {
|
||||
$this->assertContains(trim($relativepath, '/') . "/{$file}", $autoloadnamefiles);
|
||||
$this->assertContains(trim($relativepath, '/\\') . "/{$file}", $autoloadnamefiles);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user