function StubTestTrait::validateStub

Same name in this branch
  1. 11.x core/modules/migrate_drupal/src/Tests/StubTestTrait.php \Drupal\migrate_drupal\Tests\StubTestTrait::validateStub()
Same name and namespace in other branches
  1. 10 core/modules/migrate_drupal/src/Tests/StubTestTrait.php \Drupal\migrate_drupal\Tests\StubTestTrait::validateStub()
  2. 9 core/modules/migrate_drupal/src/Tests/StubTestTrait.php \Drupal\migrate_drupal\Tests\StubTestTrait::validateStub()
  3. 8.9.x core/modules/migrate_drupal/src/Tests/StubTestTrait.php \Drupal\migrate_drupal\Tests\StubTestTrait::validateStub()
  4. main core/modules/migrate_drupal/src/Tests/StubTestTrait.php \Drupal\migrate_drupal\Tests\StubTestTrait::validateStub()
  5. main core/modules/migrate/tests/src/StubTestTrait.php \Drupal\Tests\migrate\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/tests/src/StubTestTrait.php
Tests that creating a stub of an entity type results in a valid entity.

File

core/modules/migrate/tests/src/StubTestTrait.php, line 63

Class

StubTestTrait
Provides common functionality for testing stubbing.

Namespace

Drupal\Tests\migrate

Code

protected function validateStub(string $entity_type_id, string $entity_id) : EntityConstraintViolationListInterface {
  $controller = \Drupal::entityTypeManager()->getStorage($entity_type_id);
  /** @var \Drupal\Core\Entity\ContentEntityInterface $stub_entity */
  $stub_entity = $controller->load($entity_id);
  return $stub_entity->validate();
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.