RssFieldsTest.php in Drupal 10
File
core/modules/views/tests/src/Kernel/Plugin/RssFieldsTest.php
View source
<?php
namespace Drupal\Tests\views\Kernel\Plugin;
use Drupal\Tests\node\Traits\ContentTypeCreationTrait;
use Drupal\Tests\node\Traits\NodeCreationTrait;
use Drupal\Tests\user\Traits\UserCreationTrait;
use Drupal\Tests\views\Kernel\ViewsKernelTestBase;
use Drupal\views\Views;
class RssFieldsTest extends ViewsKernelTestBase {
use NodeCreationTrait;
use ContentTypeCreationTrait;
use UserCreationTrait;
protected static $modules = [
'node',
'field',
'text',
'filter',
];
public static $testViews = [
'test_display_feed',
];
protected function setUp($import_test_views = TRUE) : void {
parent::setUp($import_test_views);
$this
->installConfig([
'node',
'filter',
]);
$this
->installEntitySchema('user');
$this
->installEntitySchema('node');
$this
->installEntitySchema('path_alias');
$this
->createContentType([
'type' => 'article',
]);
}
public function testLink() {
$this
->setUpCurrentUser([
'uid' => 1,
]);
$node = $this
->createNode([
'type' => 'article',
'title' => 'Article title',
'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);
}
}