public function FieldStorageConfigEntityUnitTest::testInvalidEnforcedCardinality in Drupal 10
Same name and namespace in other branches
- 8 core/modules/field/tests/src/Unit/FieldStorageConfigEntityUnitTest.php \Drupal\Tests\field\Unit\FieldStorageConfigEntityUnitTest::testInvalidEnforcedCardinality()
- 9 core/modules/field/tests/src/Unit/FieldStorageConfigEntityUnitTest.php \Drupal\Tests\field\Unit\FieldStorageConfigEntityUnitTest::testInvalidEnforcedCardinality()
Tests invalid enforced cardinality.
@covers ::getCardinality @dataProvider providerInvalidEnforcedCardinality
Parameters
mixed $enforced_cardinality: Enforced cardinality
File
- core/
modules/ field/ tests/ src/ Unit/ FieldStorageConfigEntityUnitTest.php, line 179 - Contains \Drupal\Tests\field\Unit\FieldStorageConfigEntityUnitTest.
Class
- FieldStorageConfigEntityUnitTest
- @coversDefaultClass \Drupal\field\Entity\FieldStorageConfig
Namespace
Drupal\Tests\field\UnitCode
public function testInvalidEnforcedCardinality($enforced_cardinality) {
$this->fieldTypeManager
->expects($this
->any())
->method('getDefinition')
->with('test_field_type')
->willReturn([
'class' => TestFieldType::class,
'cardinality' => $enforced_cardinality,
]);
$field_storage = new FieldStorageConfig([
'entity_type' => 'entity_test',
'field_name' => 'test_field',
'type' => 'test_field_type',
'module' => 'test_module',
]);
$this
->expectException(FieldException::class);
$this
->expectExceptionMessage("Invalid enforced cardinality '{$enforced_cardinality}'. Allowed values: a positive integer or -1.");
$field_storage
->getCardinality();
}