mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-03 21:34:59 +00:00
@@ -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)];
|
||||
}
|
||||
|
Reference in New Issue
Block a user