function RecipeRunnerTest::testConfigActionsPreExistingConfig
Same name in other branches
- 11.x core/tests/Drupal/KernelTests/Core/Recipe/RecipeRunnerTest.php \Drupal\KernelTests\Core\Recipe\RecipeRunnerTest::testConfigActionsPreExistingConfig()
File
-
core/
tests/ Drupal/ KernelTests/ Core/ Recipe/ RecipeRunnerTest.php, line 182
Class
- RecipeRunnerTest
- @coversDefaultClass \Drupal\Core\Recipe\RecipeRunner @group Recipe
Namespace
Drupal\KernelTests\Core\RecipeCode
public function testConfigActionsPreExistingConfig() : void {
$this->enableModules([
'config_test',
]);
$this->installConfig([
'config_test',
]);
$this->assertSame('bar', $this->config('config_test.system')
->get('foo'));
$storage = \Drupal::entityTypeManager()->getStorage('config_test');
$config_test_entity = $storage->create([
'id' => 'recipe',
'label' => 'Created by test',
]);
$this->assertInstanceOf(ConfigTest::class, $config_test_entity);
$config_test_entity->setProtectedProperty('Set by test');
$config_test_entity->save();
$recipe = Recipe::createFromDirectory('core/tests/fixtures/recipes/config_actions');
RecipeRunner::processRecipe($recipe);
// Test the state after to applying the recipe.
$config_test_entity = $storage->load('recipe');
$this->assertInstanceOf(ConfigTest::class, $config_test_entity);
$this->assertSame('Created by test', $config_test_entity->label());
$this->assertSame('Set by recipe', $config_test_entity->getProtectedProperty());
$this->assertSame('not bar', $this->config('config_test.system')
->get('foo'));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.