public function NodeThumbsUpDownWidgetTest::testVoting in Rate 8
Same name in this branch
- 8 tests/src/Functional/NodeThumbsUpDownWidgetTest.php \Drupal\Tests\rate\Functional\NodeThumbsUpDownWidgetTest::testVoting()
- 8 tests/src/FunctionalJavascript/NodeThumbsUpDownWidgetTest.php \Drupal\Tests\rate\FunctionalJavascript\NodeThumbsUpDownWidgetTest::testVoting()
Tests voting.
File
- tests/
src/ FunctionalJavascript/ NodeThumbsUpDownWidgetTest.php, line 25
Class
- NodeThumbsUpDownWidgetTest
- Tests for the "Thumbs Up / Down" widget.
Namespace
Drupal\Tests\rate\FunctionalJavascriptCode
public function testVoting() {
$session = $this
->assertSession();
// Log in as first user.
$this
->drupalLogin($this->users[0]);
$this
->drupalGet('node/1');
$this
->assertThumbsUpDown(0, 0);
// Vote 'Up'.
$this
->clickLink('Up');
$session
->assertWaitOnAjaxRequest();
$this
->assertThumbsUpDown(100, 0);
$session
->linkExists('Undo');
// Unvote 'Up'.
$this
->clickLink('Undo');
$session
->assertWaitOnAjaxRequest();
$this
->assertThumbsUpDown(0, 0);
$session
->linkNotExists('Undo');
// Vote 'Up'.
$this
->clickLink('Up');
$session
->assertWaitOnAjaxRequest();
$this
->assertThumbsUpDown(100, 0);
$session
->linkExists('Undo');
// Log in as different user.
$this
->drupalLogin($this->users[1]);
$this
->drupalGet('node/1');
$this
->assertThumbsUpDown(100, 0);
$session
->linkNotExists('Undo');
// Vote 'Down'.
$this
->clickLink('Down');
$session
->assertWaitOnAjaxRequest();
$this
->assertThumbsUpDown(50, 50);
$session
->linkExists('Undo');
// Log in as different user.
$this
->drupalLogin($this->users[2]);
$this
->drupalGet('node/1');
$this
->assertThumbsUpDown(50, 50);
$session
->linkNotExists('Undo');
// Vote 'Up'.
$this
->clickLink('Up');
$session
->assertWaitOnAjaxRequest();
$this
->assertThumbsUpDown(67, 33);
$session
->linkExists('Undo');
}