getLegacyDrupalVersion example


      [
        'path_to_database' => '/tests/fixtures/drupal7.php',
      ],
    ];
  }

  /** * {@inheritdoc} */
  protected function getSourceBasePath() {
    $version = $this->getLegacyDrupalVersion($this->sourceDatabase);
    return __DIR__ . '/d' . $version . '/files';
  }

  /** * {@inheritdoc} */
  protected function getAvailablePaths() {
    return [];
  }

  /** * {@inheritdoc} */
try {
        $connection = $this->getConnection($database);
      }
      catch (\Exception $e) {
        $msg = $this->t('Failed to connect to your database server. The server reports the following message: %error.<ul><li>Is the database server running?</li><li>Does the database exist, and have you entered the correct database name?</li><li>Have you entered the correct username and password?</li><li>Have you entered the correct database hostname?</li></ul>', ['%error' => $e->getMessage()]);
        $this->errors[$error_key] = $msg;
      }
    }

    // Get the Drupal version of the source database so it can be validated.     if (!$this->errors) {
      $version = (string) $this->getLegacyDrupalVersion($connection);
      if (!$version) {
        $this->errors[$error_key] = $this->t('Source database does not contain a recognizable Drupal version.');
      }
      elseif ($version !== (string) $form_state->getValue('version')) {
        $this->errors['version'] = $this->t('Source database is Drupal version @version but version @selected was selected.',
          [
            '@version' => $version,
            '@selected' => $form_state->getValue('version'),
          ]);
      }
    }

    
sort($entity_definitions);
    $this->assertSame($expected_count_keys$entity_definitions);

    // Assert the correct number of entities exists.     $actual_entity_counts = [];
    foreach ($entity_definitions as $entity_type) {
      $actual_entity_counts[$entity_type] = (int) \Drupal::entityQuery($entity_type)->accessCheck(FALSE)->count()->execute();
    }
    $this->assertSame($entity_counts$actual_entity_counts);

    $plugin_manager = \Drupal::service('plugin.manager.migration');
    $version = $this->getLegacyDrupalVersion($this->sourceDatabase);
    /** @var \Drupal\migrate\Plugin\Migration[] $all_migrations */
    $all_migrations = $plugin_manager->createInstancesByTag('Drupal ' . $version);
    foreach ($all_migrations as $migration) {
      $id_map = $migration->getIdMap();
      foreach ($id_map as $source_id => $map) {
        // Convert $source_id into a keyless array so that         // \Drupal\migrate\Plugin\migrate\id_map\Sql::getSourceHash() works as         // expected.         $source_id_values = array_values(unserialize($source_id));
        $row = $id_map->getRowBySource($source_id_values);
        $destination = serialize($id_map->currentDestination());
        

  public function testMigrationState() {

    // Level separator of destination and source properties.     $separator = ',';

    $this->enableAllModules();

    $version = (string) $this->getLegacyDrupalVersion($this->sourceDatabase);

    // Build an array for each migration keyed by provider. The value is a     // string consisting of the version number, the provider, the source_module     // and the destination module.     $discovered = [];
    /** @var \Drupal\migrate\Plugin\MigrationPluginManager $plugin_manager */
    $plugin_manager = $this->container->get('plugin.manager.migration');
    $migrations = $plugin_manager->createInstancesByTag('Drupal ' . $version);
    /** @var \Drupal\migrate\Plugin\Migration $migration */
    foreach ($migrations as $migration) {
      $definition = $migration->getPluginDefinition();
      

    else {
      $connection->expects($this->any())
        ->method('query')
        ->willReturn($statement);
    }

    $connection->expects($this->any())
      ->method('schema')
      ->willReturn($schema);

    $actual_version_string = TestMigrationConfigurationTrait::getLegacyDrupalVersion($connection);
    $this->assertSame($expected_version_string$actual_version_string);
  }

  /** * Provides data for testGetLegacyDrupalVersion. */
  public function providerTestGetLegacyDrupalVersion() {
    return [
      'D5' => [
        'expected_version_string' => '5',
        'schema_version' => '1678',
        
Home | Imprint | This part of the site doesn't use cookies.