Skip to content

Commit

Permalink
FIX updateCMSFields test sometimes fails with field not found, made s…
Browse files Browse the repository at this point in the history
…tronger
  • Loading branch information
robbieaverill committed Oct 19, 2018
1 parent 840e737 commit d5a278e
Showing 1 changed file with 22 additions and 10 deletions.
32 changes: 22 additions & 10 deletions tests/php/Extension/FluentSiteTreeExtensionTest.php
Expand Up @@ -9,6 +9,7 @@
use SilverStripe\Core\Config\Config;
use SilverStripe\Dev\SapphireTest;
use SilverStripe\Forms\FieldList;
use SilverStripe\Forms\LiteralField;
use SilverStripe\ORM\ArrayList;
use SilverStripe\View\ArrayData;
use TractorCow\Fluent\Extension\FluentDirectorExtension;
Expand Down Expand Up @@ -157,24 +158,35 @@ public function testFluentURLs($domain, $locale, $prefixDisabled, $pageName, $ur
$this->assertEquals($url, $page->Link());
}

public function testUpdateStatusFlagsFluentInivisible()
public function testUpdateStatusFlagsFluentInvisible()
{
/** @var Page|FluentSiteTreeExtension $page */
$page = $this->objFromFixture('Page', 'home');
$flags = $page->getStatusFlags();

$this->assertTrue(array_key_exists('fluentinvisible', $flags));
$this->assertArrayHasKey('fluentinvisible', $flags);
}

public function testUpdateCMSFields()
public function testStatusMessageNotVisible()
{
/** @var Page|FluentSiteTreeExtension $page */
$page = $this->objFromFixture('Page', 'home');
$fields = new FieldList();

$page->updateCMSFields($fields);

$this->assertNotNull($fields->fieldByName('LocaleStatusMessage'));
FluentState::singleton()->withState(function (FluentState $newState) {
$newState
->setLocale('en_NZ')
->setIsDomainMode(false);

/** @var Page|FluentSiteTreeExtension $page */
$page = $this->objFromFixture(Page::class, 'staff');
$page->config()
->set('locale_published_status_message', true)
->set('frontend_publish_required', true);

$fields = $page->getCMSFields();

/** @var LiteralField $statusMessage */
$statusMessage = $fields->fieldByName('LocaleStatusMessage');
$this->assertNotNull($statusMessage, 'Locale message was not added');
$this->assertContains('This page is not visible in this locale', $statusMessage->getContent());
});
}

public function testUpdateCMSActionsInherited()
Expand Down

0 comments on commit d5a278e

Please sign in to comment.