public function ViewsFivestarWidgetTest::testFivestarViewsWidget in Rate 8
Tests a fivestar views widget.
File
- tests/
src/ FunctionalJavascript/ ViewsFivestarWidgetTest.php, line 101
Class
- ViewsFivestarWidgetTest
- Tests Views Fivestar Widget.
Namespace
Drupal\Tests\rate\FunctionalJavascriptCode
public function testFivestarViewsWidget() {
$session = $this
->assertSession();
$this
->drupalLogin($this->users[0]);
$this
->drupalGet('test_views_widget');
// Vote 1 star on the first article.
$this
->assertFivestarById(1, 0);
$this
->voteFivestarById(1, 1);
$session
->assertWaitOnAjaxRequest();
$this
->assertFivestarById(1, 1);
$session
->linkExists('Undo');
// Vote 3 stars on the second article.
$this
->assertFivestarById(2, 0);
$this
->voteFivestarById(2, 3);
$session
->assertWaitOnAjaxRequest();
$this
->assertFivestarById(2, 3);
$session
->linkExists('Undo');
$this
->drupalLogin($this->users[1]);
$this
->drupalGet('test_views_widget');
// Vote 5 stars on the first article.
$this
->voteFivestarById(1, 5);
$session
->assertWaitOnAjaxRequest();
$this
->assertFivestarById(1, 3);
$session
->linkExists('Undo');
// Vote 5 stars on the second article.
$this
->voteFivestarById(2, 4);
$session
->assertWaitOnAjaxRequest();
$this
->assertFivestarById(2, 3);
$session
->linkExists('Undo');
// Unvote first article.
$this
->unVoteFivestarById(1);
$session
->assertWaitOnAjaxRequest();
$this
->assertFivestarById(1, 1);
$session
->linkExists('Undo');
// Unvote second article.
$this
->unVoteFivestarById(2);
$session
->assertWaitOnAjaxRequest();
$this
->assertFivestarById(2, 3);
$session
->linkNotExists('Undo');
}