public function NodeYesNoWidgetTest::testVoting in Rate 8
Same name in this branch
- 8 tests/src/Functional/NodeYesNoWidgetTest.php \Drupal\Tests\rate\Functional\NodeYesNoWidgetTest::testVoting()
- 8 tests/src/FunctionalJavascript/NodeYesNoWidgetTest.php \Drupal\Tests\rate\FunctionalJavascript\NodeYesNoWidgetTest::testVoting()
Tests voting.
File
- tests/
src/ FunctionalJavascript/ NodeYesNoWidgetTest.php, line 25
Class
- NodeYesNoWidgetTest
- Tests for the "Yes / No" 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
->assertYesNo(0, 0);
// Vote 'Yes'.
$this
->clickLink('Yes');
$session
->assertWaitOnAjaxRequest();
$this
->assertYesNo(1, 0);
$session
->linkExists('Undo');
// Unvote 'Yes'.
$this
->clickLink('Undo');
$session
->assertWaitOnAjaxRequest();
$this
->assertYesNo(0, 0);
$session
->linkNotExists('Undo');
// Vote 'Yes'.
$this
->clickLink('Yes');
$session
->assertWaitOnAjaxRequest();
$this
->assertYesNo(1, 0);
$session
->linkExists('Undo');
// Log in as different user.
$this
->drupalLogin($this->users[1]);
$this
->drupalGet('node/1');
$this
->assertYesNo(1, 0);
$session
->linkNotExists('Undo');
// Vote 'No'.
$this
->clickLink('No');
$session
->assertWaitOnAjaxRequest();
$this
->assertYesNo(1, 1);
$session
->linkExists('Undo');
// Log in as different user.
$this
->drupalLogin($this->users[2]);
$this
->drupalGet('node/1');
$this
->assertYesNo(1, 1);
$session
->linkNotExists('Undo');
// Vote 'Yes'.
$this
->clickLink('Yes');
$session
->assertWaitOnAjaxRequest();
$this
->assertYesNo(2, 1);
$session
->linkExists('Undo');
}