function TemplateProjectTestBase::runComposer
Runs a Composer command and returns its output.
Always asserts that the command was executed successfully.
Parameters
string $command: The command to execute, including the `composer` invocation.
string|null $working_dir: (optional) A working directory relative to the workspace, within which to execute the command. Defaults to the workspace directory.
bool $json: (optional) Whether to parse the command's output as JSON before returning it. Defaults to FALSE.
Return value
mixed|string|null The command's output, optionally parsed as JSON.
5 calls to TemplateProjectTestBase::runComposer()
- PackageInstallTest::testPackageInstall in core/
modules/ package_manager/ tests/ src/ Build/ PackageInstallTest.php - Tests installing packages in a stage directory.
- PackageInstallTest::testSubModules in core/
modules/ package_manager/ tests/ src/ Build/ PackageInstallTest.php - Tests installing a Drupal submodule.
- PackageUpdateTest::testPackageUpdate in core/
modules/ package_manager/ tests/ src/ Build/ PackageUpdateTest.php - Tests updating packages in a stage directory.
- TemplateProjectTestBase::addRepository in core/
modules/ package_manager/ tests/ src/ Build/ TemplateProjectTestBase.php - Adds a path repository to the test site.
- TemplateProjectTestBase::createTestProject in core/
modules/ package_manager/ tests/ src/ Build/ TemplateProjectTestBase.php - Creates a test project from a given template and installs Drupal.
File
-
core/
modules/ package_manager/ tests/ src/ Build/ TemplateProjectTestBase.php, line 514
Class
- TemplateProjectTestBase
- Base class for tests which create a test site from a core project template.
Namespace
Drupal\Tests\package_manager\BuildCode
protected function runComposer(string $command, ?string $working_dir = NULL, bool $json = FALSE) {
$process = $this->executeCommand($command, $working_dir);
$this->assertCommandSuccessful();
$output = trim($process->getOutput());
if ($json) {
$output = json_decode($output, TRUE, flags: JSON_THROW_ON_ERROR);
}
return $output;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.