You are here

trait EntityUtilsTrait in Apigee Edge 8

A trait to common functions of Apigee Edge entity tests.

Hierarchy

2 files declare their use of EntityUtilsTrait
DeveloperAppUITest.php in tests/src/Functional/DeveloperAppUITest.php
UiTest.php in modules/apigee_edge_teams/tests/src/Functional/UiTest.php

File

tests/src/Traits/EntityUtilsTrait.php, line 27

Namespace

Drupal\Tests\apigee_edge\Traits
View source
trait EntityUtilsTrait {

  /**
   * Changes and validates the singular and plural aliases of the entity.
   *
   * @param string $entity_type_id
   *   The ID of the entity type.
   * @param string $entity_settings_route_name
   *   The name of the entity settings route.
   */
  protected function changeEntityAliasesAndValidate(string $entity_type_id, string $entity_settings_route_name) {
    $singular = $this
      ->getRandomGenerator()
      ->word(8);
    $plural = $this
      ->getRandomGenerator()
      ->word(8);
    $this
      ->drupalPostForm(Url::fromRoute($entity_settings_route_name), [
      'entity_label_singular' => $singular,
      'entity_label_plural' => $plural,
    ], 'Save configuration');
    \Drupal::entityTypeManager()
      ->clearCachedDefinitions();
    \Drupal::cache('menu')
      ->invalidateAll();
    $type = \Drupal::entityTypeManager()
      ->getDefinition($entity_type_id);
    $this
      ->assertEquals($singular, $type
      ->getSingularLabel());
    $this
      ->assertEquals($plural, $type
      ->getPluralLabel());
  }

}

Members

Namesort descending Modifiers Type Description Overrides
EntityUtilsTrait::changeEntityAliasesAndValidate protected function Changes and validates the singular and plural aliases of the entity.