function RoleExistsConstraintValidatorTest::testValueMustBeAString

Tests that the constraint validator will only work with strings.

File

core/modules/user/tests/src/Kernel/Plugin/Validation/Constraint/RoleExistsConstraintValidatorTest.php, line 29

Class

RoleExistsConstraintValidatorTest
@group user @group Validation

Namespace

Drupal\Tests\user\Kernel\Plugin\Validation\Constraint

Code

public function testValueMustBeAString() : void {
    $definition = DataDefinition::create('any')->addConstraint('RoleExists');
    $this->expectException(UnexpectedTypeException::class);
    $this->expectExceptionMessage('Expected argument of type "string", "int" given');
    $this->container
        ->get('typed_data_manager')
        ->create($definition, 39)
        ->validate();
}

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