You are here

public function AssertRateWidgetTrait::assertFivestar in Rate 8

Same name and namespace in other branches
  1. 8.2 tests/src/Traits/AssertRateWidgetTrait.php \Drupal\Tests\rate\Traits\AssertRateWidgetTrait::assertFivestar()

Assert "Fivestar".

Parameters

int $expected: The expected number of stars (from 0 to 5).

5 calls to AssertRateWidgetTrait::assertFivestar()
NodeFivestarWidgetTest::testVoting in tests/src/Functional/NodeFivestarWidgetTest.php
Tests voting.
NodeFivestarWidgetTest::testVoting in tests/src/FunctionalJavascript/NodeFivestarWidgetTest.php
Tests voting.
NodeMultipleWidgetTest::testVoting in tests/src/Functional/NodeMultipleWidgetTest.php
Tests voting.
NodeMultipleWidgetTest::testVoting in tests/src/FunctionalJavascript/NodeMultipleWidgetTest.php
Tests voting.
RateMultilingualTest::testMultilingualNode in tests/src/Functional/RateMultilingualTest.php
Tests for multilingual node.

File

tests/src/Traits/AssertRateWidgetTrait.php, line 19

Class

AssertRateWidgetTrait
Assert methods to verify results of voting for a single node.

Namespace

Drupal\Tests\rate\Traits

Code

public function assertFivestar($expected) {
  $session = $this
    ->assertSession();
  $session
    ->elementExists('css', '.rate-widget-fivestar');
  if ($expected > 0) {
    $session
      ->elementExists('css', '.rate-fivestar-btn-filled.rate-fivestar-' . $expected);
  }
  if ($expected < 5) {
    $session
      ->elementExists('css', '.rate-fivestar-btn-empty.rate-fivestar-' . ++$expected);
  }
}