function RecipeTestTrait::applyRecipe
Applies a recipe to the site.
Parameters
string $path: The path of the recipe to apply. Must be a directory.
int $expected_exit_code: The expected exit code of the `drupal recipe` process. Defaults to 0, which indicates that no error occurred.
string[] $options: (optional) Additional options to pass to the `drupal recipe` command.
string $command: (optional) The name of the command to run. Defaults to `recipe`.
Return value
\Symfony\Component\Process\Process The `drupal recipe` command process, after having run.
14 calls to RecipeTestTrait::applyRecipe()
- ContentExportTest::setUp in core/
tests/ Drupal/ FunctionalTests/ DefaultContent/ ContentExportTest.php - ContentImportTest::setUp in core/
tests/ Drupal/ FunctionalTests/ DefaultContent/ ContentImportTest.php - GenericRecipeTestBase::doApply in core/
modules/ system/ tests/ src/ Functional/ Recipe/ GenericRecipeTestBase.php - Applies the recipe under test.
- RecipeCommandTest::testDefaultInputValueFromConfig in core/
tests/ Drupal/ FunctionalTests/ Core/ Recipe/ RecipeCommandTest.php - RecipeCommandTest::testErrorOnNonExistentDirectory in core/
tests/ Drupal/ FunctionalTests/ Core/ Recipe/ RecipeCommandTest.php - Tests the recipe command with a non-existent directory.
File
-
core/
tests/ Drupal/ FunctionalTests/ Core/ Recipe/ RecipeTestTrait.php, line 63
Class
- RecipeTestTrait
- Contains helper methods for interacting with recipes in functional tests.
Namespace
Drupal\FunctionalTests\Core\RecipeCode
protected function applyRecipe(string $path, int $expected_exit_code = 0, array $options = [], string $command = 'recipe') : Process {
$process = $this->runDrupalCommand([
$command,
// Never apply recipes interactively.
'--no-interaction',
$options,
$path,
]);
$this->assertSame($expected_exit_code, $process->getExitCode(), sprintf("Process exit code mismatch.\nExpected: %d\nActual: %d\n\nSTDOUT:\n%s\n\nSTDERR:\n%s", $expected_exit_code, $process->getExitCode(), $process->getOutput(), $process->getErrorOutput()));
// Applying a recipe:
// - creates new checkpoints, hence the "state" service in the test runner
// is outdated
// - may install modules, which would cause the entire container in the test
// runner to be outdated.
// Hence the entire environment must be rebuilt for assertions to target the
// actual post-recipe-application result.
// @see \Drupal\Core\Config\Checkpoint\LinearHistory::__construct()
assert($this instanceof BrowserTestBase);
$this->rebuildAll();
return $process;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.