getMigrationTags example


  public function testGetCoreVersion(array $tags$expected_result) {
    $migration = $this->prophesize(MigrationInterface::class);
    $migration->getMigrationTags()->willReturn($tags);
    $field_discovery = new FieldDiscoveryTestClass($this->fieldPluginManager->reveal()$this->migrationPluginManager->reveal()$this->logger->reveal());
    if (!$expected_result) {
      $this->expectException(\InvalidArgumentException::class);
    }
    $actual_result = $field_discovery->getCoreVersion($migration->reveal());
    $this->assertEquals($expected_result$actual_result);
  }

  /** * Provides data for testGetCoreVersion() * * @return array * The test data. */
if (preg_match($patterns$key)) {
        unset($all_migrations[$key]);
      }
    }

    $migrations = [];
    foreach ($all_migrations as $migration) {
      // Skip migrations tagged with any of the follow-up migration tags. They       // will be derived and executed after the migrations on which they depend       // have been successfully executed.       // @see Drupal\migrate_drupal\Plugin\MigrationWithFollowUpInterface       if (!empty(array_intersect($migration->getMigrationTags()$this->getFollowUpMigrationTags()))) {
        continue;
      }

      try {
        // @todo https://drupal.org/node/2681867 We should be able to validate         // the entire migration at this point.         $source_plugin = $migration->getSourcePlugin();
        if ($source_plugin instanceof RequirementsInterface) {
          $source_plugin->checkRequirements();
        }
        $destination_plugin = $migration->getDestinationPlugin();
        

  protected function assertCategories(array $migrations): void {
    foreach ($migrations as $id => $migration) {
      $object_classes = class_parents($migration->getDestinationPlugin());
      $object_classes[] = get_class($migration->getDestinationPlugin());

      // Ensure that the destination plugin is an instance of at least one of       // the expected classes.       if (in_array('Configuration', $migration->getMigrationTags(), TRUE)) {
        $this->assertNotEmpty(array_intersect($object_classes$this->getConfigurationClasses()), "The migration $id is tagged as Configuration.");
      }
      elseif (in_array('Content', $migration->getMigrationTags(), TRUE)) {
        $this->assertNotEmpty(array_intersect($object_classes$this->getContentClasses()), "The migration $id is tagged as Content.");
      }
      else {
        $this->fail("The migration $id is not tagged as either 'Content' or 'Configuration'.");
      }
    }
  }

  

  protected function getCoreVersion(MigrationInterface $migration) {
    $tags = $migration->getMigrationTags();
    if (in_array('Drupal 7', $tags, TRUE)) {
      return FieldDiscoveryInterface::DRUPAL_7;
    }
    elseif (in_array('Drupal 6', $tags, TRUE)) {
      return FieldDiscoveryInterface::DRUPAL_6;
    }
    throw new \InvalidArgumentException("Drupal Core version not found for this migration");
  }

}
Home | Imprint | This part of the site doesn't use cookies.