function FieldStorageConfigEntityUnitTest::testInvalidEnforcedCardinality
Same name in other branches
- 9 core/modules/field/tests/src/Unit/FieldStorageConfigEntityUnitTest.php \Drupal\Tests\field\Unit\FieldStorageConfigEntityUnitTest::testInvalidEnforcedCardinality()
- 8.9.x core/modules/field/tests/src/Unit/FieldStorageConfigEntityUnitTest.php \Drupal\Tests\field\Unit\FieldStorageConfigEntityUnitTest::testInvalidEnforcedCardinality()
- 11.x 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 178
Class
- FieldStorageConfigEntityUnitTest
- @coversDefaultClass \Drupal\field\Entity\FieldStorageConfig
Namespace
Drupal\Tests\field\UnitCode
public function testInvalidEnforcedCardinality($enforced_cardinality) : void {
$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();
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.