function ConstraintFactoryTest::testAdditionalConstraintBackwardsCompatibility

Same name and namespace in other branches
  1. 11.x core/tests/Drupal/KernelTests/Core/Validation/ConstraintFactoryTest.php \Drupal\KernelTests\Core\Validation\ConstraintFactoryTest::testAdditionalConstraintBackwardsCompatibility()

Tests for backwards compatibility when creating specific other plugins.

Attributes

#[IgnoreDeprecations]

File

core/tests/Drupal/KernelTests/Core/Validation/ConstraintFactoryTest.php, line 134

Class

ConstraintFactoryTest
Tests Drupal\Core\Validation\ConstraintFactory.

Namespace

Drupal\KernelTests\Core\Validation

Code

public function testAdditionalConstraintBackwardsCompatibility() : void {
  $constraint_manager = \Drupal::typedDataManager()->getValidationConstraintManager();
  $constraint = $constraint_manager->create('PluginExists', 'entity_type.manager');
  $this->assertInstanceOf(PluginExistsConstraint::class, $constraint);
  $this->assertSame($constraint->pluginManager, \Drupal::entityTypeManager());
  $this->expectDeprecation('Passing any non-associative-array options to configure constraint plugin "PluginExists" is deprecated in drupal:11.4.0 and will not be supported in drupal:12.0.0. See https://www.drupal.org/node/3554746');
  $this->expectDeprecation('Passing the "value" option in configuration to Drupal\\Core\\Plugin\\Plugin\\Validation\\Constraint\\PluginExistsConstraint::create is deprecated in drupal:11.4.0 and will not be supported in drupal:12.0.0. See https://www.drupal.org/node/3554746');
  $constraint = $constraint_manager->create('ComplexData', [
    'value' => [
      'NotBlank' => [],
    ],
  ]);
  $this->assertInstanceOf(ComplexDataConstraint::class, $constraint);
  $this->assertInstanceOf(NotBlank::class, $constraint->properties['value']['NotBlank']);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.