function RecipeTestTrait::applyRecipe
Same name in other branches
- 10 core/tests/Drupal/FunctionalTests/Core/Recipe/RecipeTestTrait.php \Drupal\FunctionalTests\Core\Recipe\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.
13 calls to RecipeTestTrait::applyRecipe()
- CoreRecipesTest::testApplyRecipe in core/
tests/ Drupal/ FunctionalTests/ Core/ Recipe/ CoreRecipesTest.php - Test the recipe apply.
- 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.
- RecipeCommandTest::testExceptionOnRollback in core/
tests/ Drupal/ FunctionalTests/ Core/ Recipe/ RecipeCommandTest.php - Tests that errors during config rollback won't steamroll validation errors.
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 {
assert($this instanceof BrowserTestBase);
$arguments = [
(new PhpExecutableFinder())->find(),
'core/scripts/drupal',
$command,
// Never apply recipes interactively.
'--no-interaction',
$options,
$path,
];
$process = (new Process($arguments))->setWorkingDirectory($this->getDrupalRoot())
->setEnv([
'DRUPAL_DEV_SITE_PATH' => $this->siteDirectory,
// Ensure that the command boots Drupal into a state where it knows it's
// a test site.
// @see drupal_valid_test_ua()
'HTTP_USER_AGENT' => drupal_generate_test_ua($this->databasePrefix),
])
->setTimeout(500);
$process->run();
$this->assertSame($expected_exit_code, $process->getExitCode(), $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()
$this->rebuildAll();
return $process;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.