// Make a copy of the code to alter in the workspace directory.
$this->
copyCodebase();
// Tests are typically run on "-dev" versions, but we want to simulate
// running them on a tagged release at the same stability as specified in
// static::MINIMUM_STABILITY, in order to verify that everything will work
// if/when we make such a release.
$simulated_core_version = \Drupal::VERSION;
$simulated_core_version_suffix =
(static::MINIMUM_STABILITY === 'stable' ? '' : '-' .
static::MINIMUM_STABILITY . '99'
);
$simulated_core_version =
str_replace('-dev',
$simulated_core_version_suffix,
$simulated_core_version);
Composer::
setDrupalVersion($this->
getWorkspaceDirectory(),
$simulated_core_version);
$this->
assertDrupalVersion($simulated_core_version,
$this->
getWorkspaceDirectory());
// Remove the packages.drupal.org entry (and any other custom repository)
// from the SUT's repositories section. There is no way to do this via
// `composer config --unset`, so we read and rewrite composer.json.
$composer_json_path =
$this->
getWorkspaceDirectory() . "/
$package_dir/composer.json";
$composer_json =
json_decode(file_get_contents($composer_json_path), TRUE
);
unset($composer_json['repositories'
]);
$json =
json_encode($composer_json, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES
);
file_put_contents($composer_json_path,
$json);