getFieldInstanceStubMigrationDefinition example

/** * {@inheritdoc} */
  public function getEntityFields($core$entity_type_id) {
    return parent::getEntityFields($core$entity_type_id);
  }

  /** * {@inheritdoc} */
  public function getFieldInstanceStubMigrationDefinition($core) {
    return parent::getFieldInstanceStubMigrationDefinition($core);
  }

  /** * {@inheritdoc} */
  public function getCoreVersion(MigrationInterface $migration) {
    return parent::getCoreVersion($migration);
  }

  /** * {@inheritdoc} */
/** * Gets the source plugin to use to gather field information. * * @param string $core * The Drupal core version. * * @return array|\Drupal\migrate\Plugin\MigrateSourceInterface * The source plugin, or an empty array if none can be found that meets * requirements. */
  protected function getSourcePlugin($core) {
    $definition = $this->getFieldInstanceStubMigrationDefinition($core);
    $source_plugin = $this->migrationPluginManager
      ->createStubMigration($definition)
      ->getSourcePlugin();
    if ($source_plugin instanceof RequirementsInterface) {
      try {
        $source_plugin->checkRequirements();
      }
      catch (RequirementsException $e) {
        // If checkRequirements() failed, the source database did not support         // fields (i.e., Field is not installed in D7). Therefore, $fields will         // be empty and below we'll return an empty array. The migration will

  public function testGetFieldInstanceStubMigrationDefinition($core$expected_definition) {
    $field_discovery = new FieldDiscoveryTestClass($this->fieldPluginManager->reveal()$this->migrationPluginManager->reveal()$this->logger->reveal());
    if (!$expected_definition) {
      $this->expectException(\InvalidArgumentException::class);
      $this->expectExceptionMessage(sprintf("Drupal version %s is not supported. Valid values for Drupal core version are '6' and '7'.", $core));
    }
    $actual_definition = $field_discovery->getFieldInstanceStubMigrationDefinition($core);
    $this->assertSame($expected_definition$actual_definition);
  }

  /** * Provides data for testGetFieldInstanceStubMigrationDefinition. * * @return array * The data. */
  public function getFieldInstanceStubMigrationDefinition() {
    return [
      
Home | Imprint | This part of the site doesn't use cookies.