function AddFeedTest::urlToRSSLinkPattern

Same name in other branches
  1. 9 core/modules/system/tests/src/Kernel/Common/AddFeedTest.php \Drupal\Tests\system\Kernel\Common\AddFeedTest::urlToRSSLinkPattern()
  2. 10 core/modules/system/tests/src/Kernel/Common/AddFeedTest.php \Drupal\Tests\system\Kernel\Common\AddFeedTest::urlToRSSLinkPattern()
  3. 11.x core/modules/system/tests/src/Kernel/Common/AddFeedTest.php \Drupal\Tests\system\Kernel\Common\AddFeedTest::urlToRSSLinkPattern()

Creates a pattern representing the RSS feed in the page.

1 call to AddFeedTest::urlToRSSLinkPattern()
AddFeedTest::testBasicFeedAddNoTitle in core/modules/system/tests/src/Kernel/Common/AddFeedTest.php
Tests attaching feeds with paths, URLs, and titles.

File

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

Class

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

Namespace

Drupal\Tests\system\Kernel\Common

Code

public function urlToRSSLinkPattern($url, $title = '') {
    // Escape any regular expression characters in the URL ('?' is the worst).
    $url = preg_replace('/([+?.*])/', '[$0]', $url);
    $generated_pattern = '%<link +href="' . $url . '" +rel="alternate" +title="' . $title . '" +type="application/rss.xml" */>%';
    return $generated_pattern;
}

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