function 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[[api-linebreak]]
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());
}Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.
