function RecipeRunnerTest::testApplySameRecipe

Same name in other branches
  1. 11.x core/tests/Drupal/KernelTests/Core/Recipe/RecipeRunnerTest.php \Drupal\KernelTests\Core\Recipe\RecipeRunnerTest::testApplySameRecipe()

File

core/tests/Drupal/KernelTests/Core/Recipe/RecipeRunnerTest.php, line 86

Class

RecipeRunnerTest
@coversDefaultClass \Drupal\Core\Recipe\RecipeRunner @group Recipe

Namespace

Drupal\KernelTests\Core\Recipe

Code

public function testApplySameRecipe() : void {
    // Test the state prior to applying the recipe.
    $this->assertEmpty($this->container
        ->get('config.factory')
        ->listAll('node.'), 'There is no node configuration');
    $recipe = Recipe::createFromDirectory('core/tests/fixtures/recipes/install_node_with_config');
    RecipeRunner::processRecipe($recipe);
    // Test the state prior to applying the recipe.
    $this->assertNotEmpty($this->container
        ->get('config.factory')
        ->listAll('node.'), 'There is node configuration');
    $recipe = Recipe::createFromDirectory('core/tests/fixtures/recipes/install_node_with_config');
    RecipeRunner::processRecipe($recipe);
    $this->assertTrue(TRUE, 'Applying a recipe for the second time with no config changes results in a successful application');
    $type = NodeType::load('test');
    $type->setNewRevision(FALSE);
    $type->save();
    $this->expectException(RecipePreExistingConfigException::class);
    $this->expectExceptionMessage("The configuration 'node.type.test' exists already and does not match the recipe's configuration");
    Recipe::createFromDirectory('core/tests/fixtures/recipes/install_node_with_config');
}

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