public function EntityTypeTest::testConstraintMethods in Drupal 8
Same name and namespace in other branches
- 9 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 468
Class
- EntityTypeTest
- @coversDefaultClass \Drupal\Core\Entity\EntityType @group Entity
Namespace
Drupal\Tests\Core\EntityCode
public function testConstraintMethods() {
$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());
}