function AddFeedTest::testAttributeAdded

Same name and namespace in other branches
  1. 11.x core/modules/system/tests/src/Kernel/Common/AddFeedTest.php \Drupal\Tests\system\Kernel\Common\AddFeedTest::testAttributeAdded()

Tests that the rendered output contains specific attributes.

File

core/modules/system/tests/src/Kernel/Common/AddFeedTest.php, line 105

Class

AddFeedTest
Make sure that attaching feeds works correctly with various constructs.

Namespace

Drupal\Tests\system\Kernel\Common

Code

public function testAttributeAdded() : void {
  $variables = [
    '#theme' => 'feed_icon',
    '#url' => 'node/add/',
    '#title' => 'testing title',
    '#attributes' => [
      'title' => 'some title',
      'class' => [
        'some-class',
      ],
    ],
  ];
  $rendered_output = (string) \Drupal::service('renderer')->renderRoot($variables);
  // Check if the class 'some-class' is present in the rendered output.
  $this->assertStringContainsString('some-class', $rendered_output, "The class 'some-class' should be present in the rendered output.");
}

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