DisplayVariantTest.php

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

Namespace

Drupal\Tests\system\Functional\Render

File

core/modules/system/tests/src/Functional/Render/DisplayVariantTest.php

View source
<?php

declare (strict_types=1);
namespace Drupal\Tests\system\Functional\Render;

use Drupal\Tests\BrowserTestBase;

/**
 * Tests selecting a display variant.
 *
 * @group Render
 */
class DisplayVariantTest extends BrowserTestBase {
    
    /**
     * {@inheritdoc}
     */
    protected static $modules = [
        'display_variant_test',
    ];
    
    /**
     * {@inheritdoc}
     */
    protected $defaultTheme = 'stark';
    
    /**
     * Tests selecting the variant and passing configuration.
     */
    public function testPageDisplayVariantSelectionEvent() : void {
        // 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

Title Deprecated Summary
DisplayVariantTest Tests selecting a display variant.

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