From e134b1116f61122b96bd11572efbc286a61e7595 Mon Sep 17 00:00:00 2001 From: Steve Boyd Date: Tue, 11 Jun 2024 10:22:41 +1200 Subject: [PATCH] MNT Fix siteconfig behat test running on kitchen-sink --- tests/behat/src/LoginContext.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/behat/src/LoginContext.php b/tests/behat/src/LoginContext.php index 44fb3c04..6a4d6132 100644 --- a/tests/behat/src/LoginContext.php +++ b/tests/behat/src/LoginContext.php @@ -5,6 +5,7 @@ namespace SilverStripe\CMS\Tests\Behaviour; use Page; use PHPUnit\Framework\Assert; use SilverStripe\BehatExtension\Context\LoginContext as BehatLoginContext; +use SilverStripe\SiteConfig\SiteConfig; class LoginContext extends BehatLoginContext { @@ -26,7 +27,11 @@ class LoginContext extends BehatLoginContext $password = 'Password!456'; $member = $this->generateMemberWithPermission($email, $password, $permCode); $canEdit = strstr($negative ?? '', 'not') ? false : true; - + // Flush the SiteConfig cache so that siteconfig behat tests that update a + // SiteConfig DataObject will not be referring to a stale verion of itself + // which can happen because SiteConfig::current_site_config() uses DataObject::get_one() + // which will caches its result by default + SiteConfig::current_site_config()->flushCache(); if ($canEdit) { Assert::assertTrue($page->canEdit($member), 'The member can edit this page'); } else {