function EntityMethodConfigActionsTest::testSetPropertiesWillNotChangeEntityKeys

Tests that the setProperties action refuses to modify entity IDs or UUIDs.

@testWith ["id"] ["uuid"]

File

core/tests/Drupal/KernelTests/Core/Recipe/EntityMethodConfigActionsTest.php, line 238

Class

EntityMethodConfigActionsTest
@group Recipe

Namespace

Drupal\KernelTests\Core\Recipe

Code

public function testSetPropertiesWillNotChangeEntityKeys(string $key) : void {
    $view_display = $this->container
        ->get(EntityDisplayRepositoryInterface::class)
        ->getViewDisplay('entity_test_with_bundle', 'test');
    $this->assertFalse($view_display->isNew());
    $property_name = $view_display->getEntityType()
        ->getKey($key);
    $this->assertNotEmpty($property_name);
    $this->expectException(ConfigActionException::class);
    $this->expectExceptionMessage("Entity key '{$property_name}' cannot be changed by the setProperties config action.");
    $this->configActionManager
        ->applyAction('setProperties', $view_display->getConfigDependencyName(), [
        $property_name => '12345',
    ]);
}

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