function EntityTypeTest::testConstraintMethods
Tests the constraint methods.
@legacy-covers ::getConstraints @legacy-covers ::setConstraints @legacy-covers ::addConstraint
File
-
core/
tests/ Drupal/ Tests/ Core/ Entity/ EntityTypeTest.php, line 485
Class
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.