You are here

public function UITest::testListingTitles in Entity Construction Kit (ECK) 8

Makes sure the listing titles of entity type listings are correct.

File

tests/src/Functional/UITest.php, line 42

Class

UITest
Tests if eck's UI elements are working properly.

Namespace

Drupal\Tests\eck\Functional

Code

public function testListingTitles() {
  $type = $this
    ->createEntityType();
  $bundle = $this
    ->createEntityBundle($type['id']);
  $this
    ->drupalPlaceBlock('page_title_block');

  // Test title of the entity types listing.
  $this
    ->drupalGet(Url::fromRoute('eck.entity_type.list'));
  $this
    ->assertSession()
    ->responseContains("ECK Entity Types");

  // Test title of the entity bundles listing.
  $this
    ->drupalGet(Url::fromRoute("eck.entity.{$type['id']}_type.list"));
  $this
    ->assertSession()
    ->responseContains((string) $this
    ->t('%type bundles', [
    '%type' => ucfirst($type['label']),
  ]));

  // Test title of the add bundle page.
  $this
    ->drupalGet(Url::fromRoute("eck.entity.{$type['id']}_type.add"));
  $this
    ->assertSession()
    ->responseContains((string) $this
    ->t('Add %type bundle', [
    '%type' => $type['label'],
  ]));

  // Test title of the edit bundle page.
  $this
    ->drupalGet(Url::fromRoute("entity.{$type['id']}_type.edit_form", [
    "{$type['id']}_type" => $bundle['type'],
  ]));
  $this
    ->assertSession()
    ->responseContains((string) $this
    ->t('Edit %type bundle', [
    '%type' => $type['label'],
  ]));

  // Test title of the delete bundle page.
  $this
    ->drupalGet(Url::fromRoute("entity.{$type['id']}_type.delete_form", [
    "{$type['id']}_type" => $bundle['type'],
  ]));
  $this
    ->assertSession()
    ->responseContains((string) $this
    ->t('Are you sure you want to delete the entity bundle %type?', [
    '%type' => $bundle['name'],
  ]));

  // Test title of the entity content listing.
  $this
    ->drupalGet(Url::fromRoute("eck.entity.{$type['id']}.list"));
  $this
    ->assertSession()
    ->responseContains((string) $this
    ->t('%type content', [
    '%type' => ucfirst($type['label']),
  ]));
}