Skip to content

Instantly share code, notes, and snippets.

@nsanden
Created April 19, 2014 03:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nsanden/11073008 to your computer and use it in GitHub Desktop.
Save nsanden/11073008 to your computer and use it in GitHub Desktop.
public function testGetVotedFor()
{
$contestant1 = new stdClass;
$contestant1->name = 'Michael Jordan';
$contestant1->id = 1;
$contestant2 = new stdClass;
$contestant2->name = 'Patrick Ewing';
$contestant2->id = 2;
$comment['message'] = 'I really like Michael Jordan';
$this-assertEquals(getVotedFor($comment, $contestant1, $contestant2), 1);
$comment['message'] = 'Micshael is cool!';
$this-assertFalse(getVotedFor($comment, $contestant1, $contestant2));
$comment['message'] = 'patrick ewing is better!';
$this-assertEquals(getVotedFor($comment, $contestant1, $contestant2), 2);
$comment['message'] = 'patrickewing is better!';
$this-assertEquals(getVotedFor($comment, $contestant1, $contestant2), 2);
$comment['message'] = 'Michael patrickewing is better!';
$this-assertEquals(getVotedFor($comment, $contestant1, $contestant2), 1);
$contestant3 = new stdClass;
$contestant3->name = 'Kevin Levrone';
$contestant3->id = 1;
$contestant4 = new stdClass;
$contestant4->name = 'Tom Platz';
$contestant4->id = 2;
$comment['message'] = 'Kevin Levrone - I think Tom Platz is awesome, but not in the same league ( partly because of the era)';
$this-assertEquals(getVotedFor($comment, $contestant3, $contestant4), 1);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment