function UnknownPathExcluderTest::createTestProjectForTemplate
Creates a test project with or without a nested webroot.
Parameters
bool $use_nested_webroot: Whether to use a nested webroot.
3 calls to UnknownPathExcluderTest::createTestProjectForTemplate()
- UnknownPathExcluderTest::testExcluderCanBeDisabled in core/
modules/ package_manager/ tests/ src/ Kernel/ PathExcluder/ UnknownPathExcluderTest.php - Tests that the excluder can be disabled by a config flag.
- UnknownPathExcluderTest::testPathRepositoriesAreIncluded in core/
modules/ package_manager/ tests/ src/ Kernel/ PathExcluder/ UnknownPathExcluderTest.php - UnknownPathExcluderTest::testUnknownPath in core/
modules/ package_manager/ tests/ src/ Kernel/ PathExcluder/ UnknownPathExcluderTest.php - Tests that the unknown files and directories are excluded.
File
-
core/
modules/ package_manager/ tests/ src/ Kernel/ PathExcluder/ UnknownPathExcluderTest.php, line 36
Class
- UnknownPathExcluderTest
- @covers \Drupal\package_manager\PathExcluder\UnknownPathExcluder @group package_manager @internal
Namespace
Drupal\Tests\package_manager\Kernel\PathExcluderCode
protected function createTestProjectForTemplate(bool $use_nested_webroot) : void {
if (!$use_nested_webroot) {
// We are not using a nested webroot: the parent test project can be used.
parent::createTestProject();
}
else {
// Create another directory and copy its contents from fake_site fixture.
$fake_site_with_nested_webroot = DrupalFileSystem::getOsTemporaryDirectory() . DIRECTORY_SEPARATOR . 'fake_site_with_nested_webroot';
$fs = new Filesystem();
if (is_dir($fake_site_with_nested_webroot)) {
$fs->remove($fake_site_with_nested_webroot);
}
$fs->mkdir($fake_site_with_nested_webroot);
$fs->mirror(__DIR__ . '/../../../fixtures/fake_site', $fake_site_with_nested_webroot);
// Create a webroot directory in our new directory and copy all folders
// and files into it, except for ones that should always be in the
// project root.
$fs->mkdir($fake_site_with_nested_webroot . DIRECTORY_SEPARATOR . 'webroot');
$paths_in_project_root = glob("{$fake_site_with_nested_webroot}/*");
$keep_in_project_root = [
$fake_site_with_nested_webroot . '/vendor',
$fake_site_with_nested_webroot . '/webroot',
$fake_site_with_nested_webroot . '/composer.json',
$fake_site_with_nested_webroot . '/composer.lock',
$fake_site_with_nested_webroot . '/custom',
];
foreach ($paths_in_project_root as $path_in_project_root) {
if (!in_array($path_in_project_root, $keep_in_project_root, TRUE)) {
$fs->rename($path_in_project_root, $fake_site_with_nested_webroot . '/webroot' . str_replace($fake_site_with_nested_webroot, '', $path_in_project_root));
}
}
parent::createTestProject($fake_site_with_nested_webroot);
// We need to reset the test paths with our new webroot.
/** @var \Drupal\package_manager_bypass\MockPathLocator $path_locator */
$path_locator = $this->container
->get(PathLocator::class);
$path_locator->setPaths($path_locator->getProjectRoot(), $path_locator->getVendorDirectory(), 'webroot', $path_locator->getStagingRoot());
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.