You are here

public function FeedsDrushCommandsTest::testImportDisabledFeed in Feeds 8.3

Tests importing a disabled feed.

When the feed is disabled, the import should not happen unless when passing the --import-disabled option.

File

tests/src/Functional/Commands/FeedsDrushCommandsTest.php, line 172

Class

FeedsDrushCommandsTest
@coversDefaultClass \Drupal\feeds\Commands\FeedsDrushCommands @group feeds

Namespace

Drupal\Tests\feeds\Functional\Commands

Code

public function testImportDisabledFeed() {

  // Create a feed.
  $feed = $this
    ->createFeed($this->feedType
    ->id(), [
    'source' => $this
      ->resourcesPath() . '/rss/drupalplanet.rss2',
    'status' => FALSE,
  ]);

  // Try importing feed using drush.
  $this
    ->drush('feeds:import', [
    $feed
      ->id(),
  ], [], NULL, NULL, 1);

  // Assert that no nodes got imported.
  $this
    ->assertNodeCount(0);

  // Assert the output.
  $this
    ->assertStringContainsString('The specified feed is disabled. If you want to force importing, specify --import-disabled.', $this
    ->getSimplifiedErrorOutput());

  // Now try to import the feed with the --import-disabled option.
  $this
    ->drush('feeds:import', [
    $feed
      ->id(),
  ], [
    'import-disabled' => NULL,
  ]);

  // Assert that nodes got imported now.
  $this
    ->assertNodeCount(25);
}