public function NodeFivestarWidgetTest::testVoting in Rate 8
Same name in this branch
- 8 tests/src/Functional/NodeFivestarWidgetTest.php \Drupal\Tests\rate\Functional\NodeFivestarWidgetTest::testVoting()
- 8 tests/src/FunctionalJavascript/NodeFivestarWidgetTest.php \Drupal\Tests\rate\FunctionalJavascript\NodeFivestarWidgetTest::testVoting()
Tests voting.
File
- tests/
src/ Functional/ NodeFivestarWidgetTest.php, line 29
Class
- NodeFivestarWidgetTest
- Tests for the "Fivestar" widget.
Namespace
Drupal\Tests\rate\FunctionalCode
public function testVoting() {
$session = $this
->assertSession();
// Log in as first user.
$this
->drupalLogin($this->users[0]);
$this
->drupalGet('node/1');
$this
->assertFivestar(0);
$session
->linkExists('Star');
$session
->linkNotExists('Undo');
// Vote 5 stars.
$this
->voteFivestar(5);
$this
->assertFivestar(5);
$session
->linkExists('Undo');
// Log in as different user.
$this
->drupalLogin($this->users[1]);
$this
->drupalGet('node/1');
$this
->assertFivestar(5);
$session
->linkNotExists('Undo');
// Vote 3 stars.
$this
->voteFivestar(3);
$this
->assertFivestar(4);
$session
->linkExists('Undo');
// Tests unvote.
$this
->clickLink('Undo');
$this
->assertFivestar(5);
$session
->linkNotExists('Undo');
}