public function DrushCommandsTest::testDrush in Migrate Tools 8.5
Same name and namespace in other branches
- 8.4 tests/src/Functional/DrushCommandsTest.php \Drupal\Tests\migrate_tools\Functional\DrushCommandsTest::testDrush()
Tests many of the migrate drush commands.
File
- tests/
src/ Functional/ DrushCommandsTest.php, line 89
Class
- DrushCommandsTest
- Execute drush on fully functional website.
Namespace
Drupal\Tests\migrate_tools\FunctionalCode
public function testDrush() : void {
$this
->drush('ms', [], [], NULL, NULL, 1);
$this
->assertStringContainsString('The "does_not_exist" plugin does not exist.', $this
->getErrorOutput());
$this->container
->get('config.factory')
->getEditable('migrate_plus.migration.invalid_plugin')
->delete();
// Flush cache so the recently removed invalid migration is cleared.
drupal_flush_all_caches();
$this
->drush('ms', [], [
'format' => 'json',
]);
$expected = [
[
'group' => 'Default (default)',
'id' => 'fruit_terms',
'imported' => 0,
'status' => 'Idle',
'total' => 3,
'unprocessed' => 3,
'last_imported' => '',
],
[
'group' => 'Default (default)',
'id' => 'source_exception',
'imported' => 0,
'status' => 'Idle',
'total' => 0,
'unprocessed' => 0,
'last_imported' => '',
],
];
$this
->assertEquals($expected, $this
->getOutputFromJSON());
$this
->drush('mim', [
'fruit_terms',
]);
$this
->assertStringContainsString('1/3', $this
->getErrorOutput());
$this
->assertStringContainsString('3/3', $this
->getErrorOutput());
$this
->assertStringContainsString('[notice] Processed 3 items (3 created, 0 updated, 0 failed, 0 ignored) - done with \'fruit_terms\'', $this
->getErrorOutput());
$this
->assertStringNotContainsString('4', $this
->getErrorOutput());
$this
->drush('mim', [
'fruit_terms',
], [
'update' => NULL,
'force' => NULL,
'execute-dependencies' => NULL,
]);
$this
->assertStringContainsString('1/3', $this
->getErrorOutput());
$this
->assertStringContainsString('3/3', $this
->getErrorOutput());
$this
->assertStringContainsString('[notice] Processed 3 items (0 created, 3 updated, 0 failed, 0 ignored) - done with \'fruit_terms\'', $this
->getErrorOutput());
$this
->assertStringNotContainsString('4', $this
->getErrorOutput());
$this
->drush('mrs', [
'fruit_terms',
]);
$this
->assertErrorOutputEquals('[warning] Migration fruit_terms is already Idle');
$this
->drush('mfs', [
'fruit_terms',
], [
'format' => 'json',
]);
$expected = [
[
'machine_name' => 'name',
'description' => 'name',
],
];
$this
->assertEquals($expected, $this
->getOutputFromJSON());
$this
->drush('mr', [
'fruit_terms',
]);
$this
->assertStringContainsString('1/3', $this
->getErrorOutput());
$this
->assertStringContainsString('3/3', $this
->getErrorOutput());
$this
->assertStringContainsString('[notice] Rolled back 3 items - done with \'fruit_terms\'', $this
->getErrorOutput());
$this
->assertStringNotContainsString('4', $this
->getErrorOutput());
$this
->drush('migrate:stop', [
'fruit_terms',
]);
$this
->assertErrorOutputEquals('[warning] Migration fruit_terms is idle');
$this
->drush('mim', [
'fruit_terms',
], [
'skip-progress-bar' => NULL,
]);
$this
->assertErrorOutputEquals('[notice] Processed 3 items (3 created, 0 updated, 0 failed, 0 ignored) - done with \'fruit_terms\'');
$this
->drush('mr', [
'fruit_terms',
], [
'skip-progress-bar' => NULL,
]);
$this
->assertErrorOutputEquals('[notice] Rolled back 3 items - done with \'fruit_terms\'');
}