You are here

protected function HtmlResponseAttachmentsTest::assertFeed in Zircon Profile 8

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

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

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

File

core/modules/system/src/Tests/Render/HtmlResponseAttachmentsTest.php, line 101
Contains \Drupal\system\Tests\Render\HtmlResponseAttachmentsTest.

Class

HtmlResponseAttachmentsTest
Functional tests for HtmlResponseAttachmentsProcessor.

Namespace

Drupal\system\Tests\Render

Code

protected function assertFeed() {

  // Discover the DOM element for the feed link.
  $test_meta = $this
    ->xpath('//head/link[@href="test://url"]');
  $this
    ->assertEqual(1, count($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
        ->assertEqual($value, $test_meta_attributes[$attribute]);
    }
  }
}