You are here

public function EckEntityTest::testBaseFieldDefinitions in Entity Construction Kit (ECK) 8

Tests base field definitions.

@dataProvider baseFieldDefinitionTestDataProvider

Parameters

array $config: The configuration.

array $expectedBaseFieldDefinitionIds: The expected base field definition ids.

Throws

\ReflectionException

File

tests/src/Unit/EckEntityTest.php, line 90

Class

EckEntityTest
Tests eck entities.

Namespace

Drupal\Tests\eck\Unit

Code

public function testBaseFieldDefinitions(array $config, array $expectedBaseFieldDefinitionIds) {
  $configs = [
    'eck.eck_entity_type.eck_entity_type' => $config,
  ];
  $this
    ->registerServiceWithContainerMock('config.factory', $this
    ->getConfigFactoryStub($configs));
  $annotationReader = new SimpleAnnotationReader();
  $annotationReader
    ->addNamespace((new \ReflectionClass(Translation::class))
    ->getNamespaceName());
  $annotationReader
    ->addNamespace((new \ReflectionClass(ConfigEntityType::class))
    ->getNamespaceName());
  $definition = $annotationReader
    ->getClassAnnotation(new \ReflectionClass(EckEntityType::class), ConfigEntityType::class);
  $this
    ->assertArrayKeysEqual($expectedBaseFieldDefinitionIds, EckEntity::baseFieldDefinitions($definition
    ->get()));
}