You are here

public function EntityLoadHelperTest::getEntityDefinition in YAML Content 8

Get a mocked entity definition.

Parameters

string $entity_type: The identifier for the entity type definition being mocked.

Return value

\PHPUnit_Framework_MockObject_MockObject|ContentEntityTypeInterface The mock for the entity definition.

File

tests/src/Unit/EntityLoadHelper/EntityLoadHelperTest.php, line 558

Class

EntityLoadHelperTest
Test functionality of the EntityLoadHelper class.

Namespace

Drupal\Tests\yaml_content\Unit\EntityLoadHelper

Code

public function getEntityDefinition($entity_type) {
  $definition = $this
    ->loadFixtureContent('entity_definitions', [
    $entity_type,
  ]);
  $mock = $this
    ->getMockForAbstractClass(ContentEntityTypeInterface::class);
  $mock
    ->method('hasKey')
    ->willReturnCallback(function ($key) use ($definition) {
    return in_array($key, $definition['entity_keys']);
  });
  $mock
    ->method('getKeys')
    ->willReturn($definition['entity_keys']);
  return $mock;
}