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

Issue #3322917 by tedbow, yash.rode, Wim Leers, narendraR: Create a test (or...

Issue #3322917 by tedbow, yash.rode, Wim Leers, narendraR: Create a test (or tests) to prove Package Manager works with submodules as implemented by packages.drupal.org
parent b277cf09
No related branches found
No related tags found
1 merge request!981Issue #3322917 metapackage test
{
"name": "drupal/main_module",
"type": "drupal-module",
"version": "1.0.0"
}
name: Main module
type: module
core_version_requirement: ^9 || ^10
project: main_module
name: Main Module Submodule
type: module
core_version_requirement: ^9 || ^10
project: main_module
{
"name": "drupal/main_module_submodule",
"type": "metapackage",
"version": "1.0.0",
"require": {
"drupal/main_module": "*"
}
}
<?xml version="1.0" encoding="utf-8"?>
<!--
This fixture is used by \Drupal\Tests\package_manager\Build\PackageInstallTest.
Contains metadata about the following (fake) releases of main_module, all of which are secure, in order:
- 1.0.0
-->
<project xmlns:dc="http://purl.org/dc/elements/1.1/">
<title>Main Module</title>
<short_name>main_module</short_name>
<dc:creator>Drupal</dc:creator>
<supported_branches>1.0.</supported_branches>
<project_status>published</project_status>
<link>http://example.com/project/main_module</link>
<terms>
<term><name>Projects</name><value>Main Module project</value></term>
</terms>
<releases>
<release>
<name>Main Module 1.0.0</name>
<version>1.0.0</version>
<tag>1.0.0</tag>
<status>published</status>
<release_link>http://example.com/main_module-1-0-0-release</release_link>
<download_link>http://example.com/main_module-1-0-0.tar.gz</download_link>
<date>1584195300</date>
<terms>
<term><name>Release type</name><value>New features</value></term>
<term><name>Release type</name><value>Bug fixes</value></term>
</terms>
</release>
</releases>
</project>
......@@ -44,4 +44,47 @@ class PackageInstallTest extends TemplateProjectTestBase {
$this->assertAppliedChangesWereLogged(['Installed drupal/alpha 1.0.0']);
}
/**
* Tests installing a Drupal submodule.
*
* This test installs a submodule using a set-up that mimics how
* packages.drupal.org handles submodules. Submodules are Composer
* metapackages which depend on the Composer package of the main module.
*/
public function testSubModules(): void {
$this->createTestProject('RecommendedProject');
// Set up the release metadata for the main module. The submodule does not
// have its own release metadata.
$this->setReleaseMetadata([
'main_module' => __DIR__ . '/../../fixtures/release-history/main_module.1.0.0.xml',
]);
// Add repositories for Drupal modules which will contain the code for its
// submodule also.
$this->addRepository('main_module', $this->copyFixtureToTempDirectory(__DIR__ . '/../../fixtures/build_test_projects/main_module'));
// Add a repository for the submodule of 'main_module'. Submodule
// repositories are metapackages which have no code of their own but that
// require the main module.
$this->addRepository('main_module_submodule', $this->copyFixtureToTempDirectory(__DIR__ . '/../../fixtures/path_repos/main_module_submodule'));
// Repository definitions affect the lock file hash, so update the hash to
// ensure that Composer won't complain that the lock file is out of sync.
$this->runComposer('composer update --lock', 'project');
$this->makePackageManagerTestApiRequest(
'/package-manager-test-api',
[
'runtime' => [
'drupal/main_module_submodule:1.0.0',
],
]
);
// Assert main_module and the submodule were installed.
$main_module_path = $this->getWebRoot() . '/modules/contrib/main_module';
$this->assertFileExists("$main_module_path/main_module.info.yml");
$this->assertFileExists("$main_module_path/main_module_submodule/main_module_submodule.info.yml");
}
}
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