function HtmlResponseAttachmentsTest::assertFeed

Same name in other branches
  1. 9 core/modules/system/tests/src/Functional/Render/HtmlResponseAttachmentsTest.php \Drupal\Tests\system\Functional\Render\HtmlResponseAttachmentsTest::assertFeed()
  2. 8.9.x core/modules/system/tests/src/Functional/Render/HtmlResponseAttachmentsTest.php \Drupal\Tests\system\Functional\Render\HtmlResponseAttachmentsTest::assertFeed()
  3. 10 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));
        }
    }
}

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