function GitExcluderTest::testGitDirectoriesExcludedStage
Same name and namespace in other branches
- 11.x core/modules/package_manager/tests/src/Kernel/PathExcluder/GitExcluderTest.php \Drupal\Tests\package_manager\Kernel\PathExcluder\GitExcluderTest::testGitDirectoriesExcludedStage()
Tests that Git directories are excluded from active during PreApply.
File
-
core/
modules/ package_manager/ tests/ src/ Kernel/ PathExcluder/ GitExcluderTest.php, line 102
Class
- GitExcluderTest
- Tests Git Excluder.
Namespace
Drupal\Tests\package_manager\Kernel\PathExcluderCode
public function testGitDirectoriesExcludedStage() : void {
// Ensure we have an up-to-date container.
$this->container = $this->container
->get('kernel')
->rebuildContainer();
$this->getStageFixtureManipulator()
->removePackage('foo/package_known_to_composer_removed_later');
$stage = $this->createStage();
$stage->create();
$stage->require([
'ext-json:*',
]);
$stage_dir = $stage->getSandboxDirectory();
// Adding a module with .git in stage which is unknown to composer, we
// expect it to not be copied to the active directory.
$path = "{$stage_dir}/modules/unknown_to_composer_in_stage";
$fs = new Filesystem();
$fs->mkdir("{$path}/.git");
file_put_contents("{$path}/unknown_to_composer.info.yml", Yaml::encode([
'name' => 'Unknown to composer in stage',
'type' => 'module',
'core_version_requirement' => '^9.7 || ^10',
]));
file_put_contents("{$path}/.git/excluded.txt", 'Phoenix!');
$stage->apply();
/** @var \Drupal\package_manager_bypass\LoggingCommitter $committer */
$committer = $this->container
->get(CommitterInterface::class);
$committer_args = $committer->getInvocationArguments();
$excluded_paths = [
'.git',
'modules/module_not_known_to_composer_in_active/.git',
'modules/example/.git',
];
// We are missing "modules/unknown_to_composer_in_stage/.git" in excluded
// paths because there is no validation for it as it is assumed about any
// new .git folder in stage directory that either composer is aware of it or
// the developer knows what they are doing.
foreach ($excluded_paths as $excluded_path) {
$this->assertContains($excluded_path, $committer_args[0][2]);
}
$this->assertNotContains('modules/unknown_to_composer_in_stage/.git', $committer_args[0][2]);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.