function NoFieldItemsExistWithHigherCardinalityTest::testValidOptions

Tests the constraint initialization with valid options.

File

core/modules/field/tests/src/Unit/Plugin/Validation/Constraint/NoFieldItemsExistWithHigherCardinalityTest.php, line 23

Class

NoFieldItemsExistWithHigherCardinalityTest
Tests the NoFieldItemsExistWithHigherCardinality constraint.

Namespace

Drupal\Tests\field\Unit\Plugin\Validation\Constraint

Code

public function testValidOptions() : void {
  $options = [
    'entityType' => 'node',
    'fieldName' => 'field_test',
  ];
  $constraint = new NoFieldItemsExistWithHigherCardinality(entityType: $options['entityType'], fieldName: $options['fieldName']);
  $this->assertEquals('node', $constraint->entityType);
  $this->assertEquals('field_test', $constraint->fieldName);
  $this->assertEquals("The field '@field_name' of entity type '@entity_type' has more entries (@max_delta) than the cardinality (@cardinality) allows.", $constraint->message);
}

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