Skip to content

Commit

Permalink
MNT Fix siteconfig behat test running on kitchen-sink
Browse files Browse the repository at this point in the history
  • Loading branch information
emteknetnz committed Jun 10, 2024
1 parent 5e1706e commit f51171b
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion tests/behat/src/LoginContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Page;
use PHPUnit\Framework\Assert;
use SilverStripe\BehatExtension\Context\LoginContext as BehatLoginContext;
use SilverStripe\SiteConfig\SiteConfig;

class LoginContext extends BehatLoginContext
{
Expand All @@ -26,7 +27,11 @@ public function pagesShouldBeEditableBy($negative, $permCode)
$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 the the
// SiteConfig DataObject will not be referring to stale version of themselves
// which happens because SiteConfig::current_site_config() uses DataList::get_one()
// which will cache by default
SiteConfig::current_site_config()->flushCache();
if ($canEdit) {
Assert::assertTrue($page->canEdit($member), 'The member can edit this page');
} else {
Expand Down

0 comments on commit f51171b

Please sign in to comment.