trait NodeVoteTrait in Rate 8
Same name and namespace in other branches
- 8.2 tests/src/Traits/NodeVoteTrait.php \Drupal\Tests\rate\Traits\NodeVoteTrait
Provides methods to voting on nodes.
This trait is meant to be used only by Functional and FunctionalJavascript test classes.
Hierarchy
- trait \Drupal\Tests\rate\Traits\NodeVoteTrait
7 files declare their use of NodeVoteTrait
- NodeFivestarWidgetTest.php in tests/
src/ Functional/ NodeFivestarWidgetTest.php - NodeFivestarWidgetTest.php in tests/
src/ FunctionalJavascript/ NodeFivestarWidgetTest.php - NodeMultipleWidgetTest.php in tests/
src/ Functional/ NodeMultipleWidgetTest.php - NodeMultipleWidgetTest.php in tests/
src/ FunctionalJavascript/ NodeMultipleWidgetTest.php - RateMultilingualTest.php in tests/
src/ Functional/ RateMultilingualTest.php
File
- tests/
src/ Traits/ NodeVoteTrait.php, line 11
Namespace
Drupal\Tests\rate\TraitsView source
trait NodeVoteTrait {
/**
* Vote "Fivestar" by node id.
*
* @param int $nid
* The node id.
* @param int $stars
* The number of stars vote (from 1 to 5).
*/
protected function voteFivestarById($nid, $stars) {
$this
->assertSession()
->elementExists('css', '.rate-fivestar-1');
$node_selector = '[data-drupal-selector="rate-node-' . $nid . '"]';
$this
->click($node_selector . ' .rate-fivestar-' . $stars);
}
/**
* Un-vote "Fivestar" by node id.
*
* @param int $nid
* The node id.
*/
protected function unVoteFivestarById($nid) {
$this
->assertSession()
->elementExists('css', '.rate-fivestar-1');
$node_selector = '[data-drupal-selector="rate-node-' . $nid . '"]';
$this
->click($node_selector . ' .rate-undo');
}
/**
* Vote Fivestar for the single node.
*
* @param int $stars
* The number of stars vote (from 1 to 5).
*/
protected function voteFivestar($stars) {
$this
->assertSession()
->elementExists('css', '.rate-widget-fivestar');
$this
->click('.rate-fivestar-' . $stars);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
NodeVoteTrait:: |
protected | function | Un-vote "Fivestar" by node id. | |
NodeVoteTrait:: |
protected | function | Vote Fivestar for the single node. | |
NodeVoteTrait:: |
protected | function | Vote "Fivestar" by node id. |