You are here

public function DynamicBaseFieldTest::testTitlesDescriptionOverrides in Entity Construction Kit (ECK) 8

Test title and description overrides for base fields.

File

tests/src/Functional/DynamicBaseFieldTest.php, line 95

Class

DynamicBaseFieldTest
Tests the functioning of eck's dynamic base fields.

Namespace

Drupal\Tests\eck\Functional

Code

public function testTitlesDescriptionOverrides() {
  $entity_type = $this
    ->createEntityType();
  $bundle = $this
    ->createEntityBundle($entity_type['id']);
  $new_eck_entity_page = Url::fromRoute('eck.entity.add', [
    'eck_entity_type' => $entity_type['id'],
    'eck_entity_bundle' => $bundle['type'],
  ]);
  $this
    ->drupalGet($new_eck_entity_page);

  // Verify default field title.
  $this
    ->assertSession()
    ->pageTextContains('Title');

  // Verify default field description.
  $this
    ->assertSession()
    ->pageTextContains('The title of the entity.');

  // Override default title and description.
  $edit['title_title_override'] = 'First name';
  $edit['title_description_override'] = 'Please enter your first name.';
  $this
    ->drupalGet(Url::fromRoute("entity.{$entity_type['id']}_type.edit_form", [
    "{$entity_type['id']}_type" => $bundle['type'],
  ]));
  $this
    ->submitForm($edit, 'Save bundle');
  $this
    ->drupalGet($new_eck_entity_page);

  // Verify overridden field title.
  $this
    ->assertSession()
    ->pageTextContains('First name');

  // Verify overridden field description.
  $this
    ->assertSession()
    ->pageTextContains('Please enter your first name.');
}