/**
  * Checks if an Object has been rated by a user
  *
  * @param  BaseObject  $object
  * @param  mixed       $user_id  Unique reference to a user
  **/
 public function hasBeenRatedByUser(BaseObject $object, $user_id)
 {
     if (is_null($user_id) or trim((string) $user_id) === '') {
         throw new sfPropelActAsRatableException('Impossible to check a user rating with no user primary key provided');
     }
     $c = new Criteria();
     $c->add(sfRatingPeer::RATABLE_ID, $object->getReferenceKey());
     $c->add(sfRatingPeer::RATABLE_MODEL, get_class($object));
     $c->add(sfRatingPeer::USER_ID, $user_id);
     return sfRatingPeer::doCount($c) > 0;
 }
$obj->clearRatings();
$obj2->clearRatings();
sfConfig::set(sprintf('propel_behavior_sfPropelActAsRatableBehavior_%s_max_rating', get_class($obj)), 12);
$obj->setRating(6, $user_1_id);
$obj->setRating(6, $user_2_id);
$t->is($obj->getRating(), 6, 'getRating() base12 ok');
$obj->setRating(12, $user_2_id);
$t->is($obj->getRating(), 9, 'getRating() base12 ok');
$obj->setRating(3, $user_1_id);
$t->is($obj->getRating(), 7.5, 'getRating() base12 ok');
// Testing ratings details retrieval
$obj->setRating(6, $user_1_id);
$obj->setRating(6, $user_2_id);
$obj->setRating(7, $user_3_id);
$details = $obj->getRatingDetails();
$t->is(count($details), 2, 'getRatingDetails() count ok');
$t->is_deeply($details, array(6 => 2, 7 => 1), 'getRatingDetails() results are conform');
$full_details = $obj->getRatingDetails(true);
$t->is(count($full_details), 12, 'getRatingDetails(true) count ok');
$expected = array(0 => 0, 1 => 0, 2 => 0, 3 => 0, 4 => 0, 5 => 0, 6 => 2, 7 => 1, 8 => 0, 9 => 0, 10 => 0, 11 => 0, 12 => 0);
$t->is_deeply($full_details, $expected, 'getRatingDetails(true) results are conform');
// Testing cascade deletion
$obj_key = $obj->getPrimaryKey();
$obj->delete();
$c = new Criteria();
$c->add(sfRatingPeer::RATABLE_ID, $obj_key);
$count = sfRatingPeer::doCount($c);
$t->is($count, 0, 'doCount() No more rating records for deleted object');
// Delete remaining object
$obj2->delete();
$t->diag('Tests are now terminated');