You are here

protected function HtmlResponseAttachmentsTest::assertFeed in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/system/tests/src/Functional/Render/HtmlResponseAttachmentsTest.php \Drupal\Tests\system\Functional\Render\HtmlResponseAttachmentsTest::assertFeed()
  2. 9 core/modules/system/tests/src/Functional/Render/HtmlResponseAttachmentsTest.php \Drupal\Tests\system\Functional\Render\HtmlResponseAttachmentsTest::assertFeed()

Helper function to make assertions about the presence of an RSS feed.

@internal

2 calls to HtmlResponseAttachmentsTest::assertFeed()
HtmlResponseAttachmentsTest::testAttachments in core/modules/system/tests/src/Functional/Render/HtmlResponseAttachmentsTest.php
Tests rendering of ['#attached'].
HtmlResponseAttachmentsTest::testRenderCachedBlock in core/modules/system/tests/src/Functional/Render/HtmlResponseAttachmentsTest.php
Tests caching of ['#attached'].

File

core/modules/system/tests/src/Functional/Render/HtmlResponseAttachmentsTest.php, line 118

Class

HtmlResponseAttachmentsTest
Functional tests for HtmlResponseAttachmentsProcessor.

Namespace

Drupal\Tests\system\Functional\Render

Code

protected function assertFeed() : void {

  // Discover the DOM element for the feed link.
  $test_meta = $this
    ->xpath('//head/link[@href="test://url"]');
  $this
    ->assertCount(1, $test_meta, 'Link has URL.');

  // Reconcile the other attributes.
  $test_meta_attributes = [
    'href' => 'test://url',
    'rel' => 'alternate',
    'type' => 'application/rss+xml',
    'title' => 'Your RSS feed.',
  ];
  $test_meta = reset($test_meta);
  if (empty($test_meta)) {
    $this
      ->fail('Unable to find feed link.');
  }
  else {
    foreach ($test_meta_attributes as $attribute => $value) {
      $this
        ->assertEquals($value, $test_meta
        ->getAttribute($attribute));
    }
  }
}