You are here

public function SkipNewTest::testSkipNewItems in Feeds 8.3

Tests skip new items when there are no nodes yet.

File

tests/src/Kernel/SkipNewTest.php, line 94

Class

SkipNewTest
Tests the feature of creating/skipping new items.

Namespace

Drupal\Tests\feeds\Kernel

Code

public function testSkipNewItems() {

  // Configure that new items should not be imported.
  $feed_type = $this
    ->createFeedTypeForThisTest([
    'insert_new' => ProcessorInterface::SKIP_NEW,
  ]);

  // Create a feed and import.
  // No nodes should be created, as all are new.
  $feed = $this
    ->createFeed($feed_type
    ->id(), [
    'source' => $this
      ->resourcesPath() . '/rss/drupalplanet.rss2',
  ]);
  $feed
    ->import();

  // Assert that no nodes were created.
  $this
    ->assertNodeCount(0);
  $this
    ->assertEquals(0, $this->processState->created);

  // All items should have been skipped.
  $this
    ->assertEquals(25, $this->processState->skipped);
}