function ConfigEntityValidationTestBase::testImmutableProperties
Same name in other branches
- 10 core/tests/Drupal/KernelTests/Core/Config/ConfigEntityValidationTestBase.php \Drupal\KernelTests\Core\Config\ConfigEntityValidationTestBase::testImmutableProperties()
Tests that immutable properties cannot be changed.
Parameters
mixed[] $valid_values: (optional) The values to set for the immutable properties, keyed by name. This should be used if the immutable properties can only accept certain values, e.g. valid plugin IDs.
12 calls to ConfigEntityValidationTestBase::testImmutableProperties()
- ActionValidationTest::testImmutableProperties in core/
modules/ system/ tests/ src/ Kernel/ Entity/ ActionValidationTest.php - Tests that immutable properties cannot be changed.
- BaseFieldOverrideValidationTest::testImmutableProperties in core/
tests/ Drupal/ KernelTests/ Core/ Entity/ BaseFieldOverrideValidationTest.php - Tests that immutable properties cannot be changed.
- ContentLanguageSettingsValidationTest::testImmutableProperties in core/
modules/ language/ tests/ src/ Kernel/ ContentLanguageSettingsValidationTest.php - Tests that immutable properties cannot be changed.
- EditorValidationTest::testImmutableProperties in core/
modules/ editor/ tests/ src/ Kernel/ EditorValidationTest.php - Tests that immutable properties cannot be changed.
- EntityFormDisplayValidationTest::testImmutableProperties in core/
tests/ Drupal/ KernelTests/ Core/ Entity/ EntityFormDisplayValidationTest.php - Tests that immutable properties cannot be changed.
12 methods override ConfigEntityValidationTestBase::testImmutableProperties()
- ActionValidationTest::testImmutableProperties in core/
modules/ system/ tests/ src/ Kernel/ Entity/ ActionValidationTest.php - Tests that immutable properties cannot be changed.
- BaseFieldOverrideValidationTest::testImmutableProperties in core/
tests/ Drupal/ KernelTests/ Core/ Entity/ BaseFieldOverrideValidationTest.php - Tests that immutable properties cannot be changed.
- ContentLanguageSettingsValidationTest::testImmutableProperties in core/
modules/ language/ tests/ src/ Kernel/ ContentLanguageSettingsValidationTest.php - Tests that immutable properties cannot be changed.
- EditorValidationTest::testImmutableProperties in core/
modules/ editor/ tests/ src/ Kernel/ EditorValidationTest.php - Tests that immutable properties cannot be changed.
- EntityFormDisplayValidationTest::testImmutableProperties in core/
tests/ Drupal/ KernelTests/ Core/ Entity/ EntityFormDisplayValidationTest.php - Tests that immutable properties cannot be changed.
File
-
core/
tests/ Drupal/ KernelTests/ Core/ Config/ ConfigEntityValidationTestBase.php, line 473
Class
- ConfigEntityValidationTestBase
- Base class for testing validation of config entities.
Namespace
Drupal\KernelTests\Core\ConfigCode
public function testImmutableProperties(array $valid_values = []) : void {
$constraints = $this->entity
->getEntityType()
->getConstraints();
$this->assertNotEmpty($constraints['ImmutableProperties'], 'All config entities should have at least one immutable ID property.');
foreach ($constraints['ImmutableProperties'] as $property_name) {
$original_value = $this->entity
->get($property_name);
$this->entity
->set($property_name, $valid_values[$property_name] ?? $this->randomMachineName());
$this->assertValidationErrors([
'' => "The '{$property_name}' property cannot be changed.",
]);
$this->entity
->set($property_name, $original_value);
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.