function EntityTypeTest::testConstraintMethods
Same name in other branches
- 9 core/tests/Drupal/Tests/Core/Entity/EntityTypeTest.php \Drupal\Tests\Core\Entity\EntityTypeTest::testConstraintMethods()
- 8.9.x core/tests/Drupal/Tests/Core/Entity/EntityTypeTest.php \Drupal\Tests\Core\Entity\EntityTypeTest::testConstraintMethods()
- 10 core/tests/Drupal/Tests/Core/Entity/EntityTypeTest.php \Drupal\Tests\Core\Entity\EntityTypeTest::testConstraintMethods()
Tests the constraint methods.
@covers ::getConstraints @covers ::setConstraints @covers ::addConstraint
File
-
core/
tests/ Drupal/ Tests/ Core/ Entity/ EntityTypeTest.php, line 469
Class
- EntityTypeTest
- @coversDefaultClass \Drupal\Core\Entity\EntityType @group Entity
Namespace
Drupal\Tests\Core\EntityCode
public function testConstraintMethods() : void {
$definition = [
'constraints' => [
'EntityChanged' => [],
],
];
$entity_type = $this->setUpEntityType($definition);
$this->assertEquals($definition['constraints'], $entity_type->getConstraints());
$entity_type->addConstraint('Test');
$this->assertEquals($definition['constraints'] + [
'Test' => NULL,
], $entity_type->getConstraints());
$entity_type->setConstraints([]);
$this->assertEquals([], $entity_type->getConstraints());
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.