function ConstraintFactoryTest::providerCreateInstanceBackwardsCompatibility
Data provider for testAddConstraintBackwardsCompatibility().
File
-
core/
tests/ Drupal/ KernelTests/ Core/ Validation/ ConstraintFactoryTest.php, line 100
Class
Namespace
Drupal\KernelTests\Core\ValidationCode
public static function providerCreateInstanceBackwardsCompatibility() : iterable {
// Passing non-associative array options should still instantiate the
// constraint plugin correctly, but also trigger deprecations.
yield [
'ExtensionName',
ExtensionNameConstraint::class,
'/.*/',
'pattern',
ExtensionDiscovery::PHP_FUNCTION_PATTERN,
];
$not_blank = new NotBlank();
yield [
'Sequentially',
SequentiallyConstraint::class,
[
$not_blank,
],
'constraints',
[
$not_blank,
],
];
yield [
'Optional',
OptionalConstraint::class,
[
$not_blank,
],
'constraints',
[
$not_blank,
],
];
yield [
'Required',
RequiredConstraint::class,
[
$not_blank,
],
'constraints',
[
$not_blank,
],
];
yield [
'AtLeastOneOf',
AtLeastOneOfConstraint::class,
[
$not_blank,
],
'constraints',
[
$not_blank,
],
];
yield [
'AllowedValues',
AllowedValuesConstraint::class,
[
0,
1,
],
'choices',
[
0,
1,
],
];
yield [
'RequiredConfigDependencies',
RequiredConfigDependenciesConstraint::class,
[
'node',
],
'entityTypes',
[
'node',
],
];
yield [
'EntityHasField',
EntityHasFieldConstraint::class,
'field_test',
'field_name',
'field_test',
];
yield [
'Bundle',
BundleConstraint::class,
'article',
'bundle',
'article',
];
yield [
'Bundle',
BundleConstraint::class,
[
'article',
'page',
],
'bundle',
[
'article',
'page',
],
];
yield [
'EntityType',
EntityTypeConstraint::class,
'node',
'type',
'node',
];
yield [
'ImmutableProperties',
ImmutablePropertiesConstraint::class,
[
'test1',
'test2',
],
'properties',
[
'test1',
'test2',
],
];
yield [
'ExtensionAvailable',
ExtensionAvailableConstraint::class,
'module',
'type',
'module',
];
yield [
'ExtensionExists',
ExtensionExistsConstraint::class,
'module',
'type',
'module',
];
yield [
'EntityBundleExists',
EntityBundleExistsConstraint::class,
'node',
'entityTypeId',
'node',
];
yield [
'ValidKeys',
ValidKeysConstraint::class,
'key1',
'allowedKeys',
'key1',
];
yield [
'ValidKeys',
ValidKeysConstraint::class,
[
'key1',
'key2',
],
'allowedKeys',
[
'key1',
'key2',
],
];
yield [
'FileExtension',
FileExtensionConstraint::class,
'gif|jpg',
'extensions',
'gif|jpg',
];
yield [
'FileSizeLimit',
FileSizeLimitConstraint::class,
100,
'fileLimit',
100,
];
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.