You are here

public function AddFeedTest::urlToRSSLinkPattern in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/system/tests/src/Kernel/Common/AddFeedTest.php \Drupal\Tests\system\Kernel\Common\AddFeedTest::urlToRSSLinkPattern()
  2. 9 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;
}