public function NodeMultipleWidgetTest::testVoting in Rate 8
Same name in this branch
- 8 tests/src/Functional/NodeMultipleWidgetTest.php \Drupal\Tests\rate\Functional\NodeMultipleWidgetTest::testVoting()
- 8 tests/src/FunctionalJavascript/NodeMultipleWidgetTest.php \Drupal\Tests\rate\FunctionalJavascript\NodeMultipleWidgetTest::testVoting()
Tests voting.
File
- tests/
src/ Functional/ NodeMultipleWidgetTest.php, line 92
Class
- NodeMultipleWidgetTest
- Tests of multiple widgets for different nodes.
Namespace
Drupal\Tests\rate\FunctionalCode
public function testVoting() {
$session = $this
->assertSession();
// Tests 'Fivestar' voting on Article.
$this
->drupalLogin($this->users[0]);
$this
->drupalGet('node/1');
$this
->assertFivestar(0);
$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');
// Tests 'Thumbs Up / Down' voting on Basic Page.
$this
->drupalLogin($this->users[0]);
$this
->drupalGet('node/2');
$this
->assertThumbsUpDown(0, 0);
// Vote 'Up'.
$this
->clickLink('Up');
$this
->assertThumbsUpDown(100, 0);
$session
->linkExists('Undo');
// Unvote 'Up'.
$this
->clickLink('Undo');
$this
->assertThumbsUpDown(0, 0);
$session
->linkNotExists('Undo');
// Vote 'Up'.
$this
->clickLink('Up');
$this
->assertThumbsUpDown(100, 0);
$session
->linkExists('Undo');
// Log in as different user.
$this
->drupalLogin($this->users[1]);
$this
->drupalGet('node/2');
$this
->assertThumbsUpDown(100, 0);
$session
->linkNotExists('Undo');
// Vote 'Down'.
$this
->clickLink('Down');
$this
->assertThumbsUpDown(50, 50);
$session
->linkExists('Undo');
// Log in as different user.
$this
->drupalLogin($this->users[2]);
$this
->drupalGet('node/2');
$this
->assertThumbsUpDown(50, 50);
$session
->linkNotExists('Undo');
// Vote 'Up'.
$this
->clickLink('Up');
$this
->assertThumbsUpDown(67, 33);
$session
->linkExists('Undo');
}