ConstraintFactoryTest.php in Drupal 10
File
core/tests/Drupal/KernelTests/Core/Validation/ConstraintFactoryTest.php
View source
<?php
namespace Drupal\KernelTests\Core\Validation;
use Drupal\Component\Plugin\PluginBase;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\KernelTests\KernelTestBase;
use Symfony\Component\Validator\Constraint;
class ConstraintFactoryTest extends KernelTestBase {
protected static $modules = [
'entity_test',
];
public function testCreateInstance() {
$constraint_manager = \Drupal::typedDataManager()
->getValidationConstraintManager();
$this
->assertInstanceOf(Constraint::class, $constraint_manager
->create('Uuid', []));
$container_factory_plugin = $constraint_manager
->create('EntityTestContainerFactoryPlugin', []);
$this
->assertNotInstanceOf(Constraint::class, $container_factory_plugin);
$this
->assertInstanceOf(ContainerFactoryPluginInterface::class, $container_factory_plugin);
$default_plugin = $constraint_manager
->create('EntityTestDefaultPlugin', []);
$this
->assertNotInstanceOf(Constraint::class, $default_plugin);
$this
->assertNotInstanceOf(ContainerFactoryPluginInterface::class, $default_plugin);
$this
->assertInstanceOf(PluginBase::class, $default_plugin);
}
}