function SimpleConfigValidationTest::testInvalidPluginId

Same name in other branches
  1. 10 core/tests/Drupal/KernelTests/Core/Config/SimpleConfigValidationTest.php \Drupal\KernelTests\Core\Config\SimpleConfigValidationTest::testInvalidPluginId()

Tests that plugin IDs in simple config are validated.

@testWith ["system.mail", "interface.0"] ["system.image", "toolkit"]

Parameters

string $config_name: The name of the config object to validate.

string $property: The property path to set. This will receive the value 'non_existent' and is expected to raise a "plugin does not exist" error.

File

core/tests/Drupal/KernelTests/Core/Config/SimpleConfigValidationTest.php, line 164

Class

SimpleConfigValidationTest
Tests validation of certain elements common to all config.

Namespace

Drupal\KernelTests\Core\Config

Code

public function testInvalidPluginId(string $config_name, string $property) : void {
    $config = $this->config($config_name);
    $violations = $this->container
        ->get('config.typed')
        ->createFromNameAndData($config_name, $config->set($property, 'non_existent')
        ->get())
        ->validate();
    $this->assertCount(1, $violations);
    $this->assertSame($property, $violations[0]->getPropertyPath());
    $this->assertSame("The 'non_existent' plugin does not exist.", (string) $violations[0]->getMessage());
}

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