adding the possibility to remove activities

fix #28
This commit is contained in:
2016-06-08 21:26:30 +02:00
parent dfaa4b0968
commit 1e476b39da
10 changed files with 152 additions and 25 deletions

View File

@@ -154,6 +154,22 @@ class ActivityControllerTest extends WebTestCase
$this->assertGreaterThan(0,
$crawler->filter('dd:contains("Foo")')->count(),
'Missing element dd:contains("Foo")');
// delete the actvity
$crawler = $client->click($crawler->selectLink("Supprimer")->link());
$button = $crawler->selectButton('Supprimer');
$form = $button->form();
$client->submit($form);
$this->assertTrue($client->getResponse()->isRedirect(sprintf('/en/person/%d/activity/',
$person->getId())));
$crawler = $client->followRedirect();
$this->assertNotContains('January 25, 2015', $crawler->text());
}
/**
@@ -230,10 +246,29 @@ class ActivityControllerTest extends WebTestCase
->getRepository('ChillMainBundle:Center')
->findOneByName($centerName);
$reachableScopes = static::$kernel->getContainer()
// get scope reachable by both role UPDATE and DELETE
$reachableScopesUpdate = static::$kernel->getContainer()
->get('chill.main.security.authorization.helper')
->getReachableScopes($user, new Role('CHILL_ACTIVITY_UPDATE'),
$center);
$reachableScopesDelete = static::$kernel->getContainer()
->get('chill.main.security.authorization.helper')
->getReachableScopes($user, new Role('CHILL_ACTIVITY_DELETE'),
$center);
$reachableScopesId = array_intersect(
array_map(function ($s) { return $s->getId(); }, $reachableScopesDelete),
array_map(function ($s) { return $s->getId(); }, $reachableScopesUpdate)
);
if (count($reachableScopesId) === 0) {
throw new \RuntimeException("there are not scope reachable for "
. "both CHILL_ACTIVITY_UPDATE and CHILL_ACTIVITY_DELETE");
}
foreach($reachableScopesUpdate as $scope) {
if (in_array($scope->getId(), $reachableScopesId)) {
$reachableScopes[] = $scope;
}
}
return $reachableScopes[array_rand($reachableScopes)];
}