function RssResponseRelativeUrlFilterTest::providerTestOnResponse

Same name and namespace in other branches
  1. 9 core/tests/Drupal/Tests/Core/EventSubscriber/RssResponseRelativeUrlFilterTest.php \Drupal\Tests\Core\EventSubscriber\RssResponseRelativeUrlFilterTest::providerTestOnResponse()
  2. 8.9.x core/tests/Drupal/Tests/Core/EventSubscriber/RssResponseRelativeUrlFilterTest.php \Drupal\Tests\Core\EventSubscriber\RssResponseRelativeUrlFilterTest::providerTestOnResponse()
  3. 10 core/tests/Drupal/Tests/Core/EventSubscriber/RssResponseRelativeUrlFilterTest.php \Drupal\Tests\Core\EventSubscriber\RssResponseRelativeUrlFilterTest::providerTestOnResponse()

File

core/tests/Drupal/Tests/Core/EventSubscriber/RssResponseRelativeUrlFilterTest.php, line 20

Class

RssResponseRelativeUrlFilterTest
@coversDefaultClass <a href="/api/drupal/core%21lib%21Drupal%21Core%21EventSubscriber%21RssResponseRelativeUrlFilter.php/class/RssResponseRelativeUrlFilter/11.x" title="Subscribes to filter RSS responses, to make relative URIs absolute." class="local">\Drupal\Core\EventSubscriber\RssResponseRelativeUrlFilter</a> @group event_subscriber

Namespace

Drupal\Tests\Core\EventSubscriber

Code

public static function providerTestOnResponse() {
    $data = [];
    $valid_feed = <<<RSS
<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0" xml:base="https://www.drupal.org">
<channel>
  <title>Drupal.org</title>
  <link>https://www.drupal.org</link>
  <description>Come for the software &amp; stay for the community
Drupal is an open source content management platform powering millions of websites and applications. It’s built, used, and supported by an active and diverse community of people around the world.</description>
  <language>en</language>
  <item>
     <title>Drupal 8 turns one!</title>
     <link>https://www.drupal.org/blog/drupal-8-turns-one</link>
     <description>&lt;a href=&quot;localhost/node/1&quot;&gt;Hello&amp;nbsp;&lt;/a&gt;
    </description>
  </item>
  </channel>
</rss>
RSS;
    $valid_expected_feed = <<<RSS
<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0" xml:base="https://www.drupal.org">
<channel>
  <title>Drupal.org</title>
  <link>https://www.drupal.org</link>
  <description>Come for the software &amp; stay for the community
Drupal is an open source content management platform powering millions of websites and applications. It’s built, used, and supported by an active and diverse community of people around the world.</description>
  <language>en</language>
  <item>
     <title>Drupal 8 turns one!</title>
     <link>https://www.drupal.org/blog/drupal-8-turns-one</link>
     <description>&lt;a href="localhost/node/1"&gt;Hello&amp;nbsp;&lt;/a&gt;
    </description>
  </item>
  </channel>
</rss>

RSS;
    $data['valid-feed'] = [
        $valid_feed,
        $valid_expected_feed,
    ];
    $invalid_feed = <<<RSS
<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xml:base="https://www.drupal.org"  xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
  <title>Drupal.org</title>
  <link>https://www.drupal.org</link>
  <description>Come for the software, stay for the community
Drupal is an open source content management platform powering millions of websites and applications. It’s built, used, and supported by an active and diverse community of people around the world.</description>
  <language>en</language>
  <item>
     <title>Drupal 8 turns one!</title>
     <link>https://www.drupal.org/blog/drupal-8-turns-one</link>
     <description>
     <![CDATA[
     &lt;a href="localhost/node/1"&gt;Hello&lt;/a&gt;
     <script>
<!--//--><![CDATA[// ><!--

<!--//--><![CDATA[// ><!--

<!--//--><![CDATA[// ><!--
(function(d, s, id) {
  var js, fjs = d.getElementsByTagName(s)[0];
  if (d.getElementById(id)) return;
  js = d.createElement(s); js.id = id;
  js.src = "//connect.facebook.net/de_DE/sdk.js#xfbml=1&version=v2.3";
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
//--><!]]]]]]><![CDATA[><![CDATA[>

//--><!]]]]><![CDATA[>

//--><!]]>
</script>
    ]]>
    </description>
  </item>
  </channel>
</rss>
RSS;
    $data['invalid-feed'] = [
        $invalid_feed,
        $invalid_feed,
    ];
    return $data;
}

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