You are here

public function MigrationGroupTest::testDelete in Migrate Plus 8

Test that deleting a group deletes its migrations.

File

src/Tests/MigrationGroupTest.php, line 103
Contains \Drupal\migrate_plus\Tests\MigrationGroupTest.

Class

MigrationGroupTest
Test migration groups.

Namespace

Drupal\migrate_plus\Tests

Code

public function testDelete() {

  /** @var MigrationGroupInterface $migration_group */
  $migration_group = entity_create('migration_group', array());
  $migration_group
    ->set('id', 'test_group');
  $migration_group
    ->save();

  /** @var MigrationInterface $migration */
  $migration = entity_create('migration', [
    'id' => 'specific_migration',
    'third_party_settings' => [
      'migrate_plus' => [
        'migration_group' => 'test_group',
      ],
    ],
    'migration_tags' => array(),
    'load' => [],
    'destination' => array(),
    'source' => array(),
  ]);
  $migration
    ->save();

  /** @var MigrationGroupInterface $loaded_migration_group */
  $loaded_migration_group = entity_load('migration_group', 'test_group', TRUE);
  $loaded_migration_group
    ->delete();

  /** @var MigrationGroupInterface $loaded_migration */
  $loaded_migration = entity_load('migration', 'specific_migration', TRUE);
  $this
    ->assertNull($loaded_migration);
}