You are here

DisplayVariantTest.php in Drupal 9

File

core/modules/system/tests/src/Functional/Render/DisplayVariantTest.php
View source
<?php

namespace Drupal\Tests\system\Functional\Render;

use Drupal\Tests\BrowserTestBase;

/**
 * Tests selecting a display variant.
 *
 * @group Render
 */
class DisplayVariantTest extends BrowserTestBase {

  /**
   * Modules to enable.
   *
   * @var array
   */
  protected static $modules = [
    'display_variant_test',
  ];

  /**
   * {@inheritdoc}
   */
  protected $defaultTheme = 'stark';

  /**
   * Tests selecting the variant and passing configuration.
   */
  public function testPageDisplayVariantSelectionEvent() {

    // Tests that our display variant was selected, and that its configuration
    // was passed correctly. If the configuration wasn't passed, we'd get an
    // error page here.
    $this
      ->drupalGet('<front>');
    $this
      ->assertSession()
      ->pageTextContains('A very important, required value.');
    $this
      ->assertSession()
      ->pageTextContains('Explicitly passed in context.');
    $this
      ->assertSession()
      ->responseHeaderContains('X-Drupal-Cache-Tags', 'custom_cache_tag');
  }

}

Classes

Namesort descending Description
DisplayVariantTest Tests selecting a display variant.