class BlockBackwardCompatibilityTest

Same name and namespace in other branches
  1. main core/themes/stable9/tests/Unit/BlockBackwardCompatibilityTest.php \Drupal\Tests\stable9\Unit\BlockBackwardCompatibilityTest

Tests backward compatibility for block templates.

Attributes

#[Group('Theme')]

Hierarchy

Expanded class hierarchy of BlockBackwardCompatibilityTest

File

core/themes/stable9/tests/Unit/BlockBackwardCompatibilityTest.php, line 14

Namespace

Drupal\Tests\stable9\Unit
View source
class BlockBackwardCompatibilityTest extends UnitTestCase {
  
  /**
   * Tests copying content attributes to the wrapper.
   *
   * @legacy-covers \Drupal\stable9\Hook\Stable9Hooks::preprocessBlock()
   */
  public function testAttributeCopy() : void {
    $variables = [
      'attributes' => [
        'id' => 'test-block',
        'class' => [
          'wrapper-class',
        ],
      ],
      'content' => [
        '#attributes' => [
          'class' => [
            'content-class',
          ],
          'data-foo' => 'bar',
        ],
      ],
    ];
    $hooks = new Stable9Hooks();
    $hooks->preprocessBlock($variables);
    $expected = [
      'attributes' => [
        'id' => 'test-block',
        'class' => [
          'wrapper-class',
          'content-class',
        ],
        'data-foo' => 'bar',
      ],
      'content' => [],
    ];
    $this->assertEquals($expected, $variables);
  }

}

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