You are here

public function ViewModeTest::testInternalWarning in Lightning Layout 8

Tests that internal view displays show a warning when being edited.

File

tests/src/Functional/ViewModeTest.php, line 37

Class

ViewModeTest
@group lightning_layout

Namespace

Drupal\Tests\lightning_layout\Functional

Code

public function testInternalWarning() {
  $page = $this
    ->getSession()
    ->getPage();
  $assert_session = $this
    ->assertSession();
  $account = $this
    ->drupalCreateUser([
    'administer display modes',
    'administer node display',
  ]);
  $this
    ->drupalLogin($account);
  $this
    ->drupalGet('/admin/structure/display-modes/view');
  $assert_session
    ->statusCodeEquals(200);
  $page
    ->clickLink('Add new Content view mode');
  $page
    ->fillField('Name', 'Foobaz');
  $page
    ->fillField('id', 'foobaz');
  $page
    ->pressButton('Save');
  $assert_session
    ->statusCodeEquals(200);
  $assert_session
    ->pageTextContains('Foobaz');
  $view_mode = EntityViewMode::load('node.foobaz');
  $this
    ->assertInstanceOf(EntityViewModeInterface::class, $view_mode);

  /** @var \Drupal\Core\Entity\EntityViewModeInterface $view_mode */
  $view_mode
    ->setThirdPartySetting('lightning_core', 'internal', TRUE);
  $this
    ->assertSame(SAVED_UPDATED, $view_mode
    ->save());
  $this
    ->drupalGet("/admin/structure/types/manage/landing_page/display");
  $assert_session
    ->statusCodeEquals(200);
  $page
    ->checkField('Foobaz');
  $page
    ->pressButton('Save');
  $page
    ->clickLink('Foobaz');
  $assert_session
    ->pageTextContains('This display is internal and will not be seen by normal users.');
  $assert_session
    ->fieldNotExists('Panelize this view mode');
}