Skip to content

Commit

Permalink
Refresh sites after loading/unloading the sites fixture
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonkelly committed Nov 21, 2024
1 parent befd9c9 commit fe74e18
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions tests/fixtures/SitesFixture.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

use Craft;
use craft\records\Site;
use craft\services\Sites;
use craft\test\ActiveFixture;

/**
Expand Down Expand Up @@ -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();
}
}

0 comments on commit fe74e18

Please sign in to comment.