public function BaseFieldDefinitionTest::testFieldCardinality in Zircon Profile 8
Same name and namespace in other branches
- 8.0 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 238 - Contains \Drupal\Tests\Core\Entity\BaseFieldDefinitionTest.
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());
}