Пример #1
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;
 }
Пример #2
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];
         }
     }
 }
Пример #3
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;
 }