function VotingAPITestCase::validateVote in Voting API 7.2
Same name and namespace in other branches
- 6.2 tests/votingapi.test \VotingAPITestCase::validateVote()
- 7.3 tests/votingapi.test \VotingAPITestCase::validateVote()
3 calls to VotingAPITestCase::validateVote()
- VotingAPITestCase::testAddMultipleVotes in tests/
votingapi.test - Add multiple votes and ensure that the vote calculations are working.
- VotingAPITestCase::testAddVote in tests/
votingapi.test - Add a vote and ensure that the vote was stored properly.
- VotingAPITestCase::testMinimalAdd in tests/
votingapi.test - Ensure that the optional fields are truly optional.
File
- tests/
votingapi.test, line 124 - Test file for VotingAPI module.
Class
- VotingAPITestCase
- @file Test file for VotingAPI module.
Code
function validateVote($prefix, $vote, $entity_id, $value, $entity_type = 'node', $uid = NULL, $value_type = 'percent', $tag = 'vote', $vote_source = NULL) {
global $user;
if ($vote_source == NULL) {
$vote_source = hash('sha256', serialize(ip_address()));
}
$prefix_array = array(
'@prefix' => $prefix,
);
for ($index = 0; $index < count($vote); $index++) {
$this
->assertTrue($vote[$index]['entity_id'] == $entity_id, t('@prefix: entity_id should match.', $prefix_array));
$this
->assertTrue($vote[$index]['value'] == $value[$index], t('@prefix: value should match.', $prefix_array));
$this
->assertTrue($vote[$index]['entity_type'] == $entity_type, t('@prefix: entity_type should match, default = "node".', $prefix_array));
$this
->assertTrue($vote[$index]['value_type'] == $value_type, t('@prefix: value_type should match, default= "percent".', $prefix_array));
$this
->assertTrue($vote[$index]['tag'] == $tag, t('@prefix: tag should match, default = "vote".', $prefix_array));
$this
->assertTrue($vote[$index]['vote_source'] == $vote_source, t('@prefix: vote_source should match, default = ip address hash.', $prefix_array));
if ($uid != NULL) {
$this
->assertTrue($vote[0]['uid'] == $uid, t('@prefix: uid should match.', $prefix_array));
}
}
}