function configMergeTest::setUpStagingWorkflow

7.x configMergeTest.php configMergeTest::setUpStagingWorkflow($sites)
1 call to configMergeTest::setUpStagingWorkflow()


tests/configMergeTest.php, line 206
Test config-merge, that merges configuration changes from one site to another.




@group slow @group commands


function setUpStagingWorkflow($sites) {

  // Copy settings.php from sites/dev to sites/default.
  $dev_settings = file_get_contents($sites['dev']['root'] . '/sites/' . $sites['dev']['uri'] . '/settings.php');
  $sites['dev']['uri'] = 'default';
  file_put_contents($sites['dev']['root'] . '/sites/' . $sites['dev']['uri'] . '/settings.php', $dev_settings);

  // Rewrite the alias file for the dev site
  $this->writeSiteAlias('dev', $sites['dev']['root'], 'default');

  // Create a site alias for the staging site.
  $sites['stage']['root'] = $sites['dev']['root'] . '-stage';
  $sites['stage']['uri'] = 'default';
  $sites['stage']['db_url'] = str_replace('dev', 'stage', $sites['dev']['db_url']);
  $this->writeSiteAlias('stage', $sites['stage']['root'], 'default');

  // Create a root directory for the staging site

  // Write a .gitignore file for the dev site, to ignore settings.php and the files/php directory.
  file_put_contents($sites['dev']['root'] . '/.gitignore', "sites/default/settings.php\nsites/default/files/php");
  // Make a git repository for the dev site.

  // We have to check out the files in the 'stage' site from
  // the git repository of the 'dev' site so that we can
  // use git to transfer configuration.

  // make a bare repository, push the dev site up to it, and clone from there.
  $central_repo = dirname($sites['dev']['root']) . '/repository.git';
  mkdir($central_repo, 0777, TRUE);
  $this->execute("git init --bare", CommandUnishTestCase::EXIT_SUCCESS, $central_repo);
  $this->execute("git remote add origin file://" . $central_repo . " && git push origin master", CommandUnishTestCase::EXIT_SUCCESS, $sites['dev']['root']);
  $this->execute("git clone file://" . $central_repo . " " . $sites['stage']['root']);
  $this->execute("git config '' && git config 'Unish'", CommandUnishTestCase::EXIT_SUCCESS, $sites['stage']['root']);

  // Change the db settings in $stage_settings
  $stage_settings = str_replace("_dev", "_stage", $dev_settings);
  file_put_contents($sites['stage']['root'] . '/sites/default/settings.php', $stage_settings);

  // Both sites must be based off of the same install; otherwise, the uuids
  // for the initial configuration items will not match, which will cause
  // problems.
  $this->drush('sql-sync', array('@self', '@stage'), $sites['dev'] + array('yes' => NULL, 'strict' => 0));

  return $sites;