apply more cs rules for php-cs

This commit is contained in:
2023-10-17 13:27:03 +02:00
parent 0b0cbed9db
commit bc2041cbdd
1485 changed files with 8169 additions and 9620 deletions

View File

@@ -12,14 +12,12 @@ declare(strict_types=1);
namespace Chill\ActivityBundle\Tests\Controller;
use Chill\ActivityBundle\Entity\ActivityType;
use RuntimeException;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
use Symfony\Component\Security\Core\Role\Role;
use function count;
use function in_array;
/**
* @internal
*
* @coversNothing
*/
final class ActivityControllerTest extends WebTestCase
@@ -206,19 +204,19 @@ final class ActivityControllerTest extends WebTestCase
$container = self::$kernel->getContainer();
$em = $container->get('doctrine.orm.entity_manager');
//get the social PermissionGroup, and remove CHILL_ACTIVITY_*
// get the social PermissionGroup, and remove CHILL_ACTIVITY_*
$socialPermissionGroup = $em
->getRepository(\Chill\MainBundle\Entity\PermissionsGroup::class)
->findOneByName('social');
$withoutActivityPermissionGroup = (new \Chill\MainBundle\Entity\PermissionsGroup())
->setName('social without activity');
//copy role scopes where ACTIVITY is not present
// copy role scopes where ACTIVITY is not present
foreach ($socialPermissionGroup->getRoleScopes() as $roleScope) {
if (!strpos((string) $roleScope->getRole(), 'ACTIVITY')) {
$withoutActivityPermissionGroup->addRoleScope($roleScope);
}
}
//create groupCenter
// create groupCenter
$groupCenter = new \Chill\MainBundle\Entity\GroupCenter();
$groupCenter->setCenter($em->getRepository(\Chill\MainBundle\Entity\Center::class)
->findOneBy(['name' => 'Center A']))
@@ -226,7 +224,7 @@ final class ActivityControllerTest extends WebTestCase
$em->persist($withoutActivityPermissionGroup);
$em->persist($groupCenter);
//create user
// create user
$faker = \Faker\Factory::create();
$username = $faker->name;
$user = new \Chill\MainBundle\Entity\User();
@@ -251,9 +249,8 @@ final class ActivityControllerTest extends WebTestCase
$activities = $em->getRepository(\Chill\ActivityBundle\Entity\Activity::class)
->findBy(['person' => $person]);
if (count($activities) === 0) {
throw new RuntimeException('We need activities associated with this '
. 'person. Did you forget to add fixtures ?');
if (0 === \count($activities)) {
throw new \RuntimeException('We need activities associated with this person. Did you forget to add fixtures ?');
}
return $activities;
@@ -285,8 +282,7 @@ final class ActivityControllerTest extends WebTestCase
]);
if (null === $person) {
throw new RuntimeException('We need a person with firstname Gérard and'
. ' lastname Depardieu. Did you add fixtures ?');
throw new \RuntimeException('We need a person with firstname Gérard and lastname Depardieu. Did you add fixtures ?');
}
return $person;
@@ -306,7 +302,7 @@ final class ActivityControllerTest extends WebTestCase
$reason = $reasons[array_rand($reasons)];
if (in_array($reason->getId(), $excludeIds, true)) {
if (\in_array($reason->getId(), $excludeIds, true)) {
return $this->getRandomActivityReason($excludeIds);
}
@@ -340,8 +336,7 @@ final class ActivityControllerTest extends WebTestCase
->findOneByUsername($username);
if (null === $user) {
throw new RuntimeException("The user with username {$username} "
. 'does not exists in database. Did you add fixtures ?');
throw new \RuntimeException("The user with username {$username} ".'does not exists in database. Did you add fixtures ?');
}
$center = self::$kernel->getContainer()
@@ -369,13 +364,12 @@ final class ActivityControllerTest extends WebTestCase
array_map(static fn ($s) => $s->getId(), $reachableScopesUpdate)
);
if (count($reachableScopesId) === 0) {
throw new RuntimeException('there are not scope reachable for '
. 'both CHILL_ACTIVITY_UPDATE and CHILL_ACTIVITY_DELETE');
if (0 === \count($reachableScopesId)) {
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, true)) {
if (\in_array($scope->getId(), $reachableScopesId, true)) {
$reachableScopes[] = $scope;
}
}