mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-01 04:23:49 +00:00
An activity may have multiple reasons
The relationship between Activity and Reasons is now many-to-many. Some improvement in show activity layout. refs #4 #7
This commit is contained in:
@@ -106,6 +106,9 @@ class ActivityControllerTest extends WebTestCase
|
||||
"Unexpected HTTP status code for GET /activity/");
|
||||
$crawler = $client->click($crawler->selectLink('Ajouter une nouvelle activité')
|
||||
->link());
|
||||
|
||||
$reason1 = $this->getRandomActivityReason();
|
||||
$reason2 = $this->getRandomActivityReason(array($reason1->getId()));
|
||||
|
||||
// Fill in the form and submit it
|
||||
$form = $crawler->selectButton('Ajouter une nouvelle activité')->form(array(
|
||||
@@ -117,10 +120,10 @@ class ActivityControllerTest extends WebTestCase
|
||||
),
|
||||
'remark' => 'blabla',
|
||||
'scope' => $this->getRandomScope('center a_social', 'Center A')->getId(),
|
||||
'reason' => $this->getRandomActivityReason()->getId(),
|
||||
'type' => $this->getRandomActivityType()->getId()
|
||||
)
|
||||
));
|
||||
$form['chill_activitybundle_activity[reasons]']->select(array ($reason1->getId(), $reason2->getId()));
|
||||
|
||||
$client->submit($form);
|
||||
|
||||
@@ -240,16 +243,23 @@ class ActivityControllerTest extends WebTestCase
|
||||
|
||||
/**
|
||||
*
|
||||
* @param int[] $excludeIds An array of id to exclude
|
||||
* @return \Chill\ActivityBundle\Entity\ActivityReason
|
||||
*/
|
||||
private function getRandomActivityReason()
|
||||
private function getRandomActivityReason(array $excludeIds = array())
|
||||
{
|
||||
$reasons = static::$kernel->getContainer()
|
||||
->get('doctrine.orm.entity_manager')
|
||||
->getRepository('ChillActivityBundle:ActivityReason')
|
||||
->findAll();
|
||||
|
||||
return $reasons[array_rand($reasons)];
|
||||
$reason = $reasons[array_rand($reasons)];
|
||||
|
||||
if (in_array($reason->getId(), $excludeIds)) {
|
||||
return $this->getRandomActivityReason($excludeIds);
|
||||
}
|
||||
|
||||
return $reason;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user