public function FeedsItemGuidFormatterTest::testFeedsItemGuidFormatter in Feeds 8.3
Test the feeds item guid formatter.
@covers \Drupal\feeds\Plugin\Field\FieldFormatter\FeedsItemGuidFormatter::viewElements
@dataProvider providerGuids
File
- tests/
src/ Functional/ Plugin/ Field/ FieldFormatter/ FeedsItemGuidFormatterTest.php, line 36
Class
- FeedsItemGuidFormatterTest
- Tests feeds_item_guid field formatter.
Namespace
Drupal\Tests\feeds\Functional\Plugin\Field\FieldFormatterCode
public function testFeedsItemGuidFormatter($input, $expected) {
$feed = $this
->createCsvFeed();
// Create an article and set the feeds item guid value.
$article = $this
->createNodeWithFeedsItem($feed);
$article->feeds_item->guid = $input;
// Display the article and test we are getting correct output for guid.
$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);
if ($expected) {
$this
->assertStringContainsString($expected, (string) $rendered_content);
}
else {
// If nothing is expected to be displayed, check if the field is rendered
// at all.
$this
->assertFeedsItemFieldNotDisplayed($rendered_content, $input);
}
}