You are here

public function FeedsItemImportedFormatterTest::testFeedsItemImportedFormatter in Feeds 8.3

Test the feeds item imported formatter.

@covers \Drupal\feeds\Plugin\Field\FieldFormatter\FeedsItemImportedFormatter::viewElements

@dataProvider providerImported

File

tests/src/Functional/Plugin/Field/FieldFormatter/FeedsItemImportedFormatterTest.php, line 56

Class

FeedsItemImportedFormatterTest
Tests feeds_item_imported field formatter.

Namespace

Drupal\Tests\feeds\Functional\Plugin\Field\FieldFormatter

Code

public function testFeedsItemImportedFormatter($input, $expected) {
  $feed = $this
    ->createCsvFeed();

  // Create an article and set imported time.
  $article = $this
    ->createNodeWithFeedsItem($feed);
  $article->feeds_item->imported = $input;

  // Set custom date format for last test to m-d-Y.
  if ($input == '1543370515') {
    $this
      ->switchToCustomDateFormat();
  }

  // Display the article and test we are getting correct output for
  // 'imported'.
  $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);
}