You are here

public function TranslationOperationTargetLanguageTest::testTranslationOperationsTargetLanguage in Translation Views 8

Test translation operations target language.

Throws

\Behat\Mink\Exception\ElementHtmlException

\Behat\Mink\Exception\ExpectationException

File

tests/src/Functional/TranslationOperationTargetLanguageTest.php, line 159

Class

TranslationOperationTargetLanguageTest
Class TranslationOperationTargetLanguageTest.

Namespace

Drupal\Tests\translation_views\Functional

Code

public function testTranslationOperationsTargetLanguage() {
  $base_selector = 'table > tbody > tr:nth-child(1) .views-field-translation-operations ul li';
  $this
    ->drupalLogin($this->adminUser);

  // Check for "Add" links target languages.
  $target_language = $this
    ->generateTargetLanguage();
  $this
    ->drupalGet('translation-views-all-filters-and-fields', [
    'query' => [
      'content_translation_source' => 'All',
      'translation_target_language' => $target_language,
      'translation_default' => 'All',
      'translation_status' => 'All',
    ],
  ]);
  $this
    ->assertResponseOk();
  $expected_create_link = "/{$target_language}/node/1/translations/add/{$this->defaultLangcode}/{$target_language}";
  $this
    ->assertSession()
    ->elementAttributeContains('css', "{$base_selector} a", 'href', $expected_create_link);

  // Translate nodes.
  $this
    ->translateNode();

  // Check for "Edit" and "Delete" links target languages.
  $target_language = $this
    ->generateTargetLanguage();
  $this
    ->drupalGet('translation-views-all-filters-and-fields', [
    'query' => [
      'content_translation_source' => 'All',
      'translation_target_language' => $target_language,
      'translation_default' => 'All',
      'translation_status' => 'All',
    ],
  ]);
  $this
    ->assertResponseOk();
  $this
    ->assertSession()
    ->elementAttributeContains('css', "{$base_selector}.edit a", 'href', "/{$target_language}/node/1/edit");
  $this
    ->assertSession()
    ->elementAttributeContains('css', "{$base_selector}.delete a", 'href', "/{$target_language}/node/1/delete");
}