Enhanced push tests

This commit is contained in:
Romain Neutron
2012-01-26 16:58:50 +01:00
parent 5941bc73e3
commit f7cc38ea25
2 changed files with 328 additions and 320 deletions

View File

@@ -214,6 +214,8 @@ class Push implements ControllerProviderInterface
$em->flush(); $em->flush();
} }
$em->refresh($Basket);
if (!$Basket->getValidation()) if (!$Basket->getValidation())
{ {
$Validation = new \Entities\ValidationSession(); $Validation = new \Entities\ValidationSession();
@@ -233,6 +235,12 @@ class Push implements ControllerProviderInterface
foreach ($participants as $participant) foreach ($participants as $participant)
{ {
foreach (array('see_others', 'usr_id', 'agree', 'HD') as $mandatoryparam)
{
if (!array_key_exists($mandatoryparam, $participant))
throw new ControllerException(sprintf(_('Missing mandatory participant parameter %s'), $mandatoryparam));
}
try try
{ {
$participant_user = \User_Adapter::getInstance($participant['usr_id'], $appbox); $participant_user = \User_Adapter::getInstance($participant['usr_id'], $appbox);
@@ -265,7 +273,7 @@ class Push implements ControllerProviderInterface
{ {
$ValidationData = new \Entities\ValidationData(); $ValidationData = new \Entities\ValidationData();
$ValidationData->setParticipant($Participant); $ValidationData->setParticipant($Participant);
$validationData->setBasketElement($BasketElement); $ValidationData->setBasketElement($BasketElement);
$BasketElement->addValidationData($ValidationData); $BasketElement->addValidationData($ValidationData);
if ($participant['HD']) if ($participant['HD'])
@@ -286,7 +294,7 @@ class Push implements ControllerProviderInterface
} }
$em->merge($BasketElement); $em->merge($BasketElement);
$em->persists($ValidationData); $em->persist($ValidationData);
$Participant->addValidationData($ValidationData); $Participant->addValidationData($ValidationData);
} }
@@ -300,9 +308,9 @@ class Push implements ControllerProviderInterface
$em->flush(); $em->flush();
$message = sprintf( $message = sprintf(
_('%1$d records have been sent to %2$d users') _('%1$d records have been sent for validation to %2$d users')
, count($pusher->get_elements()) , count($pusher->get_elements())
, count($request->get('receivers')) , count($request->get('$participants'))
); );
$ret = array( $ret = array(

View File

@@ -102,13 +102,13 @@ class ControllerPushTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
'usr_id' => self::$user_alt1->get_id(), 'usr_id' => self::$user_alt1->get_id(),
'agree'=> 0, 'agree'=> 0,
'see_others'=> 1, 'see_others'=> 1,
'HS'=> 0, 'HD'=> 0,
) )
, array( , array(
'usr_id' => self::$user_alt2->get_id(), 'usr_id' => self::$user_alt2->get_id(),
'agree'=> 1, 'agree'=> 1,
'see_others'=> 0, 'see_others'=> 0,
'HS'=> 1, 'HD'=> 1,
) )
); );