class ComponentsIsolatedBuildTest
Same name and namespace in other branches
- 11.x core/tests/Drupal/BuildTests/Composer/Component/ComponentsIsolatedBuildTest.php \Drupal\BuildTests\Composer\Component\ComponentsIsolatedBuildTest
- 10 core/tests/Drupal/BuildTests/Composer/Component/ComponentsIsolatedBuildTest.php \Drupal\BuildTests\Composer\Component\ComponentsIsolatedBuildTest
- 9 core/tests/Drupal/BuildTests/Composer/Component/ComponentsIsolatedBuildTest.php \Drupal\BuildTests\Composer\Component\ComponentsIsolatedBuildTest
Try to install dependencies per component, using Composer.
Attributes
#[CoversNothing]
#[Group('Composer')]
#[Group('Component')]
Hierarchy
- class \Drupal\Tests\DrupalTestCase uses \Drupal\Tests\DrupalTestCaseTrait extends \PHPUnit\Framework\TestCase
- class \Drupal\BuildTests\Framework\BuildTestBase uses \Drupal\TestTools\Extension\RequiresComposerTrait extends \Drupal\Tests\DrupalTestCase
- class \Drupal\BuildTests\Composer\ComposerBuildTestBase extends \Drupal\BuildTests\Framework\BuildTestBase
- class \Drupal\BuildTests\Composer\Component\ComponentsIsolatedBuildTest extends \Drupal\BuildTests\Composer\ComposerBuildTestBase
- class \Drupal\BuildTests\Composer\ComposerBuildTestBase extends \Drupal\BuildTests\Framework\BuildTestBase
- class \Drupal\BuildTests\Framework\BuildTestBase uses \Drupal\TestTools\Extension\RequiresComposerTrait extends \Drupal\Tests\DrupalTestCase
Expanded class hierarchy of ComponentsIsolatedBuildTest
File
-
core/
tests/ Drupal/ BuildTests/ Composer/ Component/ ComponentsIsolatedBuildTest.php, line 17
Namespace
Drupal\BuildTests\Composer\ComponentView source
class ComponentsIsolatedBuildTest extends ComposerBuildTestBase {
/**
* Test whether components' composer.json can be installed in isolation.
*/
public function testComponentComposerJson() : void {
// Only copy the components. Copy all of them because some of them depend on
// each other.
$finder = new Finder();
$finder->files()
->ignoreUnreadableDirs()
->in($this->getDrupalRoot() . static::$componentsPath)
->ignoreDotFiles(FALSE)
->ignoreVCS(FALSE);
$this->copyCodebase($finder->getIterator());
$component_paths = [];
// During the dataProvider phase, there is not a workspace directory yet.
// So we will find relative paths and assemble them with the workspace
// path later.
$drupal_root = self::getDrupalRootStatic();
$composer_json_finder = self::getComponentPathsFinder($drupal_root);
/** @var \Symfony\Component\Finder\SplFileInfo $path */
foreach ($composer_json_finder->getIterator() as $path) {
$component_paths[$path->getRelativePath()] = '/' . $path->getRelativePath();
}
// Adding composer path repositories for every component to every component
// is time consuming, so add a path repository for each component in
// parallel.
$repo_paths = $component_paths;
foreach ($repo_paths as $repo_path) {
$commands = [];
foreach ($component_paths as $component_path) {
$working_dir = $this->getWorkingPath() . static::$componentsPath . $component_path;
$package_name = 'drupal/core' . strtolower(preg_replace('/[A-Z]/', '-$0', substr($repo_path, 1)));
$path_repo = $this->getWorkingPath() . static::$componentsPath . $repo_path;
$repo_name = strtolower($repo_path);
// Add path repositories with the current version number to the current
// package under test.
$drupal_version = Composer::drupalVersionBranch();
$command_line = "composer repository add {$repo_name} " . "'{\"type\": \"path\",\"url\": \"{$path_repo}\",\"options\": {\"versions\": {\"{$package_name}\": \"{$drupal_version}\"}}}' --working-dir={$working_dir}";
$commands[$repo_path][$component_path] = Process::fromShellCommandline($command_line);
$commands[$repo_path][$component_path]->setWorkingDirectory($this->getWorkingPath($working_dir))
->setTimeout(360)
->setIdleTimeout(360);
$commands[$repo_path][$component_path]->start();
}
foreach ($component_paths as $component_path) {
if ($commands[$repo_path][$component_path]->isRunning()) {
$commands[$repo_path][$component_path]->wait();
}
}
}
foreach ($component_paths as $component_path) {
$working_dir = $this->getWorkingPath() . static::$componentsPath . $component_path;
// Perform the installation.
$this->executeCommand("COMPOSER_NO_SECURITY_BLOCKING=1 composer install --working-dir={$working_dir} --no-interaction --no-progress");
$this->assertCommandSuccessful();
}
}
}
Members
| Title Sort descending | Modifiers | Object type | Summary | Overrides |
|---|---|---|---|---|
| BuildTestBase::$commandProcess | private | property | The most recent command process. | |
| BuildTestBase::$destroyBuild | protected | property | Default to destroying build artifacts after a test finishes. | |
| BuildTestBase::$hostName | private static | property | Our native host name, used by PHP when it starts up the server. | |
| BuildTestBase::$hostPort | private | property | Port that will be tested. | |
| BuildTestBase::$mink | private | property | The Mink session manager. | |
| BuildTestBase::$phpFinder | private | property | The PHP executable finder. | |
| BuildTestBase::$portLocks | private | property | A list of ports used by the test. | |
| BuildTestBase::$serverDocroot | private | property | The docroot for the server process. | |
| BuildTestBase::$serverProcess | private | property | The process that's running the HTTP server. | |
| BuildTestBase::$workspaceDir | private | property | The working directory where this test will manipulate files. | |
| BuildTestBase::assertCommandExitCode | public | function | Asserts that the last command returned the specified exit code. | |
| BuildTestBase::assertCommandOutputContains | public | function | Assert that text is present in the output of the most recent command. | |
| BuildTestBase::assertCommandSuccessful | public | function | Asserts that the last command ran without error. | |
| BuildTestBase::assertDrupalVisit | public | function | Helper function to assert that the last visit was a Drupal site. | |
| BuildTestBase::assertErrorOutputContains | public | function | Assert that text is present in the error output of the most recent command. | |
| BuildTestBase::assertErrorOutputNotContains | public | function | Assert text is not present in the error output of the most recent command. | |
| BuildTestBase::checkPortIsAvailable | protected | function | Checks whether a port is available. | |
| BuildTestBase::copyCodebase | public | function | Copy the current working codebase into a workspace. | 1 |
| BuildTestBase::executeCommand | public | function | Run a command. | |
| BuildTestBase::findAvailablePort | protected | function | Discover an available port number. | |
| BuildTestBase::getCodebaseFinder | public | function | Get a default Finder object for a Drupal codebase. | |
| BuildTestBase::getComposerRoot | public | function | Gets the path to the Composer root directory. | |
| BuildTestBase::getDrupalRoot | public | function | Get the root path of this Drupal codebase. | |
| BuildTestBase::getDrupalRootStatic | public static | function | Get the root path of this Drupal codebase. | |
| BuildTestBase::getMink | public | function | Get the Mink instance. | |
| BuildTestBase::getPortNumber | protected | function | Get the port number for requests. | |
| BuildTestBase::getWorkingPath | protected | function | Get the working directory within the workspace, creating if necessary. | |
| BuildTestBase::getWorkingPathDrupalRoot | public | function | Gets the working path for Drupal core. | |
| BuildTestBase::getWorkspaceDirectory | public | function | Full path to the workspace where this test can build. | |
| BuildTestBase::getWorkspaceDrupalRoot | public | function | Gets the path to Drupal root in the workspace directory. | |
| BuildTestBase::initMink | protected | function | Set up the Mink session manager. | |
| BuildTestBase::instantiateServer | protected | function | Do the work of making a server process. | 1 |
| BuildTestBase::setUp | protected | function | 7 | |
| BuildTestBase::standUpServer | protected | function | Makes a local test server using PHP's internal HTTP server. | |
| BuildTestBase::stopServer | protected | function | Stop the HTTP server, zero out all necessary variables. | |
| BuildTestBase::tearDown | protected | function | 5 | |
| BuildTestBase::visit | public | function | Visit a URI on the HTTP server. | 1 |
| ComponentsIsolatedBuildTest::testComponentComposerJson | public | function | Test whether components' composer.json can be installed in isolation. | |
| ComposerBuildTestBase::$componentsPath | protected static | property | Relative path from Drupal root to the Components directory. | |
| ComposerBuildTestBase::assertDrupalVersion | protected | function | Assert that the VERSION constant in Drupal.php is the expected value. | |
| ComposerBuildTestBase::getComponentPathsFinder | protected static | function | Find all the composer.json files for components. | |
| DrupalTestCaseTrait::checkErrorHandlerOnTearDown | public | function | Checks the test error handler after test execution. | 1 |
| DrupalTestCaseTrait::setDebugDumpHandler | public static | function | Registers the dumper CLI handler when the DebugDump extension is enabled. | |
| RequiresComposerTrait::requiresComposer | public static | function | #[BeforeClass] |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.