function RecipeTestTrait::alterRecipe

Alters an existing recipe.

Parameters

string $path: The recipe directory path.

callable $alter: A function that will receive the decoded contents of recipe.yml as an array. This should returned a modified array to be written to recipe.yml.

3 calls to RecipeTestTrait::alterRecipe()
ConfigConfiguratorTest::testExistingConfigIsIgnoredInLenientMode in core/tests/Drupal/KernelTests/Core/Recipe/ConfigConfiguratorTest.php
@testWith [false] [[]]
ConfigConfiguratorTest::testFullStrictness in core/tests/Drupal/KernelTests/Core/Recipe/ConfigConfiguratorTest.php
ConfigConfiguratorTest::testSelectiveStrictness in core/tests/Drupal/KernelTests/Core/Recipe/ConfigConfiguratorTest.php

File

core/tests/Drupal/FunctionalTests/Core/Recipe/RecipeTestTrait.php, line 109

Class

RecipeTestTrait
Contains helper methods for interacting with recipes in functional tests.

Namespace

Drupal\FunctionalTests\Core\Recipe

Code

protected function alterRecipe(string $path, callable $alter) : void {
    $file = $path . '/recipe.yml';
    $this->assertFileExists($file);
    $contents = file_get_contents($file);
    $contents = Yaml::decode($contents);
    $contents = $alter($contents);
    file_put_contents($file, Yaml::encode($contents));
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.