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:
2016-02-22 14:48:35 +01:00
parent 65e7a130c5
commit c60d6acf97
11 changed files with 197 additions and 39 deletions

View File

@@ -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;
}
/**