You are here

protected function StubTestTrait::validateStub in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 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
Test that creating a stub of the given entity type results in a valid entity.

File

core/modules/migrate_drupal/src/Tests/StubTestTrait.php, line 73
Contains \Drupal\migrate_drupal\Tests\StubTestTrait.

Class

StubTestTrait
Provides common functionality for testing stubbing.

Namespace

Drupal\migrate_drupal\Tests

Code

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

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