mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-21 07:03:49 +00:00
cs: Switch to a stricter way of coding - this might break in a lot of places.
This commit is contained in:
@@ -7,6 +7,15 @@
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers.
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Chill\ActivityBundle\Tests\Controller;
|
||||
|
||||
use RuntimeException;
|
||||
@@ -19,11 +28,11 @@ use function in_array;
|
||||
* @internal
|
||||
* @coversNothing
|
||||
*/
|
||||
class ActivityControllerTest extends WebTestCase
|
||||
final class ActivityControllerTest extends WebTestCase
|
||||
{
|
||||
public function getSecuredPagesAuthenticated()
|
||||
{
|
||||
static::bootKernel();
|
||||
self::bootKernel();
|
||||
|
||||
$person = $this->getPersonFromFixtures();
|
||||
$activities = $this->getActivitiesForPerson($person);
|
||||
@@ -59,7 +68,7 @@ class ActivityControllerTest extends WebTestCase
|
||||
*/
|
||||
public function getSecuredPagesUnauthenticated()
|
||||
{
|
||||
static::bootKernel();
|
||||
self::bootKernel();
|
||||
$person = $this->getPersonFromFixtures();
|
||||
$activities = $this->getActivitiesForPerson($person);
|
||||
|
||||
@@ -202,7 +211,7 @@ class ActivityControllerTest extends WebTestCase
|
||||
*/
|
||||
private function createFakeUser()
|
||||
{
|
||||
$container = static::$kernel->getContainer();
|
||||
$container = self::$kernel->getContainer();
|
||||
$em = $container->get('doctrine.orm.entity_manager');
|
||||
|
||||
//get the social PermissionGroup, and remove CHILL_ACTIVITY_*
|
||||
@@ -244,7 +253,7 @@ class ActivityControllerTest extends WebTestCase
|
||||
|
||||
private function getActivitiesForPerson(\Chill\PersonBundle\Entity\Person $person)
|
||||
{
|
||||
$em = static::$kernel->getContainer()
|
||||
$em = self::$kernel->getContainer()
|
||||
->get('doctrine.orm.entity_manager');
|
||||
|
||||
$activities = $em->getRepository('ChillActivityBundle:Activity')
|
||||
@@ -265,7 +274,7 @@ class ActivityControllerTest extends WebTestCase
|
||||
*/
|
||||
private function getAuthenticatedClient($username = 'center a_social')
|
||||
{
|
||||
return static::createClient([], [
|
||||
return self::createClient([], [
|
||||
'PHP_AUTH_USER' => $username,
|
||||
'PHP_AUTH_PW' => 'password',
|
||||
]);
|
||||
@@ -276,7 +285,7 @@ class ActivityControllerTest extends WebTestCase
|
||||
*/
|
||||
private function getPersonFromFixtures()
|
||||
{
|
||||
$em = static::$kernel->getContainer()
|
||||
$em = self::$kernel->getContainer()
|
||||
->get('doctrine.orm.entity_manager');
|
||||
|
||||
$person = $em->getRepository('ChillPersonBundle:Person')
|
||||
@@ -300,14 +309,14 @@ class ActivityControllerTest extends WebTestCase
|
||||
*/
|
||||
private function getRandomActivityReason(array $excludeIds = [])
|
||||
{
|
||||
$reasons = static::$kernel->getContainer()
|
||||
$reasons = self::$kernel->getContainer()
|
||||
->get('doctrine.orm.entity_manager')
|
||||
->getRepository('ChillActivityBundle:ActivityReason')
|
||||
->findAll();
|
||||
|
||||
$reason = $reasons[array_rand($reasons)];
|
||||
|
||||
if (in_array($reason->getId(), $excludeIds)) {
|
||||
if (in_array($reason->getId(), $excludeIds, true)) {
|
||||
return $this->getRandomActivityReason($excludeIds);
|
||||
}
|
||||
|
||||
@@ -319,7 +328,7 @@ class ActivityControllerTest extends WebTestCase
|
||||
*/
|
||||
private function getRandomActivityType()
|
||||
{
|
||||
$types = static::$kernel->getContainer()
|
||||
$types = self::$kernel->getContainer()
|
||||
->get('doctrine.orm.entity_manager')
|
||||
->getRepository('ChillActivityBundle:ActivityType')
|
||||
->findAll();
|
||||
@@ -335,7 +344,7 @@ class ActivityControllerTest extends WebTestCase
|
||||
*/
|
||||
private function getRandomScope($username, $centerName)
|
||||
{
|
||||
$user = static::$kernel->getContainer()
|
||||
$user = self::$kernel->getContainer()
|
||||
->get('doctrine.orm.entity_manager')
|
||||
->getRepository('ChillMainBundle:User')
|
||||
->findOneByUsername($username);
|
||||
@@ -345,20 +354,20 @@ class ActivityControllerTest extends WebTestCase
|
||||
. 'does not exists in database. Did you add fixtures ?');
|
||||
}
|
||||
|
||||
$center = static::$kernel->getContainer()
|
||||
$center = self::$kernel->getContainer()
|
||||
->get('doctrine.orm.entity_manager')
|
||||
->getRepository('ChillMainBundle:Center')
|
||||
->findOneByName($centerName);
|
||||
|
||||
// get scope reachable by both role UPDATE and DELETE
|
||||
$reachableScopesUpdate = static::$kernel->getContainer()
|
||||
$reachableScopesUpdate = self::$kernel->getContainer()
|
||||
->get('chill.main.security.authorization.helper')
|
||||
->getReachableScopes(
|
||||
$user,
|
||||
new Role('CHILL_ACTIVITY_UPDATE'),
|
||||
$center
|
||||
);
|
||||
$reachableScopesDelete = static::$kernel->getContainer()
|
||||
$reachableScopesDelete = self::$kernel->getContainer()
|
||||
->get('chill.main.security.authorization.helper')
|
||||
->getReachableScopes(
|
||||
$user,
|
||||
@@ -376,7 +385,7 @@ class ActivityControllerTest extends WebTestCase
|
||||
}
|
||||
|
||||
foreach ($reachableScopesUpdate as $scope) {
|
||||
if (in_array($scope->getId(), $reachableScopesId)) {
|
||||
if (in_array($scope->getId(), $reachableScopesId, true)) {
|
||||
$reachableScopes[] = $scope;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user