You are here

public function EckEntityTranslationTest::testEntityTranslation in Entity Construction Kit (ECK) 8

Test translating of ECK entities.

File

tests/src/Functional/EckEntityTranslationTest.php, line 76

Class

EckEntityTranslationTest
Tests translating ECK entities.

Namespace

Drupal\Tests\eck\Functional

Code

public function testEntityTranslation() {
  $entity = $this
    ->createEntity($this->entityType['id'], [
    'type' => $this->bundle['type'],
    'title' => 'ECK Entity',
  ]);
  $entity_type = $entity
    ->getEntityTypeId();

  // Add translation.
  $this
    ->drupalGet("{$entity_type}/{$entity->id()}/translations");
  $this
    ->assertSession()
    ->linkByHrefExists("{$entity_type}/{$entity->id()}/translations/add/en/uk");
  $this
    ->getSession()
    ->getPage()
    ->clickLink('Add');
  $this
    ->getSession()
    ->getPage()
    ->fillField('Title', 'ECK Entity translation');
  $this
    ->getSession()
    ->getPage()
    ->pressButton('Save');

  // Make sure the created translation exists.
  $this
    ->drupalGet("{$entity_type}/{$entity->id()}/translations");
  $this
    ->assertSession()
    ->linkByHrefExists("{$entity_type}/{$entity->id()}");
  $this
    ->assertSession()
    ->linkByHrefExists("uk/{$entity_type}/{$entity->id()}");
  $this
    ->drupalGet("{$entity_type}/{$entity->id()}");
  $this
    ->assertSession()
    ->pageTextContains('ECK Entity');
  $this
    ->drupalGet("uk/{$entity_type}/{$entity->id()}");
  $this
    ->assertSession()
    ->pageTextContains('ECK Entity translation');
}