class ConstraintFactoryTest
Same name and namespace in other branches
- 11.x core/tests/Drupal/KernelTests/Core/Validation/ConstraintFactoryTest.php \Drupal\KernelTests\Core\Validation\ConstraintFactoryTest
- 10 core/tests/Drupal/KernelTests/Core/Validation/ConstraintFactoryTest.php \Drupal\KernelTests\Core\Validation\ConstraintFactoryTest
@coversDefaultClass \Drupal\Core\Validation\ConstraintFactory
@group Validation
Hierarchy
- class \Drupal\KernelTests\KernelTestBase extends \Drupal\Core\DependencyInjection\ServiceProviderInterface uses \Drupal\KernelTests\AssertLegacyTrait, \Drupal\KernelTests\AssertContentTrait, \Drupal\Tests\RandomGeneratorTrait, \Drupal\Tests\ConfigTestTrait, \Drupal\Tests\ExtensionListTestTrait, \Drupal\Tests\TestRequirementsTrait, \Drupal\Tests\Traits\PhpUnitWarnings, \Drupal\Tests\PhpUnitCompatibilityTrait, \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait implements \PHPUnit\Framework\TestCase
- class \Drupal\KernelTests\Core\Validation\ConstraintFactoryTest implements \Drupal\KernelTests\KernelTestBase
Expanded class hierarchy of ConstraintFactoryTest
File
-
core/
tests/ Drupal/ KernelTests/ Core/ Validation/ ConstraintFactoryTest.php, line 15
Namespace
Drupal\KernelTests\Core\ValidationView source
class ConstraintFactoryTest extends KernelTestBase {
/**
* {@inheritdoc}
*/
protected static $modules = [
'entity_test',
];
/**
* @covers ::createInstance
*/
public function testCreateInstance() {
$constraint_manager = \Drupal::typedDataManager()->getValidationConstraintManager();
// If the plugin is a \Symfony\Component\Validator\Constraint, they will be
// created first.
$this->assertInstanceOf(Constraint::class, $constraint_manager->create('Uuid', []));
// If the plugin implements the
// \Drupal\Core\Plugin\ContainerFactoryPluginInterface, they will be created
// second.
$container_factory_plugin = $constraint_manager->create('EntityTestContainerFactoryPlugin', []);
$this->assertNotInstanceOf(Constraint::class, $container_factory_plugin);
$this->assertInstanceOf(ContainerFactoryPluginInterface::class, $container_factory_plugin);
// Plugins that are not a \Symfony\Component\Validator\Constraint or do not
// implement the \Drupal\Core\Plugin\ContainerFactoryPluginInterface are
// created last.
$default_plugin = $constraint_manager->create('EntityTestDefaultPlugin', []);
$this->assertNotInstanceOf(Constraint::class, $default_plugin);
$this->assertNotInstanceOf(ContainerFactoryPluginInterface::class, $default_plugin);
$this->assertInstanceOf(PluginBase::class, $default_plugin);
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.