public function testValidation(): void
{ $definition = DataDefinition::
create('string'
) ->
addConstraint('PluginExists', 'plugin.manager.action'
);
// An existing action plugin should pass validation.
$data =
$this->container->
get('typed_data_manager'
)->
create($definition);
$data->
setValue('action_test_save_entity'
);
$this->
assertCount(0,
$data->
validate());
// It should also pass validation if we check for an interface it actually
// implements.
$definition->
setConstraints([ 'PluginExists' =>
[ 'manager' => 'plugin.manager.action',
'interface' => ActionInterface::
class,
],
]);
$this->
assertCount(0,
$data->
validate());
// A non-existent plugin should be invalid, regardless of interface.
$data->
setValue('non_existent_plugin'
);
$violations =
$data->
validate();
$this->
assertCount(1,
$violations);