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