Skip to content

Commit

Permalink
Merge pull request #2959 from creative-commoners/pulls/5.2/fix-behat
Browse files Browse the repository at this point in the history
MNT Fix siteconfig behat test running on kitchen-sink
  • Loading branch information
GuySartorelli authored Jun 10, 2024
2 parents 5e1706e + e134b11 commit ab33216
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 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 {
Expand Down

0 comments on commit ab33216

Please sign in to comment.