public function BaseFieldDefinitionTest::testFieldCardinality in Drupal 10
Same name and namespace in other branches
- 8 core/tests/Drupal/Tests/Core/Entity/BaseFieldDefinitionTest.php \Drupal\Tests\Core\Entity\BaseFieldDefinitionTest::testFieldCardinality()
- 9 core/tests/Drupal/Tests/Core/Entity/BaseFieldDefinitionTest.php \Drupal\Tests\Core\Entity\BaseFieldDefinitionTest::testFieldCardinality()
Tests field cardinality.
@covers ::getCardinality @covers ::setCardinality
File
- core/
tests/ Drupal/ Tests/ Core/ Entity/ BaseFieldDefinitionTest.php, line 282
Class
- BaseFieldDefinitionTest
- Unit test for BaseFieldDefinition.
Namespace
Drupal\Tests\Core\EntityCode
public function testFieldCardinality() {
$definition = BaseFieldDefinition::create($this->fieldType);
$this
->assertEquals(1, $definition
->getCardinality());
$definition
->setCardinality(2);
$this
->assertEquals(2, $definition
->getCardinality());
$definition
->setCardinality(FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED);
$this
->assertEquals(FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED, $definition
->getCardinality());
}