You are here

protected function LikeAndDislikeTest::vote in Like & Dislike 8

Triggers a voting action with given parameters.

Parameters

string $vote_type: The vote type.

string $entity_type_id: The entity type ID.

string $entity_id: The entity ID.

string|null $message: (optional) The message to assert.

bool $cancel: (optional) TRUE if the vote is cancelled. Otherwise, FALSE.

1 call to LikeAndDislikeTest::vote()
LikeAndDislikeTest::testVoting in tests/src/FunctionalJavascript/LikeAndDislikeTest.php
Asserts module voting.

File

tests/src/FunctionalJavascript/LikeAndDislikeTest.php, line 529

Class

LikeAndDislikeTest
Provides a web test for like_and_dislike module.

Namespace

Drupal\Tests\like_and_dislike\FunctionalJavascript

Code

protected function vote($vote_type, $entity_type_id, $entity_id, $message = NULL, $cancel = FALSE) {

  // Get the current URL.
  $page = $this
    ->getSession()
    ->getPage();
  $container_id = "{$vote_type}-container-{$entity_type_id}-{$entity_id}";
  $link = $page
    ->find('css', "#{$container_id} a");
  $link
    ->click();
  $this
    ->assertSession()
    ->assertWaitOnAjaxRequest();
  if ($message) {

    // @todo: The message content is not recognized.
    // $this->assertRaw($message);
  }

  // Assert that voted icon was updated.
  if (!$cancel) {
    $this
      ->assertEquals('voted', $link
      ->getAttribute('class'));
  }
}