You are here

public function CommentFullViewFiltersFieldsTest::testSorting in Translation Views 8

Tests columns' sorting.

File

tests/src/Functional/CommentFullViewFiltersFieldsTest.php, line 245

Class

CommentFullViewFiltersFieldsTest
Tests for fields, filters and sorting for comment entity.

Namespace

Drupal\Tests\translation_views\Functional

Code

public function testSorting() {

  // Title.
  $this
    ->assertOrder('subject', 'asc', [
    'de',
    'fr',
  ]);
  $this
    ->assertTextInRowOrder('subject', [
    1 => 'node 1 de comment',
    2 => 'node 2 de comment',
  ]);
  $this
    ->assertSession()
    ->pageTextNotContains('node 1 en comment');
  $this
    ->assertSession()
    ->pageTextNotContains('node 2 fr comment');
  $this
    ->assertSession()
    ->pageTextNotContains('node 3 fr comment');
  $this
    ->assertSession()
    ->pageTextNotContains('node 3 en from fr comment');
  $this
    ->assertOrder('subject', 'desc', [
    'de',
    'fr',
  ]);
  $this
    ->assertTextInRowOrder('subject', [
    2 => 'node 1 de comment',
    1 => 'node 2 de comment',
  ]);
  $this
    ->assertSession()
    ->pageTextNotContains('node 1 en comment');
  $this
    ->assertSession()
    ->pageTextNotContains('node 2 fr comment');
  $this
    ->assertSession()
    ->pageTextNotContains('node 3 fr comment');
  $this
    ->assertSession()
    ->pageTextNotContains('node 3 en from fr comment');

  // Translation language.
  $this
    ->assertOrder('langcode', 'asc', [
    'All',
    'de',
  ]);
  $this
    ->assertTextInRowOrder('langcode', [
    1 => 'German',
    2 => 'German',
    3 => 'English',
    4 => 'English',
    5 => 'French',
    6 => 'French',
  ]);
  $this
    ->assertOrder('langcode', 'desc', [
    'All',
    'de',
  ]);
  $this
    ->assertTextInRowOrder('langcode', [
    6 => 'German',
    5 => 'German',
    4 => 'English',
    3 => 'English',
    2 => 'French',
    1 => 'French',
  ]);

  // Target language equals default language.
  $this
    ->assertOrder('translation_default', 'asc', [
    'All',
    'fr',
  ]);
  $this
    ->assertTextInRowOrder('translation-default', [
    1 => 'No',
    2 => 'No',
    3 => 'No',
    4 => 'Yes',
    5 => 'Yes',
    6 => 'Yes',
  ]);
  $this
    ->assertOrder('translation_default', 'desc', [
    'All',
    'fr',
  ]);
  $this
    ->assertTextInRowOrder('translation-default', [
    6 => 'No',
    5 => 'No',
    4 => 'No',
    3 => 'Yes',
    2 => 'Yes',
    1 => 'Yes',
  ]);

  // Translation changed time.
  $this
    ->assertOrder('translation_changed', 'asc', [
    'All',
    'fr',
  ]);
  $this
    ->assertTextInRowOrder('translation-changed', [
    4 => ':',
    5 => ':',
    6 => ':',
  ]);
  $this
    ->assertOrder('translation_changed', 'desc', [
    'All',
    'fr',
  ]);
  $this
    ->assertTextInRowOrder('translation-changed', [
    1 => ':',
    2 => ':',
    3 => ':',
  ]);

  // Translation counter.
  $this
    ->assertOrder('translation_count', 'asc', [
    'en',
    'fr',
  ]);
  $this
    ->assertTextInRowOrder('translation-count', [
    1 => '0',
    2 => '1',
  ]);
  $this
    ->assertOrder('translation_count', 'desc', [
    'en',
    'fr',
  ]);
  $this
    ->assertTextInRowOrder('translation-count', [
    2 => '0',
    1 => '1',
  ]);

  // Translation outdated.
  $this
    ->assertOrder('translation-outdated', 'asc', [
    'en',
    'fr',
  ]);
  $this
    ->assertTextInRowOrder('translation-outdated', [
    1 => 'No',
    2 => 'Yes',
  ]);
  $this
    ->assertOrder('translation-outdated', 'desc', [
    'en',
    'fr',
  ]);
  $this
    ->assertTextInRowOrder('translation-outdated', [
    1 => 'No',
    2 => 'Yes',
  ]);

  // Source translation of target language equals row language.
  $this
    ->assertOrder('translation_source', 'asc', [
    'All',
    '***LANGUAGE_site_default***',
  ]);
  $this
    ->assertTextInRowOrder('translation-source', [
    1 => 'No',
    2 => 'No',
    3 => 'No',
    4 => 'No',
    5 => 'Yes',
    6 => 'Yes',
  ]);
  $this
    ->assertOrder('translation_source', 'desc', [
    'All',
    '***LANGUAGE_site_default***',
  ]);
  $this
    ->assertTextInRowOrder('translation-source', [
    6 => 'No',
    5 => 'No',
    4 => 'No',
    3 => 'No',
    2 => 'Yes',
    1 => 'Yes',
  ]);

  // Translation status.
  $this
    ->assertOrder('translation_status', 'asc', [
    'All',
    '***LANGUAGE_site_default***',
  ]);
  $this
    ->assertTextInRowOrder('translation-status', [
    1 => 'Not translated',
    2 => 'Not translated',
    3 => 'Not translated',
    4 => 'Translated',
    5 => 'Translated',
    6 => 'Translated',
  ]);
  $this
    ->assertOrder('translation_status', 'desc', [
    'All',
    '***LANGUAGE_site_default***',
  ]);
  $this
    ->assertTextInRowOrder('translation-status', [
    6 => 'Not translated',
    5 => 'Not translated',
    4 => 'Not translated',
    3 => 'Translated',
    2 => 'Translated',
    1 => 'Translated',
  ]);
}