function ImmutablePropertiesConstraintValidatorTest::testValidatorRequiresAConfigEntity

Same name and namespace in other branches
  1. 11.x core/tests/Drupal/KernelTests/Core/Entity/ImmutablePropertiesConstraintValidatorTest.php \Drupal\KernelTests\Core\Entity\ImmutablePropertiesConstraintValidatorTest::testValidatorRequiresAConfigEntity()

Tests that only config entities are accepted by the validator.

File

core/tests/Drupal/KernelTests/Core/Entity/ImmutablePropertiesConstraintValidatorTest.php, line 32

Class

ImmutablePropertiesConstraintValidatorTest
@group Entity @group Validation

Namespace

Drupal\KernelTests\Core\Entity

Code

public function testValidatorRequiresAConfigEntity() : void {
  $definition = DataDefinition::createFromDataType('any')->addConstraint('ImmutableProperties', [
    'read_only',
  ]);
  $data = $this->container
    ->get(TypedDataManagerInterface::class)
    ->create($definition, 39);
  $this->expectException(UnexpectedValueException::class);
  $this->expectExceptionMessage('Expected argument of type "' . ConfigEntityInterface::class . '", "int" given');
  $data->validate();
}

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