class RssResponseRelativeUrlFilterTest
Same name in other branches
- 9 core/tests/Drupal/Tests/Core/EventSubscriber/RssResponseRelativeUrlFilterTest.php \Drupal\Tests\Core\EventSubscriber\RssResponseRelativeUrlFilterTest
- 8.9.x core/tests/Drupal/Tests/Core/EventSubscriber/RssResponseRelativeUrlFilterTest.php \Drupal\Tests\Core\EventSubscriber\RssResponseRelativeUrlFilterTest
- 10 core/tests/Drupal/Tests/Core/EventSubscriber/RssResponseRelativeUrlFilterTest.php \Drupal\Tests\Core\EventSubscriber\RssResponseRelativeUrlFilterTest
@coversDefaultClass \Drupal\Core\EventSubscriber\RssResponseRelativeUrlFilter @group event_subscriber
Hierarchy
- class \Drupal\Tests\UnitTestCase extends \PHPUnit\Framework\TestCase uses \Drupal\Tests\PhpUnitCompatibilityTrait, \Prophecy\PhpUnit\ProphecyTrait, \Drupal\TestTools\Extension\DeprecationBridge\ExpectDeprecationTrait, \Drupal\Tests\RandomGeneratorTrait
- class \Drupal\Tests\Core\EventSubscriber\RssResponseRelativeUrlFilterTest extends \Drupal\Tests\UnitTestCase
Expanded class hierarchy of RssResponseRelativeUrlFilterTest
File
-
core/
tests/ Drupal/ Tests/ Core/ EventSubscriber/ RssResponseRelativeUrlFilterTest.php, line 20
Namespace
Drupal\Tests\Core\EventSubscriberView source
class RssResponseRelativeUrlFilterTest extends UnitTestCase {
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 & 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><a href="localhost/node/1">Hello&nbsp;</a>
</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 & 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><a href="localhost/node/1">Hello&nbsp;</a>
</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[
<a href="localhost/node/1">Hello</a>
<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-js-sdk'));
//--><!]]]]]]><![CDATA[><![CDATA[>
//--><!]]]]><![CDATA[>
//--><!]]>
</script>
]]>
</description>
</item>
</channel>
</rss>
RSS;
$data['invalid-feed'] = [
$invalid_feed,
$invalid_feed,
];
return $data;
}
/**
* @dataProvider providerTestOnResponse
*
* @param string $content
* The content for the request.
* @param string $expected_content
* The expected content from the response.
*/
public function testOnResponse($content, $expected_content) : void {
$event = new ResponseEvent($this->prophesize(HttpKernelInterface::class)
->reveal(), Request::create('/'), HttpKernelInterface::MAIN_REQUEST, new Response($content, 200, [
'Content-Type' => 'application/rss+xml',
]));
$url_filter = new RssResponseRelativeUrlFilter();
$url_filter->onResponse($event);
$this->assertEquals($expected_content, $event->getResponse()
->getContent());
}
}
Members
Title Sort descending | Modifiers | Object type | Summary | Overrides |
---|---|---|---|---|
ExpectDeprecationTrait::expectDeprecation | public | function | Adds an expected deprecation. | |
ExpectDeprecationTrait::getCallableName | private static | function | Returns a callable as a string suitable for inclusion in a message. | |
ExpectDeprecationTrait::setUpErrorHandler | public | function | Sets up the test error handler. | |
ExpectDeprecationTrait::tearDownErrorHandler | public | function | Tears down the test error handler. | |
RandomGeneratorTrait::getRandomGenerator | protected | function | Gets the random generator for the utility methods. | |
RandomGeneratorTrait::randomMachineName | protected | function | Generates a unique random string containing letters and numbers. | |
RandomGeneratorTrait::randomObject | public | function | Generates a random PHP object. | |
RandomGeneratorTrait::randomString | public | function | Generates a pseudo-random string of ASCII characters of codes 32 to 126. | |
RssResponseRelativeUrlFilterTest::providerTestOnResponse | public static | function | ||
RssResponseRelativeUrlFilterTest::testOnResponse | public | function | @dataProvider providerTestOnResponse | |
UnitTestCase::$root | protected | property | The app root. | |
UnitTestCase::getClassResolverStub | protected | function | Returns a stub class resolver. | |
UnitTestCase::getConfigFactoryStub | public | function | Returns a stub config factory that behaves according to the passed array. | |
UnitTestCase::getConfigStorageStub | public | function | Returns a stub config storage that returns the supplied configuration. | |
UnitTestCase::getContainerWithCacheTagsInvalidator | protected | function | Sets up a container with a cache tags invalidator. | |
UnitTestCase::getStringTranslationStub | public | function | Returns a stub translation manager that just returns the passed string. | |
UnitTestCase::setUp | protected | function | 367 | |
UnitTestCase::setUpBeforeClass | public static | function |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.