예제 #1
0
 /**
  * Test the complete Drupal migration.
  */
 public function testDrupal()
 {
     $dumps = $this->getDumps();
     $this->loadDumps($dumps);
     $classes = $this->getTestClassesList();
     $extension_install_storage = new ExtensionInstallStorage(\Drupal::service('config.storage'), InstallStorage::CONFIG_OPTIONAL_DIRECTORY, StorageInterface::DEFAULT_COLLECTION, TRUE);
     foreach ($classes as $class) {
         if (is_subclass_of($class, '\\Drupal\\migrate\\Tests\\MigrateDumpAlterInterface')) {
             $class::migrateDumpAlter($this);
         }
     }
     // Run every migration in the order specified by the storage controller.
     foreach (entity_load_multiple('migration', static::$migrations) as $migration) {
         (new MigrateExecutable($migration, $this))->import();
         // Ensure that the default migration has the correct dependencies.
         list($base_name, ) = explode(':', $migration->id(), 2);
         $default_configuration = $extension_install_storage->read('migrate.migration.' . $base_name);
         $default_dependencies = isset($default_configuration['dependencies']) ? $default_configuration['dependencies'] : [];
         $this->assertEqual($default_dependencies, $migration->getDependencies(), SafeMarkup::format('Dependencies in @id match after installing. Default configuration @first is equal to active configuration @second.', array('@id' => $migration->id(), '@first' => var_export($default_dependencies, TRUE), '@second' => var_export($migration->getDependencies(), TRUE))));
     }
     foreach ($classes as $class) {
         $test_object = new $class($this->testId);
         $test_object->databasePrefix = $this->databasePrefix;
         $test_object->container = $this->container;
         // run() does a lot of setup and tear down work which we don't need:
         // it would setup a new database connection and wouldn't find the
         // Drupal dump. Also by skipping the setUp() methods there are no id
         // mappings or entities prepared. The tests run against solely migrated
         // data.
         foreach (get_class_methods($test_object) as $method) {
             if (strtolower(substr($method, 0, 4)) == 'test') {
                 // Insert a fail record. This will be deleted on completion to ensure
                 // that testing completed.
                 $method_info = new \ReflectionMethod($class, $method);
                 $caller = array('file' => $method_info->getFileName(), 'line' => $method_info->getStartLine(), 'function' => $class . '->' . $method . '()');
                 $completion_check_id = TestBase::insertAssert($this->testId, $class, FALSE, 'The test did not complete due to a fatal error.', 'Completion check', $caller);
                 // Run the test method.
                 try {
                     $test_object->{$method}();
                 } catch (\Exception $e) {
                     $this->exceptionHandler($e);
                 }
                 // Remove the completion check record.
                 TestBase::deleteAssert($completion_check_id);
             }
         }
         // Add the pass/fail/exception/debug results.
         foreach ($this->results as $key => &$value) {
             $value += $test_object->results[$key];
         }
     }
 }
예제 #2
0
 /**
  * {@inheritdoc}
  */
 public function getFromExtension($type, $name)
 {
     $full_name = $this->getFullName($type, $name);
     $value = $this->extensionConfigStorage->read($full_name);
     if (!$value) {
         $value = $this->extensionOptionalConfigStorage->read($full_name);
     }
     return $value;
 }
예제 #3
0
 /**
  * Returns a list of the install storage items for an extension.
  *
  * @param string $type
  *   Type of extension ('module', etc.).
  * @param string $name
  *   Machine name of extension.
  * @param bool $do_optional
  *   FALSE (default) to list config/install items, TRUE to list
  *   config/optional items.
  *
  * @return string[]
  *   List of config items provided by this extension.
  */
 protected function listProvidedItems($type, $name, $do_optional = FALSE)
 {
     $pathname = drupal_get_filename($type, $name);
     $component = new Extension(\Drupal::root(), $type, $pathname);
     if ($do_optional) {
         $names = $this->extensionOptionalConfigStorage->getComponentNames(array($component));
     } else {
         $names = $this->extensionConfigStorage->getComponentNames(array($component));
     }
     return array_keys($names);
 }
예제 #4
0
 /**
  * {@inheritdoc}
  */
 public function installCollectionDefaultConfig($collection)
 {
     $storage = new ExtensionInstallStorage($this->getActiveStorages(StorageInterface::DEFAULT_COLLECTION), InstallStorage::CONFIG_INSTALL_DIRECTORY, $collection, $this->drupalInstallationAttempted());
     // Only install configuration for enabled extensions.
     $enabled_extensions = $this->getEnabledExtensions();
     $config_to_install = array_filter($storage->listAll(), function ($config_name) use($enabled_extensions) {
         $provider = Unicode::substr($config_name, 0, strpos($config_name, '.'));
         return in_array($provider, $enabled_extensions);
     });
     if (!empty($config_to_install)) {
         $this->createConfiguration($collection, $storage->readMultiple($config_to_install));
         // Reset all the static caches and list caches.
         $this->configFactory->reset();
     }
 }
 /**
  * Overrides \Drupal\Core\Config\ExtensionInstallStorage::__construct().
  *
  * Sets includeProfile to FALSE.
  *
  * @param \Drupal\Core\Config\StorageInterface $config_storage
  *   The active configuration store where the list of installed modules and
  *   themes is stored.
  * @param string $directory
  *   The directory to scan in each extension to scan for files. Defaults to
  *   'config/install'.
  * @param string $collection
  *   (optional) The collection to store configuration in. Defaults to the
  *   default collection.
  */
 public function __construct(StorageInterface $config_storage, $directory = self::CONFIG_INSTALL_DIRECTORY, $collection = StorageInterface::DEFAULT_COLLECTION)
 {
     parent::__construct($config_storage, $directory, $collection, FALSE);
 }
 /**
  * {@inheritdoc}
  */
 public function __construct(StorageInterface $config_storage, $directory = self::CONFIG_INSTALL_DIRECTORY, $collection = StorageInterface::DEFAULT_COLLECTION, $include_profile = TRUE)
 {
     parent::__construct($config_storage, $directory, $collection, $include_profile);
     $this->directory = 'override_config';
 }
예제 #7
0
 /**
  * {@inheritdoc}
  */
 public function createBundleFromDefault($machine_name, $name = NULL, $description = NULL, $is_profile = FALSE, $profile_name = NULL)
 {
     // Duplicate the default bundle to get its default configuration.
     $default = $this->getBundle(FeaturesBundleInterface::DEFAULT_BUNDLE);
     if (!$default) {
         // If we don't have the default installed, generate it from the install
         // config file.
         $ext_storage = new ExtensionInstallStorage($this->configStorage);
         $record = $ext_storage->read('features.bundle.default');
         $bundle_storage = $this->entityManager->getStorage('features_bundle');
         $default = $bundle_storage->createFromStorageRecord($record);
     }
     /** @var \Drupal\features\Entity\FeaturesBundle $bundle */
     $bundle = $default->createDuplicate();
     $bundle->setMachineName($machine_name);
     $bundle->setName($name);
     if (isset($description)) {
         $bundle->setDescription($description);
     } else {
         $bundle->setDescription(t('Auto-generated bundle from package @name', array('@name' => $name)));
     }
     $bundle->setIsProfile($is_profile);
     if (isset($profile_name)) {
         $bundle->setProfileName($profile_name);
     }
     $bundle->save();
     $this->setBundle($bundle);
     return $bundle;
 }