You are here

public function ViewsFilterTest::testFilterMin in Rate 8

Tests a views filter.

File

tests/src/Functional/ViewsFilterTest.php, line 86

Class

ViewsFilterTest
Tests Views Fivestar Widget.

Namespace

Drupal\Tests\rate\Functional

Code

public function testFilterMin() {
  $session = $this
    ->assertSession();
  $this
    ->drupalGet('node/1');
  $this
    ->voteFivestar(1);
  $this
    ->drupalGet('node/2');
  $this
    ->voteFivestar(2);
  $this
    ->drupalGet('node/3');
  $this
    ->voteFivestar(3);
  $this
    ->drupalGet('node/4');
  $this
    ->voteFivestar(4);
  $this
    ->drupalGet('node/5');
  $this
    ->voteFivestar(5);
  $this
    ->drupalGet('test_views_filter');
  $session
    ->pageTextContains('Article 1');
  $session
    ->pageTextContains('Article 2');
  $session
    ->pageTextContains('Article 3');
  $session
    ->pageTextContains('Article 4');
  $session
    ->pageTextContains('Article 5');
  $session
    ->pageTextContains('Article 6');

  // Tests filter minimum 1 star.
  $this
    ->drupalGet('test_views_filter', [
    'query' => [
      'node_rate_field' => 1,
    ],
  ]);
  $session
    ->pageTextNotContains('Article 1');
  $session
    ->pageTextContains('Article 2');
  $session
    ->pageTextContains('Article 3');
  $session
    ->pageTextContains('Article 4');
  $session
    ->pageTextContains('Article 5');
  $session
    ->pageTextNotContains('Article 6');

  // Tests filter minimum 3 stars.
  $this
    ->drupalGet('test_views_filter', [
    'query' => [
      'node_rate_field' => 3,
    ],
  ]);
  $session
    ->pageTextNotContains('Article 1');
  $session
    ->pageTextNotContains('Article 2');
  $session
    ->pageTextNotContains('Article 3');
  $session
    ->pageTextContains('Article 4');
  $session
    ->pageTextContains('Article 5');
  $session
    ->pageTextNotContains('Article 6');
}