function ContentEntityBaseUnitTest::testValidate
Same name in other branches
- 8.9.x core/tests/Drupal/Tests/Core/Entity/ContentEntityBaseUnitTest.php \Drupal\Tests\Core\Entity\ContentEntityBaseUnitTest::testValidate()
- 10 core/tests/Drupal/Tests/Core/Entity/ContentEntityBaseUnitTest.php \Drupal\Tests\Core\Entity\ContentEntityBaseUnitTest::testValidate()
- 11.x core/tests/Drupal/Tests/Core/Entity/ContentEntityBaseUnitTest.php \Drupal\Tests\Core\Entity\ContentEntityBaseUnitTest::testValidate()
@covers ::validate
File
-
core/
tests/ Drupal/ Tests/ Core/ Entity/ ContentEntityBaseUnitTest.php, line 422
Class
- ContentEntityBaseUnitTest
- @coversDefaultClass \Drupal\Core\Entity\ContentEntityBase @group Entity @group Access
Namespace
Drupal\Tests\Core\EntityCode
public function testValidate() {
$validator = $this->createMock(ValidatorInterface::class);
/** @var \Symfony\Component\Validator\ConstraintViolationList $empty_violation_list */
$empty_violation_list = new ConstraintViolationList();
$non_empty_violation_list = clone $empty_violation_list;
$violation = $this->createMock('\\Symfony\\Component\\Validator\\ConstraintViolationInterface');
$non_empty_violation_list->add($violation);
$validator->expects($this->exactly(2))
->method('validate')
->with($this->entity
->getTypedData())
->willReturnOnConsecutiveCalls($empty_violation_list, $non_empty_violation_list);
$this->typedDataManager
->expects($this->exactly(2))
->method('getValidator')
->willReturn($validator);
$this->assertCount(0, $this->entity
->validate());
$this->assertCount(1, $this->entity
->validate());
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.