You are here

public function RateWidgetTest::testWidgetCaching in Rate 8

Tests widget caching.

File

tests/src/Functional/RateWidgetTest.php, line 84

Class

RateWidgetTest
Tests for the Rate widget.

Namespace

Drupal\Tests\rate\Functional

Code

public function testWidgetCaching() {

  // Log in and vote as user 1.
  $this
    ->drupalLogin($this->webUsers[1]);
  $this
    ->drupalGet($this->testEntity
    ->toUrl());

  // Vote on the item.
  $this
    ->clickLink('Up');
  $this
    ->drupalGet($this->testEntity
    ->toUrl());
  $this
    ->assertSession()
    ->pageTextContains('+1');
  $this
    ->assertSession()
    ->linkExists('Undo');

  // Log in as different user, verify widget has a +1 vote, but should still
  // let the user vote on their own.
  $this
    ->drupalLogin($this->webUsers[2]);
  $this
    ->drupalGet($this->testEntity
    ->toUrl());
  $this
    ->assertSession()
    ->pageTextContains('+1');
  $this
    ->assertSession()
    ->linkNotExists('Undo');
}