public function EntityResourceValidationTraitTest::testValidate in Drupal 8
Same name and namespace in other branches
- 9 core/modules/rest/tests/src/Unit/EntityResourceValidationTraitTest.php \Drupal\Tests\rest\Unit\EntityResourceValidationTraitTest::testValidate()
@covers ::validate
File
- core/
modules/ rest/ tests/ src/ Unit/ EntityResourceValidationTraitTest.php, line 22
Class
- EntityResourceValidationTraitTest
- @group rest @coversDefaultClass \Drupal\rest\Plugin\rest\resource\EntityResourceValidationTrait
Namespace
Drupal\Tests\rest\UnitCode
public function testValidate() {
$trait = new EntityResourceValidationTraitTestClass();
$method = new \ReflectionMethod($trait, 'validate');
$method
->setAccessible(TRUE);
$violations = $this
->prophesize(EntityConstraintViolationList::class);
$violations
->filterByFieldAccess()
->shouldBeCalled()
->willReturn([]);
$violations
->count()
->shouldBeCalled()
->willReturn(0);
$entity = $this
->prophesize(Node::class);
$entity
->validate()
->shouldBeCalled()
->willReturn($violations
->reveal());
$method
->invoke($trait, $entity
->reveal());
}