From fe74e184462d0f2d1829636cf4b084c65822d9c6 Mon Sep 17 00:00:00 2001 From: brandonkelly Date: Wed, 20 Nov 2024 17:19:13 -0800 Subject: [PATCH] Refresh sites after loading/unloading the sites fixture --- tests/fixtures/SitesFixture.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/tests/fixtures/SitesFixture.php b/tests/fixtures/SitesFixture.php index 542c6d93586..1c113cc87e3 100644 --- a/tests/fixtures/SitesFixture.php +++ b/tests/fixtures/SitesFixture.php @@ -9,7 +9,6 @@ use Craft; use craft\records\Site; -use craft\services\Sites; use craft\test\ActiveFixture; /** @@ -37,9 +36,15 @@ class SitesFixture extends ActiveFixture public function load(): void { parent::load(); + Craft::$app->getSites()->refreshSites(); + } - // Because the Sites() class memoizes on initialization we need to set() a new sites class - // with the updated fixture data - Craft::$app->set('sites', new Sites()); + /** + * @inheritdoc + */ + public function unload(): void + { + parent::unload(); + Craft::$app->getSites()->refreshSites(); } }