function ClassResolverConstraintValidatorTest::testNonExistingMethod
Test missing method case.
Tests that the ClassResolver constraint throws an exception when the method does not exist.
File
-
core/
tests/ Drupal/ KernelTests/ Core/ TypedData/ ClassResolverConstraintValidatorTest.php, line 114
Class
- ClassResolverConstraintValidatorTest
- Tests ClassResolver validation constraint with both valid and invalid values.
Namespace
Drupal\KernelTests\Core\TypedDataCode
public function testNonExistingMethod() : void {
$definition = DataDefinition::create('integer')->addConstraint('ClassResolver', [
'classOrService' => 'test.service',
'method' => 'missingMethod',
]);
$typed_data = $this->typedData
->create($definition, 1);
$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage('The method "missingMethod" does not exist on the service "test.service".');
$typed_data->validate();
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.