From b442d9d45ad208e5a41987afdd3c2f237efe2f13 Mon Sep 17 00:00:00 2001 From: Guy Sartorelli <36352093+GuySartorelli@users.noreply.github.com> Date: Tue, 2 Apr 2024 11:28:06 +1300 Subject: [PATCH 1/2] ENH Let unit tests manipulate the DB before loading fixtures (#11182) --- src/Dev/SapphireTest.php | 8 ++++++++ src/Dev/State/FixtureTestState.php | 1 + 2 files changed, 9 insertions(+) diff --git a/src/Dev/SapphireTest.php b/src/Dev/SapphireTest.php index 3694f18ae..df953acc2 100644 --- a/src/Dev/SapphireTest.php +++ b/src/Dev/SapphireTest.php @@ -251,6 +251,14 @@ abstract class SapphireTest extends TestCase implements TestOnly return $this->requireDefaultRecordsFrom; } + /** + * Called after the database is created, but before fixtures are loaded. + */ + public function onBeforeLoadFixtures(): void + { + // no-op - this method is intended to be overridden by subclasses. + } + /** * Setup the test. * Always sets up in order: diff --git a/src/Dev/State/FixtureTestState.php b/src/Dev/State/FixtureTestState.php index 441f212c3..2488c5f17 100644 --- a/src/Dev/State/FixtureTestState.php +++ b/src/Dev/State/FixtureTestState.php @@ -63,6 +63,7 @@ class FixtureTestState implements TestState $instance->augmentDefaultRecords(); } } + $test->onBeforeLoadFixtures(); $this->loadFixtures($test); } From cca2f7059bc572497a8ed80f2d35e12a94984683 Mon Sep 17 00:00:00 2001 From: Thomas Portelange Date: Tue, 2 Apr 2024 02:33:09 +0200 Subject: [PATCH 2/2] ENH Update PHPDocs for methods with missing nullable return types (#11187) --- src/Core/Manifest/ModuleResourceLoader.php | 8 ++++---- src/Security/Member.php | 7 +++---- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/Core/Manifest/ModuleResourceLoader.php b/src/Core/Manifest/ModuleResourceLoader.php index 96cf80e2c..6ae4ef3db 100644 --- a/src/Core/Manifest/ModuleResourceLoader.php +++ b/src/Core/Manifest/ModuleResourceLoader.php @@ -19,7 +19,7 @@ class ModuleResourceLoader implements TemplateGlobalProvider * For other files, return original value * * @param string $resource - * @return string + * @return string|null */ public function resolvePath($resource) { @@ -38,7 +38,7 @@ class ModuleResourceLoader implements TemplateGlobalProvider * Resolves resource specifier to the given url. * * @param string $resource - * @return string + * @return string|null */ public function resolveURL($resource) { @@ -60,7 +60,7 @@ class ModuleResourceLoader implements TemplateGlobalProvider * Template wrapper for resolvePath * * @param string $resource - * @return string + * @return string|null */ public static function resourcePath($resource) { @@ -71,7 +71,7 @@ class ModuleResourceLoader implements TemplateGlobalProvider * Template wrapper for resolveURL * * @param string $resource - * @return string + * @return string|null */ public static function resourceURL($resource) { diff --git a/src/Security/Member.php b/src/Security/Member.php index a511a9e3e..4b60be117 100644 --- a/src/Security/Member.php +++ b/src/Security/Member.php @@ -390,7 +390,7 @@ class Member extends DataObject /** * Returns the default {@link PasswordValidator} * - * @return PasswordValidator + * @return PasswordValidator|null */ public static function password_validator() { @@ -575,8 +575,7 @@ class Member extends DataObject * @param string $hash The hash key * @param bool $login Should the member be logged in? * - * @return Member the matching member, if valid - * @return Member + * @return Member|null the matching member, if valid or null */ public static function member_from_autologinhash($hash, $login = false) { @@ -597,7 +596,7 @@ class Member extends DataObject * Find a member record with the given TempIDHash value * * @param string $tempid - * @return Member + * @return Member|null the matching member, if valid or null */ public static function member_from_tempid($tempid) {