You are here

public function DrushCommandsTest::testContinueOnFailure in Migrate Tools 8.4

Same name and namespace in other branches
  1. 8.5 tests/src/Functional/DrushCommandsTest.php \Drupal\Tests\migrate_tools\Functional\DrushCommandsTest::testContinueOnFailure()

Test that migrations continue after a failure if the option is set.

File

tests/src/Functional/DrushCommandsTest.php, line 60

Class

DrushCommandsTest
Execute drush on fully functional website.

Namespace

Drupal\Tests\migrate_tools\Functional

Code

public function testContinueOnFailure() {

  // Option not set, fruit_terms should not run.
  $this
    ->drush('mim', [
    'invalid_plugin,fruit_terms',
  ], [], NULL, NULL, 1);
  $this
    ->assertNotContains("done with 'fruit_terms'", $this
    ->getErrorOutput());

  // Option set, fruit_terms should run.
  $this
    ->drush('mim', [
    'invalid_plugin,fruit_terms',
  ], [
    'continue-on-failure' => NULL,
  ]);
  $this
    ->assertContains("done with 'fruit_terms'", $this
    ->getErrorOutput());

  // Option not set, fruit_terms should not run.
  $this
    ->drush('mr', [
    'invalid_plugin,fruit_terms',
  ], [], NULL, NULL, 1);
  $this
    ->assertNotContains("done with 'fruit_terms'", $this
    ->getErrorOutput());

  // Option set, fruit_terms should run.
  $this
    ->drush('mr', [
    'invalid_plugin,fruit_terms',
  ], [
    'continue-on-failure' => NULL,
  ]);
  $this
    ->assertContains("done with 'fruit_terms'", $this
    ->getErrorOutput());

  // Option not set, fruit_terms should not display.
  $this
    ->drush('ms', [
    'invalid_plugin,fruit_terms',
  ], [
    'format' => 'json',
  ], NULL, NULL, 1);

  // This demonstrates we surface the exception but not as an error.
  $this
    ->assertNotContains('[error]  The "does_not_exist" plugin does not exist', $this
    ->getErrorOutput());
  $this
    ->assertContains('The "does_not_exist" plugin does not exist', $this
    ->getErrorOutput());
  $this
    ->assertNotContains('fruit_terms    Idle     3', $this
    ->getOutput());

  // Option set, fruit_terms should display.
  $this
    ->drush('ms', [
    'invalid_plugin,fruit_terms',
  ], [
    'continue-on-failure' => NULL,
  ]);
  $this
    ->assertContains('[error]  The "does_not_exist" plugin does not exist', $this
    ->getErrorOutput());
  $this
    ->assertContains('fruit_terms    Idle     3', $this
    ->getOutput());
}