You are here

public function UiPatternsLayoutsRenderTest::testUiPatternsLayoutsRendering in UI Patterns 8

Tests field template settings.

File

modules/ui_patterns_layouts/tests/src/FunctionalJavascript/UiPatternsLayoutsRenderTest.php, line 51

Class

UiPatternsLayoutsRenderTest
Test Layouts template rendering.

Namespace

Drupal\Tests\ui_patterns_layout\FunctionalJavascript

Code

public function testUiPatternsLayoutsRendering() {
  $this
    ->enableTwigDebugMode();
  $this
    ->drupalLogin($this
    ->drupalCreateUser([], NULL, TRUE));
  $node = $this
    ->drupalCreateNode([
    'title' => 'Test article',
    'body' => 'Test body',
    'type' => 'article',
  ]);
  $this
    ->drupalGet($node
    ->toUrl());
  $assert_session = $this
    ->assertSession();

  // Assert correct variant suggestions.
  $suggestions = [
    'pattern-one-column--variant-default--layout--node--1.html.twig',
    'pattern-one-column--variant-default--layout--node--article--full.html.twig',
    'pattern-one-column--variant-default--layout--node--full.html.twig',
    'pattern-one-column--variant-default--layout--node--article.html.twig',
    'pattern-one-column--variant-default--layout--node.html.twig',
    'pattern-one-column--variant-default--layout.html.twig',
    'pattern-one-column--layout--node--1.html.twig',
    'pattern-one-column--layout--node--article--full.html.twig',
    'pattern-one-column--layout--node--full.html.twig',
    'pattern-one-column--layout--node--article.html.twig',
    'pattern-one-column--layout--node.html.twig',
    'pattern-one-column--layout.html.twig',
    'pattern-one-column--variant-default.html.twig',
    'pattern-one-column.html.twig',
  ];
  foreach ($suggestions as $suggestion) {
    $assert_session
      ->responseContains($suggestion);
  }

  // Test content is rendered in the pattern.
  $assert_session
    ->elementContains('css', 'article', 'Test body');
}