You are here

public function CommentFullViewFiltersFieldsTest::testFilters in Translation Views 8

Tests that filters are working correctly.

File

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

Class

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

Namespace

Drupal\Tests\translation_views\Functional

Code

public function testFilters() {

  // Translation language.
  $this
    ->drupalGet($this->viewPath, [
    'query' => [
      'langcode' => 'en',
    ],
  ]);
  $this
    ->assertTextInRowOrder('subject', [
    1 => 'node 1 en comment',
    2 => 'node 3 en from fr comment',
  ]);
  $this
    ->assertSession()
    ->pageTextNotContains('node 1 de comment');
  $this
    ->assertSession()
    ->pageTextNotContains('node 2 de comment');
  $this
    ->assertSession()
    ->pageTextNotContains('node 2 fr comment');
  $this
    ->assertSession()
    ->pageTextNotContains('node 3 fr comment');

  // Translation language & Target language.
  $this
    ->drupalGet($this->viewPath, [
    'query' => [
      'langcode' => 'en',
      'translation_target_language' => 'fr',
    ],
  ]);
  $this
    ->assertTextInRowOrder('subject', [
    1 => 'node 1 en comment',
    2 => 'node 3 en from fr comment',
  ]);
  $this
    ->assertSession()
    ->pageTextNotContains('node 1 de comment');
  $this
    ->assertSession()
    ->pageTextNotContains('node 2 de comment');
  $this
    ->assertSession()
    ->pageTextNotContains('node 2 fr comment');
  $this
    ->assertSession()
    ->pageTextNotContains('node 3 fr comment');

  // Translation language & Target language & Translation outdated.
  $this
    ->drupalGet($this->viewPath, [
    'query' => [
      'langcode' => 'en',
      'translation_target_language' => 'fr',
      'translation_outdated' => '1',
    ],
  ]);
  $this
    ->assertTextInRowOrder('subject', [
    1 => 'node 3 en from fr comment',
  ]);
  $this
    ->assertSession()
    ->pageTextNotContains('node 1 en comment');
  $this
    ->assertSession()
    ->pageTextNotContains('node 1 de comment');
  $this
    ->assertSession()
    ->pageTextNotContains('node 2 de comment');
  $this
    ->assertSession()
    ->pageTextNotContains('node 2 fr comment');
  $this
    ->assertSession()
    ->pageTextNotContains('node 3 fr comment');

  // Translation status #1.
  $this
    ->drupalGet($this->viewPath, [
    'query' => [
      'translation_status' => '0',
    ],
  ]);
  $this
    ->assertTextInRowOrder('subject', [
    1 => 'node 1 de comment',
    2 => 'node 2 de comment',
    3 => 'node 2 fr comment',
  ]);
  $this
    ->assertSession()
    ->pageTextNotContains('node 1 en comment');
  $this
    ->assertSession()
    ->pageTextNotContains('node 3 fr comment');
  $this
    ->assertSession()
    ->pageTextNotContains('node 3 en from fr comment');

  // Translation status #2.
  $this
    ->drupalGet($this->viewPath, [
    'query' => [
      'translation_status' => '1',
    ],
  ]);
  $this
    ->assertTextInRowOrder('subject', [
    1 => 'node 1 en comment',
    2 => 'node 3 en from fr comment',
    3 => 'node 3 fr comment',
  ]);
  $this
    ->assertSession()
    ->pageTextNotContains('node 1 de comment');
  $this
    ->assertSession()
    ->pageTextNotContains('node 2 de comment');
  $this
    ->assertSession()
    ->pageTextNotContains('node 2 fr comment');
}