function EntityUuidIdTest::testUi

Tests the user interface for the test entity.

File

core/tests/Drupal/FunctionalTests/Entity/EntityUuidIdTest.php, line 45

Class

EntityUuidIdTest
Tests that an entity with a UUID as ID can be managed.

Namespace

Drupal\FunctionalTests\Entity

Code

public function testUi() : void {
  $this->drupalLogin($this->createUser([
    'administer entity_test content',
    'create content translations',
    'translate entity_test_uuid_id',
    'view test entity',
  ]));
  // Test adding an entity.
  $this->drupalGet('/entity_test_uuid_id/add');
  $this->submitForm([
    'Name' => 'Test entity with UUID ID',
  ], 'Save');
  $this->assertSession()
    ->elementTextEquals('css', 'h1', 'Edit Test entity with UUID ID');
  $this->assertSession()
    ->addressMatches('#^/entity_test_uuid_id/manage/' . Uuid::VALID_PATTERN . '/edit$#');
  // Test translating an entity.
  $this->clickLink('Translate');
  $this->clickLink('Add');
  $this->submitForm([
    'Name' => 'Afrikaans translation of test entity with UUID ID',
  ], 'Save');
  $this->assertSession()
    ->elementTextEquals('css', 'h1', 'Afrikaans translation of test entity with UUID ID [Afrikaans translation]');
  $this->assertSession()
    ->addressMatches('#^/af/entity_test_uuid_id/manage/' . Uuid::VALID_PATTERN . '/edit$#');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.