You are here

public function ContentTranslationJobsViewTest::testNodesSorting in Translation Views 8

Tests that columns' sorting works as expected.

File

tests/src/Functional/ContentTranslationJobsViewTest.php, line 165

Class

ContentTranslationJobsViewTest
Tests for fields, filters and sorting (Content translation jobs view).

Namespace

Drupal\Tests\translation_views\Functional

Code

public function testNodesSorting() {

  // Check title column asc sorting.
  $this
    ->drupalGet('translate/content', [
    'query' => [
      'order' => 'title',
      'sort' => 'asc',
    ],
  ]);
  $this
    ->assertSession()
    ->elementTextContains('css', 'table > tbody > tr:nth-child(1)', 'node1 de');
  $this
    ->assertSession()
    ->elementTextContains('css', 'table > tbody > tr:nth-child(2)', 'node1 fr');
  $this
    ->assertSession()
    ->elementTextContains('css', 'table > tbody > tr:nth-child(3)', 'node3 fr');

  // Check title column desc sorting.
  $this
    ->drupalGet('translate/content', [
    'query' => [
      'order' => 'title',
      'sort' => 'desc',
    ],
  ]);
  $this
    ->assertSession()
    ->elementTextContains('css', 'table > tbody > tr:nth-child(3)', 'node1 de');
  $this
    ->assertSession()
    ->elementTextContains('css', 'table > tbody > tr:nth-child(2)', 'node1 fr');
  $this
    ->assertSession()
    ->elementTextContains('css', 'table > tbody > tr:nth-child(1)', 'node3 fr');

  // Check langcode column asc sorting.
  $this
    ->drupalGet('translate/content', [
    'query' => [
      'order' => 'langcode',
      'sort' => 'asc',
    ],
  ]);
  $this
    ->assertSession()
    ->elementTextContains('css', 'table > tbody > tr:nth-child(1)', 'German');
  $this
    ->assertSession()
    ->elementTextContains('css', 'table > tbody > tr:nth-child(2)', 'French');
  $this
    ->assertSession()
    ->elementTextContains('css', 'table > tbody > tr:nth-child(3)', 'French');

  // Check langcode column desc sorting.
  $this
    ->drupalGet('translate/content', [
    'query' => [
      'order' => 'langcode',
      'sort' => 'desc',
    ],
  ]);
  $this
    ->assertSession()
    ->elementTextContains('css', 'table > tbody > tr:nth-child(1)', 'French');
  $this
    ->assertSession()
    ->elementTextContains('css', 'table > tbody > tr:nth-child(2)', 'French');
  $this
    ->assertSession()
    ->elementTextContains('css', 'table > tbody > tr:nth-child(3)', 'German');
}