You are here

protected function ConfigInstallProfileUnmetDependenciesTest::setUp in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/config/src/Tests/ConfigInstallProfileUnmetDependenciesTest.php \Drupal\config\Tests\ConfigInstallProfileUnmetDependenciesTest::setUp()

Sets up a Drupal site for running functional and integration tests.

Installs Drupal with the installation profile specified in \Drupal\simpletest\WebTestBase::$profile into the prefixed database.

Afterwards, installs any additional modules specified in the static \Drupal\simpletest\WebTestBase::$modules property of each class in the class hierarchy.

After installation all caches are flushed and several configuration values are reset to the values of the parent site executing the test, since the default values may be incompatible with the environment in which tests are being executed.

Overrides InstallerTestBase::setUp

File

core/modules/config/src/Tests/ConfigInstallProfileUnmetDependenciesTest.php, line 35
Contains \Drupal\config\Tests\ConfigInstallProfileUnmetDependenciesTest.

Class

ConfigInstallProfileUnmetDependenciesTest
Tests install profile config overrides can not add unmet dependencies.

Namespace

Drupal\config\Tests

Code

protected function setUp() {

  // Copy the testing_config_overrides install profile so we can change the
  // configuration to include a dependency that can not be met. File API
  // functions are not available yet.
  $dest = $this->siteDirectory . '/profiles/testing_config_overrides';
  mkdir($dest, 0777, TRUE);
  $source = DRUPAL_ROOT . '/core/profiles/testing_config_overrides';
  $iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($source, \RecursiveDirectoryIterator::SKIP_DOTS), \RecursiveIteratorIterator::SELF_FIRST);
  foreach ($iterator as $item) {
    if ($item
      ->isDir()) {
      mkdir($dest . DIRECTORY_SEPARATOR . $iterator
        ->getSubPathName());
    }
    else {
      copy($item, $dest . DIRECTORY_SEPARATOR . $iterator
        ->getSubPathName());
    }
  }

  // Add a dependency that can not be met because User is installed before
  // Action.
  $config_file = $dest . DIRECTORY_SEPARATOR . InstallStorage::CONFIG_INSTALL_DIRECTORY . DIRECTORY_SEPARATOR . 'system.action.user_block_user_action.yml';
  $action = Yaml::decode(file_get_contents($config_file));
  $action['dependencies']['module'][] = 'action';
  file_put_contents($config_file, Yaml::encode($action));
  parent::setUp();
}