You are here

protected function StubTestTrait::validateStub in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/migrate_drupal/src/Tests/StubTestTrait.php \Drupal\migrate_drupal\Tests\StubTestTrait::validateStub()

Perform validation on a stub entity.

Parameters

string $entity_type_id: The entity type we are stubbing.

string $entity_id: ID of the stubbed entity to validate.

Return value

\Drupal\Core\Entity\EntityConstraintViolationListInterface List of constraint violations identified.

1 call to StubTestTrait::validateStub()
StubTestTrait::performStubTest in core/modules/migrate_drupal/src/Tests/StubTestTrait.php
Tests that a stub of the given entity type results in a valid entity.

File

core/modules/migrate_drupal/src/Tests/StubTestTrait.php, line 60

Class

StubTestTrait
Provides common functionality for testing stubbing.

Namespace

Drupal\migrate_drupal\Tests

Code

protected function validateStub($entity_type_id, $entity_id) {
  $controller = \Drupal::entityTypeManager()
    ->getStorage($entity_type_id);

  /** @var \Drupal\Core\Entity\ContentEntityInterface $stub_entity */
  $stub_entity = $controller
    ->load($entity_id);
  return $stub_entity
    ->validate();
}