function FieldConfigValidationTest::testEntityReferenceSelectionHandlerIsValidated

Same name in other branches
  1. 11.x core/modules/field/tests/src/Kernel/Entity/FieldConfigValidationTest.php \Drupal\Tests\field\Kernel\Entity\FieldConfigValidationTest::testEntityReferenceSelectionHandlerIsValidated()

Tests that entity reference selection handler plugin IDs are validated.

File

core/modules/field/tests/src/Kernel/Entity/FieldConfigValidationTest.php, line 175

Class

FieldConfigValidationTest
Tests validation of field_config entities.

Namespace

Drupal\Tests\field\Kernel\Entity

Code

public function testEntityReferenceSelectionHandlerIsValidated() : void {
    $this->container
        ->get('state')
        ->set('field_test_disable_broken_entity_reference_handler', TRUE);
    $this->enableModules([
        'field_test',
    ]);
    // The `field_type` property is immutable, so we need to clone the entity in
    // order to cleanly change its immutable properties.
    $this->entity = $this->entity
        ->createDuplicate()
        ->set('field_type', 'entity_reference')
        ->set('settings', [
        'handler' => 'non_existent',
    ]);
    $this->assertValidationErrors([
        'settings.handler' => "The 'non_existent' plugin does not exist.",
    ]);
}

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