function ConfigValidationTest::testValidatableConfigIsValidated

Same name in other branches
  1. 10 core/tests/Drupal/KernelTests/Core/Recipe/ConfigValidationTest.php \Drupal\KernelTests\Core\Recipe\ConfigValidationTest::testValidatableConfigIsValidated()

Tests that the recipe runner only validates config which is validatable.

File

core/tests/Drupal/KernelTests/Core/Recipe/ConfigValidationTest.php, line 62

Class

ConfigValidationTest
@group Recipe

Namespace

Drupal\KernelTests\Core\Recipe

Code

public function testValidatableConfigIsValidated() : void {
    // Since config_test.types is not validatable, there should not be a
    // validation error.
    $recipe = $this->createRecipeWithInvalidDataInFile('config_test.types.yml');
    RecipeRunner::processRecipe($recipe);
    $this->assertFalse($this->config('config_test.types')
        ->isNew());
    // If we create a config object which IS fully validatable, and has invalid
    // data, we should get a validation error.
    $recipe = $this->createRecipeWithInvalidDataInFile('config_test.types.fully_validatable.yml');
    $this->expectException(InvalidConfigException::class);
    $this->expectExceptionMessage('There were validation errors in config_test.types.fully_validatable');
    RecipeRunner::processRecipe($recipe);
}

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