protected function LikeAndDislikeTest::assertLikesAndDislikes in Like & Dislike 8
Asserts likes and dislikes markup and their number.
Parameters
string $entity_type_id: The entity type ID.
string $entity_id: The entity ID.
string $likes: (optional) The number of likes. Default to zero.
string $dislikes: (optional) The number of dislikes. Default to zero.
bool $disabled: (optional) If TRUE disabled CSS class is checked.
3 calls to LikeAndDislikeTest::assertLikesAndDislikes()
- LikeAndDislikeTest::testUserEntity in tests/
src/ FunctionalJavascript/ LikeAndDislikeTest.php - Asserts likes and dislikes for users.
- LikeAndDislikeTest::testVisibility in tests/
src/ FunctionalJavascript/ LikeAndDislikeTest.php - Tests likes visibility.
- LikeAndDislikeTest::testVoting in tests/
src/ FunctionalJavascript/ LikeAndDislikeTest.php - Asserts module voting.
File
- tests/
src/ FunctionalJavascript/ LikeAndDislikeTest.php, line 561
Class
- LikeAndDislikeTest
- Provides a web test for like_and_dislike module.
Namespace
Drupal\Tests\like_and_dislike\FunctionalJavascriptCode
protected function assertLikesAndDislikes($entity_type_id, $entity_id, $likes = '0', $dislikes = '0', $disabled = FALSE) {
// Assert likes.
$like_container_id = '#like-container-' . $entity_type_id . '-' . $entity_id;
$this
->assertSession()
->elementAttributeContains('css', $like_container_id . ' a', 'data-entity-type', $entity_type_id);
$this
->assertSession()
->elementAttributeContains('css', $like_container_id . ' a', 'data-entity-id', $entity_id);
$this
->assertSession()
->elementContains('css', $like_container_id . ' span.count', $likes);
// Assert dislikes.
$dislike_container_id = '#dislike-container-' . $entity_type_id . '-' . $entity_id;
$this
->assertSession()
->elementAttributeContains('css', $dislike_container_id . ' a', 'data-entity-type', $entity_type_id);
$this
->assertSession()
->elementAttributeContains('css', $dislike_container_id . ' a', 'data-entity-id', $entity_id);
$this
->assertSession()
->elementContains('css', $dislike_container_id . ' span.count', $dislikes);
if ($disabled) {
$this
->assertSession()
->elementExists('css', $like_container_id . ' a.disable-status');
$this
->assertSession()
->elementExists('css', $dislike_container_id . ' a.disable-status');
}
}