Skip to content
Snippets Groups Projects
Commit 5ac879de authored by Ted Bowman's avatar Ted Bowman
Browse files

Issue #3273407 by tedbow: Move 'addRepository()' to TemplateProjectTestBase class

parent 9ce9b7bf
No related branches found
No related tags found
No related merge requests found
...@@ -115,25 +115,4 @@ class PackageUpdateTest extends TemplateProjectTestBase { ...@@ -115,25 +115,4 @@ class PackageUpdateTest extends TemplateProjectTestBase {
$this->assertSame($expected_post_apply_results, $results['post']); $this->assertSame($expected_post_apply_results, $results['post']);
} }
/**
* Adds a path repository to the test site.
*
* @param string $name
* An arbitrary name for the repository.
* @param string $path
* The path of the repository. Must exist in the file system.
*/
private function addRepository(string $name, string $path): void {
$this->assertDirectoryExists($path);
$repository = json_encode([
'type' => 'path',
'url' => $path,
'options' => [
'symlink' => FALSE,
],
]);
$this->runComposer("composer config repo.$name '$repository'", 'project');
}
} }
...@@ -113,6 +113,29 @@ END; ...@@ -113,6 +113,29 @@ END;
return $packages; return $packages;
} }
/**
* Adds a path repository to the test site.
*
* @param string $name
* An arbitrary name for the repository.
* @param string $path
* The path of the repository. Must exist in the file system.
* @param string $working_directory
* (optional) The Composer working directory. Defaults to 'project'.
*/
protected function addRepository(string $name, string $path, $working_directory = 'project'): void {
$this->assertDirectoryExists($path);
$repository = json_encode([
'type' => 'path',
'url' => $path,
'options' => [
'symlink' => FALSE,
],
], JSON_UNESCAPED_SLASHES);
$this->runComposer("composer config repo.$name '$repository'", $working_directory);
}
/** /**
* Creates a test project from a given template and installs Drupal. * Creates a test project from a given template and installs Drupal.
* *
...@@ -142,15 +165,7 @@ END; ...@@ -142,15 +165,7 @@ END;
// symlinking, we need to pass the JSON representations of the repositories // symlinking, we need to pass the JSON representations of the repositories
// to `composer config`. // to `composer config`.
foreach ($this->getCorePackages() as $name => $path) { foreach ($this->getCorePackages() as $name => $path) {
$repository = [ $this->addRepository($name, $path, $template_dir);
'type' => 'path',
'url' => $path,
'options' => [
'symlink' => FALSE,
],
];
$repository = json_encode($repository, JSON_UNESCAPED_SLASHES);
$this->runComposer("composer config repo.$name '$repository'", $template_dir);
} }
// Add a local Composer repository with all third-party dependencies. // Add a local Composer repository with all third-party dependencies.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment