Same name and namespace in other branches
- 8.9.x core/modules/views/tests/src/Kernel/Plugin/RssFieldsTest.php \Drupal\Tests\views\Kernel\Plugin\RssFieldsTest
- 9 core/modules/views/tests/src/Kernel/Plugin/RssFieldsTest.php \Drupal\Tests\views\Kernel\Plugin\RssFieldsTest
Tests \Drupal\views\Plugin\views\row\RssFields.
@group views
Hierarchy
- class \Drupal\Tests\views\Kernel\ViewsKernelTestBase extends \Drupal\KernelTests\KernelTestBase uses ViewResultAssertionTrait
- class \Drupal\Tests\views\Kernel\Plugin\RssFieldsTest uses ContentTypeCreationTrait, NodeCreationTrait, UserCreationTrait
Expanded class hierarchy of RssFieldsTest
File
- core/
modules/ views/ tests/ src/ Kernel/ Plugin/ RssFieldsTest.php, line 18
Namespace
Drupal\Tests\views\Kernel\PluginView source
class RssFieldsTest extends ViewsKernelTestBase {
use NodeCreationTrait;
use ContentTypeCreationTrait;
use UserCreationTrait;
/**
* {@inheritdoc}
*/
protected static $modules = [
'node',
'field',
'text',
'filter',
];
/**
* {@inheritdoc}
*/
public static $testViews = [
'test_display_feed',
];
/**
* {@inheritdoc}
*/
protected function setUp($import_test_views = TRUE) : void {
parent::setUp($import_test_views);
$this
->installConfig([
'node',
'filter',
]);
$this
->installEntitySchema('user');
$this
->installEntitySchema('node');
$this
->createContentType([
'type' => 'article',
]);
}
/**
* Tests correct processing of RSS fields.
*
* This overlaps with \Drupal\Tests\views\Functional\Plugin\DisplayFeedTest to
* ensure that root-relative links also work in a scenario without
* subdirectory.
*/
public function testRssFields() {
$this
->setUpCurrentUser([], [
'access content',
]);
$date = '1975-05-18';
$node = $this
->createNode([
'type' => 'article',
'title' => 'Article title',
'created' => strtotime($date),
'body' => [
0 => [
'value' => 'A paragraph',
'format' => filter_default_format(),
],
],
]);
$node_url = $node
->toUrl()
->setAbsolute()
->toString();
$renderer = $this->container
->get('renderer');
$view = Views::getView('test_display_feed');
$output = $view
->preview('feed_2');
$output = (string) $renderer
->renderRoot($output);
$this
->assertStringContainsString('<link>' . $node_url . '</link>', $output);
$this
->assertStringContainsString('<pubDate>' . $date . '</pubDate>', $output);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ContentTypeCreationTrait:: |
protected | function | Creates a custom content type based on default settings. | |
NodeCreationTrait:: |
protected | function | Creates a node based on default settings. | |
NodeCreationTrait:: |
public | function | Get a node from the database based on its title. | |
RssFieldsTest:: |
protected static | property |
Overrides ViewsKernelTestBase:: |
|
RssFieldsTest:: |
public static | property |
Views to be enabled. Overrides ViewsKernelTestBase:: |
|
RssFieldsTest:: |
protected | function |
Overrides ViewsKernelTestBase:: |
|
RssFieldsTest:: |
public | function | Tests correct processing of RSS fields. | |
UserCreationTrait:: |
protected | function | Checks whether a given list of permission names is valid. | |
UserCreationTrait:: |
protected | function | Creates an administrative role. | |
UserCreationTrait:: |
protected | function | Creates a role with specified permissions. | |
UserCreationTrait:: |
protected | function | Create a user with a given set of permissions. | |
UserCreationTrait:: |
protected | function | Grant permissions to a user role. | |
UserCreationTrait:: |
protected | function | Switch the current logged in user. | |
UserCreationTrait:: |
protected | function | Creates a random user account and sets it as current user. | |
ViewResultAssertionTrait:: |
protected | function | Verifies that a result set returned by a View matches expected values. | |
ViewResultAssertionTrait:: |
protected | function | Performs View result assertions. | |
ViewResultAssertionTrait:: |
protected | function | Verifies that a result set returned by a View differs from certain values. | |
ViewsKernelTestBase:: |
protected | function | Returns a very simple test dataset. | 8 |
ViewsKernelTestBase:: |
protected | function | Executes a view. | |
ViewsKernelTestBase:: |
protected | function | Orders a nested array containing a result set based on a given column. | |
ViewsKernelTestBase:: |
protected | function | Returns the schema definition. | 6 |
ViewsKernelTestBase:: |
protected | function | Sets up the configuration and schema of views and views_test_data modules. | 7 |
ViewsKernelTestBase:: |
protected | function | Returns the views data definition. | 22 |