public function FeedsItemUrlFormatterTest::testOutputUrlAsPlainText in Feeds 8.3
Test that the plain text URL display setting works.
@covers \Drupal\feeds\Plugin\Field\FieldFormatter\FeedsItemUrlFormatter::viewElements
File
- tests/
src/ Functional/ Plugin/ Field/ FieldFormatter/ FeedsItemUrlFormatterTest.php, line 71
Class
- FeedsItemUrlFormatterTest
- Tests feeds_item_url field formatter.
Namespace
Drupal\Tests\feeds\Functional\Plugin\Field\FieldFormatterCode
public function testOutputUrlAsPlainText() {
$input = 'https://en.wikipedia.org/wiki/Star_Control_3';
$expected = '<div>https://en.wikipedia.org/wiki/Star_Control_3</div>';
// Set display mode for feeds_item to feeds_item_url on article content
// type with plain_text_url setting on.
$this->container
->get('entity_display.repository')
->getViewDisplay('node', 'article', 'default')
->setComponent('feeds_item', [
'type' => 'feeds_item_url',
'settings' => [
'url_plain' => TRUE,
],
'weight' => 1,
])
->save();
$feed = $this
->createCsvFeed();
// Create an article and set the 'url' property on the feeds_item field.
$article = $this
->createNodeWithFeedsItem($feed);
$article->feeds_item->url = $input;
$display = $this->container
->get('entity_display.repository')
->getViewDisplay($article
->getEntityTypeId(), $article
->bundle(), 'default');
$content = $display
->build($article);
$rendered_content = $this->container
->get('renderer')
->renderRoot($content);
$this
->assertStringContainsString($expected, (string) $rendered_content);
}