function RecipeTestTrait::createRecipe
Same name in other branches
- 10 core/tests/Drupal/FunctionalTests/Core/Recipe/RecipeTestTrait.php \Drupal\FunctionalTests\Core\Recipe\RecipeTestTrait::createRecipe()
Creates a recipe in a temporary directory.
Parameters
string|array<mixed> $data: The contents of recipe.yml. If passed as an array, will be encoded to YAML.
string|null $machine_name: The machine name for the recipe. Will be used as the directory name.
Return value
\Drupal\Core\Recipe\Recipe The recipe object.
19 calls to RecipeTestTrait::createRecipe()
- AddItemToToolbarConfigActionTest::testActionRequiresCKEditor5 in core/
modules/ ckeditor5/ tests/ src/ Kernel/ ConfigAction/ AddItemToToolbarConfigActionTest.php - AddItemToToolbarConfigActionTest::testAddItemToToolbar in core/
modules/ ckeditor5/ tests/ src/ Kernel/ ConfigAction/ AddItemToToolbarConfigActionTest.php - @testWith ["sourceEditing", ["heading", "bold", "italic", "sourceEditing"]] [{"item_name": "sourceEditing"}, ["heading", "bold", "italic",…
- AddItemToToolbarConfigActionTest::testAddNonExistentItem in core/
modules/ ckeditor5/ tests/ src/ Kernel/ ConfigAction/ AddItemToToolbarConfigActionTest.php - AddModerationConfigActionTest::createRecipe in core/
modules/ content_moderation/ tests/ src/ Kernel/ ConfigAction/ AddModerationConfigActionTest.php - AddToAllBundlesConfigActionTest::applyAction in core/
modules/ field/ tests/ src/ Kernel/ AddToAllBundlesConfigActionTest.php - Applies a recipe with the addToAllBundles action.
File
-
core/
tests/ Drupal/ FunctionalTests/ Core/ Recipe/ RecipeTestTrait.php, line 30
Class
- RecipeTestTrait
- Contains helper methods for interacting with recipes in functional tests.
Namespace
Drupal\FunctionalTests\Core\RecipeCode
protected function createRecipe(string|array $data, ?string $machine_name = NULL) : Recipe {
if (is_array($data)) {
$data = Yaml::encode($data);
}
$recipes_dir = $this->siteDirectory . '/recipes';
if ($machine_name === NULL) {
$dir = uniqid($recipes_dir . '/');
}
else {
$dir = $recipes_dir . '/' . $machine_name;
}
mkdir($dir, recursive: TRUE);
file_put_contents($dir . '/recipe.yml', $data);
return Recipe::createFromDirectory($dir);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.