You are here

public function MigrationGroupTest::testDelete in Migrate Plus 8.4

Same name and namespace in other branches
  1. 8.5 tests/src/Kernel/MigrationGroupTest.php \Drupal\Tests\migrate_plus\Kernel\MigrationGroupTest::testDelete()
  2. 8.2 tests/src/Kernel/MigrationGroupTest.php \Drupal\Tests\migrate_plus\Kernel\MigrationGroupTest::testDelete()
  3. 8.3 tests/src/Kernel/MigrationGroupTest.php \Drupal\Tests\migrate_plus\Kernel\MigrationGroupTest::testDelete()

Test that deleting a group deletes its migrations.

File

tests/src/Kernel/MigrationGroupTest.php, line 99

Class

MigrationGroupTest
Test migration groups.

Namespace

Drupal\Tests\migrate_plus\Kernel

Code

public function testDelete() {

  /** @var \Drupal\migrate_plus\Entity\MigrationGroupInterface $migration_group */
  $group_configuration = [
    'id' => 'test_group',
  ];
  $migration_group = $this->container
    ->get('entity_type.manager')
    ->getStorage('migration_group')
    ->create($group_configuration);
  $migration_group
    ->save();

  /** @var \Drupal\migrate_plus\Entity\MigrationInterface $migration */
  $migration = $this->container
    ->get('entity_type.manager')
    ->getStorage('migration')
    ->create([
    'id' => 'specific_migration',
    'migration_group' => 'test_group',
    'migration_tags' => [],
    'load' => [],
    'destination' => [],
    'source' => [],
    'migration_dependencies' => [],
  ]);
  $migration
    ->save();

  /** @var \Drupal\migrate_plus\Entity\MigrationGroupInterface $loaded_migration_group */
  $loaded_migration_group = MigrationGroup::load('test_group');
  $loaded_migration_group
    ->delete();

  /** @var \Drupal\migrate_plus\Entity\MigrationInterface $loaded_migration */
  $loaded_migration = Migration::load('specific_migration');
  $this
    ->assertNull($loaded_migration);
}