class DisplayVariantTest

Same name in this branch
  1. 9 core/tests/Drupal/Tests/Core/Display/DisplayVariantTest.php \Drupal\Tests\Core\Display\DisplayVariantTest
Same name and namespace in other branches
  1. 11.x core/modules/system/tests/src/Functional/Render/DisplayVariantTest.php \Drupal\Tests\system\Functional\Render\DisplayVariantTest
  2. 11.x core/tests/Drupal/Tests/Core/Display/DisplayVariantTest.php \Drupal\Tests\Core\Display\DisplayVariantTest
  3. 10 core/modules/system/tests/src/Functional/Render/DisplayVariantTest.php \Drupal\Tests\system\Functional\Render\DisplayVariantTest
  4. 10 core/tests/Drupal/Tests/Core/Display/DisplayVariantTest.php \Drupal\Tests\Core\Display\DisplayVariantTest
  5. 8.9.x core/modules/system/tests/src/Functional/Render/DisplayVariantTest.php \Drupal\Tests\system\Functional\Render\DisplayVariantTest
  6. 8.9.x core/tests/Drupal/Tests/Core/Display/DisplayVariantTest.php \Drupal\Tests\Core\Display\DisplayVariantTest

Tests selecting a display variant.

@group Render

Hierarchy

Expanded class hierarchy of DisplayVariantTest

File

core/modules/system/tests/src/Functional/Render/DisplayVariantTest.php, line 12

Namespace

Drupal\Tests\system\Functional\Render
View source
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');
  }

}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.