You are here

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

Test the delete process of ECK entity translations.

File

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

Class

EckEntityTranslationTest
Tests translating ECK entities.

Namespace

Drupal\Tests\eck\Functional

Code

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

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

  // Remove newly created translation.
  $this
    ->drupalGet("uk/{$entity_type}/{$entity->id()}/edit");
  $this
    ->getSession()
    ->getPage()
    ->pressButton('Delete translation');
  $this
    ->assertSession()
    ->pageTextContains('Are you sure you want to delete the Ukrainian translation of the translatable ECK Entity translation?');
  $this
    ->getSession()
    ->getPage()
    ->pressButton('Delete Ukrainian translation');
  $this
    ->drupalGet("{$entity_type}/{$entity->id()}/translations");

  // Make sure the translation is removed and original entity exists.
  $this
    ->assertSession()
    ->linkByHrefExists("{$entity_type}/{$entity->id()}");
  $this
    ->assertSession()
    ->linkByHrefExists("uk/{$entity_type}/{$entity->id()}/translations/add/en/uk");
}