You are here

public function EntityTypeAlterTest::testEntityTypeAlter in Workspace 8

File

tests/src/Functional/EntityTypeAlterTest.php, line 28

Class

EntityTypeAlterTest
Test the workspace entity.

Namespace

Drupal\Tests\workspace\Functional

Code

public function testEntityTypeAlter() {
  $entity_types = \Drupal::service('entity_type.manager')
    ->getDefinitions();

  /** @var EntityTypeInterface $workspace_type */
  $workspace_type = $entity_types['workspace_type'];
  $this
    ->assertTrue($workspace_type
    ->getHandlerClass('list_builder') !== null);
  $this
    ->assertTrue($workspace_type
    ->getHandlerClass('route_provider', 'html') !== null);
  $this
    ->assertTrue($workspace_type
    ->getHandlerClass('form', 'default') !== null);
  $this
    ->assertTrue($workspace_type
    ->getHandlerClass('form', 'add') !== null);
  $this
    ->assertTrue($workspace_type
    ->getHandlerClass('form', 'edit') !== null);
  $this
    ->assertTrue($workspace_type
    ->getHandlerClass('form', 'delete') !== null);
  $this
    ->assertTrue($workspace_type
    ->getLinkTemplate('collection') !== null);
  $this
    ->assertTrue($workspace_type
    ->getLinkTemplate('edit-form') !== null);
  $this
    ->assertTrue($workspace_type
    ->getLinkTemplate('delete-form') !== null);

  /** @var EntityTypeInterface $workspace */
  $workspace = $entity_types['workspace'];
  $this
    ->assertTrue($workspace
    ->getHandlerClass('list_builder') !== null);
  $this
    ->assertTrue($workspace
    ->getHandlerClass('route_provider', 'html') !== null);
  $this
    ->assertTrue($workspace
    ->getHandlerClass('form', 'default') !== null);
  $this
    ->assertTrue($workspace
    ->getHandlerClass('form', 'add') !== null);
  $this
    ->assertTrue($workspace
    ->getHandlerClass('form', 'edit') !== null);
  $this
    ->assertTrue($workspace
    ->getLinkTemplate('collection') !== null);
  $this
    ->assertTrue($workspace
    ->getLinkTemplate('edit-form') !== null);
  $this
    ->assertTrue($workspace
    ->getLinkTemplate('activate-form') !== null);
  $this
    ->assertTrue($workspace
    ->get('field_ui_base_route') !== null);
  foreach ($entity_types as $entity_type) {
    if (\Drupal::service('multiversion.manager')
      ->isSupportedEntityType($entity_type)) {
      if ($entity_type
        ->hasViewBuilderClass() && $entity_type
        ->hasLinkTemplate('canonical')) {
        $this
          ->assertTrue($entity_type
          ->getLinkTemplate('version-tree') !== null);
        $this
          ->assertTrue($entity_type
          ->getLinkTemplate('revision') !== null);
      }
    }
  }
}