getMigrations example


  protected function setupMigrations(Connection $connection$version, array $database, FormStateInterface $form_state) {
    $this->createDatabaseStateSettings($database$version);
    $migrations = $this->getMigrations('migrate_drupal_' . $version$version);

    // Get the system data from source database.     $system_data = $this->getSystemData($connection);

    // Convert the migration object into array     // so that it can be stored in form storage.     $migration_array = [];
    foreach ($migrations as $migration) {
      $migration_array[$migration->id()] = $migration->label();
    }

    
static::assertInstanceOf(MigrationCollection::class$collection);
        static::assertSame('core.V6_3', $collection->getName());
        static::assertContainsOnlyInstancesOf(MigrationStep::class$collection->getMigrationSteps());
        static::assertGreaterThan(1, \count($collection->getMigrationSteps()));
    }

    public function testItLoadsTheValidMigrations(): void
    {
        $collection = $this->loader->collect('_test_migrations_valid');
        $collection->sync();

        $migrations = $this->getMigrations();

        $migrationsObjects = [];
        foreach ($migrations as $migration) {
            $migrationsObjects[] = new $migration['class']();
        }

        static::assertCount(2, $migrationsObjects);
        static::assertNull($migrations[0]['update']);
        static::assertNull($migrations[0]['update_destructive']);
        static::assertNull($migrations[0]['message']);
        static::assertNotNull($migrations[0]['class']);
        
while ($generator->valid()) {
            $generator->next();
            ++$cnt;
        }

        static::assertSame(2, $cnt);
    }

    public function testItWorksWithASingleMigration(): void
    {
        $migrations = $this->getMigrations();
        static::assertNull($migrations[0]['update']);
        static::assertNull($migrations[0]['update_destructive']);
        static::assertNull($migrations[1]['update']);
        static::assertNull($migrations[1]['update_destructive']);

        static::assertCount(1, $this->validMigrationCollection->migrateInPlace(null, 1));

        $migrations = $this->getMigrations();
        static::assertNotNull($migrations[0]['update']);
        static::assertNull($migrations[0]['update_destructive']);
        static::assertNull($migrations[1]['update']);
        
Home | Imprint | This part of the site doesn't use cookies.