public function FeedsItemTargetLabelFormatterTest::testFeedsItemTargetLabelFormatterPlain in Feeds 8.3
Tests the feeds target label formatter in plain text.
@covers \Drupal\feeds\Plugin\Field\FieldFormatter\FeedsItemTargetLabelFormatter::viewElements
File
- tests/
src/ Functional/ Plugin/ Field/ FieldFormatter/ FeedsItemTargetLabelFormatterTest.php, line 35
Class
- FeedsItemTargetLabelFormatterTest
- Tests feeds_item_target_id field formatter.
Namespace
Drupal\Tests\feeds\Functional\Plugin\Field\FieldFormatterCode
public function testFeedsItemTargetLabelFormatterPlain() {
$feed = $this
->createCsvFeed();
$feed = $this
->addFieldToFeed($feed);
// Create an article with a reference to the feed.
$article = $this
->createNodeWithFeedsItem($feed);
// Display the article and test we are getting correct output for label.
$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
->htmlOutput($rendered_content);
// Assert that the label of the feeds_item field is displayed.
$this
->assertStringContainsString('<div>Feeds item</div>', (string) $rendered_content);
// Assert that the label of the feed is displayed.
$this
->assertStringContainsString('<div>' . $feed
->label() . '</div>', (string) $rendered_content);
}