Skip to content

Commit

Permalink
Merge pull request #8 from markhuot/fix-test-database-cache-sharing
Browse files Browse the repository at this point in the history
fixes a bug where caches are shared between dev and test when using s…
  • Loading branch information
markhuot authored Dec 5, 2023
2 parents de027c9 + defd474 commit fa280c8
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/test/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,15 @@ public function createApplication()
$needsRefresh = true;
}

// We have to flush the data cache to make sure we're getting an accurate look at whether or not there
// are pending changes.
//
// If you are using a separate test database from your dev database you may have an updated project
// config on the dev side and have cached that the project-config is updated. Then, when you run the
// tests you'll reach in to the same cache as the dev side and pull that the project config is unchanged
// even though it actually _is_ changed. This ensures that there isn't any cache sharing between dev
// and test.
\Craft::$app->getCache()->flush();
if (\Craft::$app->getProjectConfig()->areChangesPending(null, true)) {
$this->craftProjectConfigApply();
$needsRefresh = true;
Expand Down

0 comments on commit fa280c8

Please sign in to comment.