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

@@ -24,10 +24,10 @@ use Chill\MainBundle\Test\PrepareScopeTrait;
use Chill\MainBundle\Test\PrepareUserTrait;
use Prophecy\PhpUnit\ProphecyTrait;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
use function in_array;
/**
* @internal
*
* @coversNothing
*/
final class AuthorizationHelperTest extends KernelTestCase
@@ -78,7 +78,7 @@ final class AuthorizationHelperTest extends KernelTestCase
// without scopes
[
true,
in_array($centerA, $ah->getReachableCenters(
\in_array($centerA, $ah->getReachableCenters(
$userA,
'CHILL_ROLE_1',
null
@@ -87,7 +87,7 @@ final class AuthorizationHelperTest extends KernelTestCase
],
[
true,
in_array($centerA, $ah->getReachableCenters(
\in_array($centerA, $ah->getReachableCenters(
$userA,
'CHILL_ROLE_2',
null
@@ -96,7 +96,7 @@ final class AuthorizationHelperTest extends KernelTestCase
],
[
true,
in_array($centerB, $ah->getReachableCenters(
\in_array($centerB, $ah->getReachableCenters(
$userA,
'CHILL_ROLE_2',
null
@@ -105,7 +105,7 @@ final class AuthorizationHelperTest extends KernelTestCase
],
[
false,
in_array($centerB, $ah->getReachableCenters(
\in_array($centerB, $ah->getReachableCenters(
$userA,
'CHILL_ROLE_1',
null
@@ -115,7 +115,7 @@ final class AuthorizationHelperTest extends KernelTestCase
// with scope
[
true,
in_array($centerA, $ah->getReachableCenters(
\in_array($centerA, $ah->getReachableCenters(
$userA,
'CHILL_ROLE_1',
$scopeB
@@ -124,7 +124,7 @@ final class AuthorizationHelperTest extends KernelTestCase
],
[
false,
in_array($centerA, $ah->getReachableCenters(
\in_array($centerA, $ah->getReachableCenters(
$userA,
'CHILL_ROLE_2',
$scopeC
@@ -133,7 +133,7 @@ final class AuthorizationHelperTest extends KernelTestCase
],
[
true,
in_array($centerB, $ah->getReachableCenters(
\in_array($centerB, $ah->getReachableCenters(
$userA,
'CHILL_ROLE_2',
$scopeA
@@ -193,7 +193,7 @@ final class AuthorizationHelperTest extends KernelTestCase
'CHILL_ROLE_1',
$centerB,
'Assert that a scope not reachable is not found within accessible scopes.'
. ' Trying on filter centering',
.' Trying on filter centering',
],
];
}
@@ -224,7 +224,7 @@ final class AuthorizationHelperTest extends KernelTestCase
/**
* @dataProvider dataProvider_getReachableScopes
*
* @param bool $expectedResult
* @param bool $expectedResult
* @param string $message
*/
public function testGetReachableScopes(
@@ -240,7 +240,7 @@ final class AuthorizationHelperTest extends KernelTestCase
$this->assertEquals(
$expectedResult,
in_array($testedScope, $reachableScopes, true),
\in_array($testedScope, $reachableScopes, true),
$message
);
}
@@ -258,8 +258,8 @@ final class AuthorizationHelperTest extends KernelTestCase
]);
$helper = $this->getAuthorizationHelper();
$entity = $this->prophesize();
$entity->willImplement('\\' . \Chill\MainBundle\Entity\HasCenterInterface::class);
$entity->willImplement('\\' . \Chill\MainBundle\Entity\HasScopeInterface::class);
$entity->willImplement('\\'.\Chill\MainBundle\Entity\HasCenterInterface::class);
$entity->willImplement('\\'.\Chill\MainBundle\Entity\HasScopeInterface::class);
$entity->getCenter()->willReturn($center);
$entity->getScope()->willReturn($scope);
@@ -313,8 +313,8 @@ final class AuthorizationHelperTest extends KernelTestCase
{
$centerA = $this->prepareCenter(1, 'center');
$centerB = $this->prepareCenter(2, 'centerB');
$scopeA = $this->prepareScope(3, 'other'); //the user will be granted this scope
$scopeB = $this->prepareScope(4, 'other'); //the user will be granted this scope
$scopeA = $this->prepareScope(3, 'other'); // the user will be granted this scope
$scopeB = $this->prepareScope(4, 'other'); // the user will be granted this scope
$user = $this->prepareUser([
[
'center' => $centerA, 'permissionsGroup' => [
@@ -354,7 +354,7 @@ final class AuthorizationHelperTest extends KernelTestCase
{
$center = $this->prepareCenter(1, 'center');
$centerB = $this->prepareCenter(1, 'centerB');
$scopeB = $this->prepareScope(2, 'other'); //the user will be granted this scope
$scopeB = $this->prepareScope(2, 'other'); // the user will be granted this scope
$user = $this->prepareUser([
[
'center' => $center, 'permissionsGroup' => [
@@ -383,7 +383,7 @@ final class AuthorizationHelperTest extends KernelTestCase
]);
$helper = $this->getAuthorizationHelper();
$entity = $this->prophesize();
$entity->willImplement('\\' . \Chill\MainBundle\Entity\HasCenterInterface::class);
$entity->willImplement('\\'.\Chill\MainBundle\Entity\HasCenterInterface::class);
$entity->getCenter()->willReturn($center);
$this->assertTrue($helper->userHasAccess(
@@ -407,7 +407,7 @@ final class AuthorizationHelperTest extends KernelTestCase
$helper = $this->getAuthorizationHelper();
$entity = $this->prophesize();
$entity->willImplement('\\' . \Chill\MainBundle\Entity\HasCenterInterface::class);
$entity->willImplement('\\'.\Chill\MainBundle\Entity\HasCenterInterface::class);
$entity->getCenter()->willReturn($center);
$this->assertTrue($helper->userHasAccess(
@@ -419,8 +419,8 @@ final class AuthorizationHelperTest extends KernelTestCase
public function testUserHasAccessUserHasNoCenterEntityWithScope()
{
$centerA = $this->prepareCenter(1, 'center'); //the user will have this center
$centerB = $this->prepareCenter(2, 'centerB'); //the entity will have another center
$centerA = $this->prepareCenter(1, 'center'); // the user will have this center
$centerB = $this->prepareCenter(2, 'centerB'); // the entity will have another center
$scope = $this->prepareScope(1, 'default');
$user = $this->prepareUser([
[
@@ -431,8 +431,8 @@ final class AuthorizationHelperTest extends KernelTestCase
]);
$helper = $this->getAuthorizationHelper();
$entity = $this->prophesize();
$entity->willImplement('\\' . \Chill\MainBundle\Entity\HasCenterInterface::class);
$entity->willImplement('\\' . \Chill\MainBundle\Entity\HasScopeInterface::class);
$entity->willImplement('\\'.\Chill\MainBundle\Entity\HasCenterInterface::class);
$entity->willImplement('\\'.\Chill\MainBundle\Entity\HasScopeInterface::class);
$entity->getCenter()->willReturn($centerB);
$entity->getScope()->willReturn($scope);
@@ -452,7 +452,7 @@ final class AuthorizationHelperTest extends KernelTestCase
]);
$helper = $this->getAuthorizationHelper();
$entity = $this->prophesize();
$entity->willImplement('\\' . \Chill\MainBundle\Entity\HasCenterInterface::class);
$entity->willImplement('\\'.\Chill\MainBundle\Entity\HasCenterInterface::class);
$entity->getCenter()->willReturn($center);
$this->assertFalse($helper->userHasAccess($user, $entity->reveal(), 'CHILL_ROLE'));
@@ -471,8 +471,8 @@ final class AuthorizationHelperTest extends KernelTestCase
]);
$helper = $this->getAuthorizationHelper();
$entity = $this->prophesize();
$entity->willImplement('\\' . \Chill\MainBundle\Entity\HasCenterInterface::class);
$entity->willImplement('\\' . \Chill\MainBundle\Entity\HasScopeInterface::class);
$entity->willImplement('\\'.\Chill\MainBundle\Entity\HasCenterInterface::class);
$entity->willImplement('\\'.\Chill\MainBundle\Entity\HasScopeInterface::class);
$entity->getCenter()->willReturn($center);
$entity->getScope()->willReturn($scope);
@@ -503,7 +503,7 @@ final class AuthorizationHelperTest extends KernelTestCase
]);
$helper = $this->getAuthorizationHelper();
$entity = $this->prophesize();
$entity->willImplement('\\' . \Chill\MainBundle\Entity\HasCenterInterface::class);
$entity->willImplement('\\'.\Chill\MainBundle\Entity\HasCenterInterface::class);
$entity->getCenter()->willReturn($centerA);
$this->assertFalse($helper->userHasAccess($user, $entity->reveal(), 'CHILL_ROLE'));
@@ -512,8 +512,8 @@ final class AuthorizationHelperTest extends KernelTestCase
public function testUserHasAccessUserHasNoScopeEntityWithScope()
{
$center = $this->prepareCenter(1, 'center');
$scopeA = $this->prepareScope(1, 'default'); //the entity will have this scope
$scopeB = $this->prepareScope(2, 'other'); //the user will be granted this scope
$scopeA = $this->prepareScope(1, 'default'); // the entity will have this scope
$scopeB = $this->prepareScope(2, 'other'); // the user will be granted this scope
$user = $this->prepareUser([
[
'center' => $center, 'permissionsGroup' => [
@@ -535,9 +535,9 @@ final class AuthorizationHelperTest extends KernelTestCase
{
$centerA = $this->prepareCenter(1, 'center');
$centerB = $this->prepareCenter(2, 'centerB');
$scopeA = $this->prepareScope(3, 'other'); //the user will be granted this scope
$scopeB = $this->prepareScope(4, 'other'); //the user will be granted this scope
$scopeC = $this->prepareScope(5, 'other'); //the user will be granted this scope
$scopeA = $this->prepareScope(3, 'other'); // the user will be granted this scope
$scopeB = $this->prepareScope(4, 'other'); // the user will be granted this scope
$scopeC = $this->prepareScope(5, 'other'); // the user will be granted this scope
$user = $this->prepareUser([
[
'center' => $centerA, 'permissionsGroup' => [
@@ -560,7 +560,7 @@ final class AuthorizationHelperTest extends KernelTestCase
$center = $this->prepareCenter(1, 'center');
$centerB = $this->prepareCenter(2, 'centerB');
$centerC = $this->prepareCenter(3, 'centerC');
$scopeB = $this->prepareScope(4, 'other'); //the user will be granted this scope
$scopeB = $this->prepareScope(4, 'other'); // the user will be granted this scope
$user = $this->prepareUser([
[
'center' => $center, 'permissionsGroup' => [

View File

@@ -13,13 +13,11 @@ namespace Chill\MainBundle\Tests\Security\PasswordRecover;
use Chill\MainBundle\Entity\User;
use Chill\MainBundle\Security\PasswordRecover\TokenManager;
use DateInterval;
use DateTimeImmutable;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
use UnexpectedValueException;
/**
* @internal
*
* @coversNothing
*/
final class TokenManagerTest extends KernelTestCase
@@ -42,7 +40,7 @@ final class TokenManagerTest extends KernelTestCase
{
$tokenManager = $this->tokenManager;
$user = (new User())->setUsernameCanonical('test');
$expiration = new DateTimeImmutable('tomorrow');
$expiration = new \DateTimeImmutable('tomorrow');
$tokens = $tokenManager->generate($user, $expiration);
@@ -56,12 +54,12 @@ final class TokenManagerTest extends KernelTestCase
public function testGenerateEmptyUsernameCanonical()
{
$this->expectException(UnexpectedValueException::class);
$this->expectException(\UnexpectedValueException::class);
$tokenManager = $this->tokenManager;
// set a username, but not a username canonical
$user = (new User())->setUsername('test');
$expiration = new DateTimeImmutable('tomorrow');
$expiration = new \DateTimeImmutable('tomorrow');
$tokenManager->generate($user, $expiration);
}
@@ -70,7 +68,7 @@ final class TokenManagerTest extends KernelTestCase
{
$tokenManager = $this->tokenManager;
$user = (new User())->setUsernameCanonical('test');
$expiration = new DateTimeImmutable('tomorrow');
$expiration = new \DateTimeImmutable('tomorrow');
$tokens = $tokenManager->generate($user, $expiration);
@@ -83,8 +81,8 @@ final class TokenManagerTest extends KernelTestCase
$this->assertTrue($verification);
// test with altering token
$this->assertFalse($tokenManager->verify($hash . '5', $token, $user, $timestamp));
$this->assertFalse($tokenManager->verify($hash, $token . '25', $user, $timestamp));
$this->assertFalse($tokenManager->verify($hash.'5', $token, $user, $timestamp));
$this->assertFalse($tokenManager->verify($hash, $token.'25', $user, $timestamp));
$this->assertFalse($tokenManager->verify($hash, $token, $user->setUsernameCanonical('test2'), $timestamp));
$this->assertFalse($tokenManager->verify($hash, $token, $user, (string) ($timestamp + 1)));
}
@@ -93,7 +91,7 @@ final class TokenManagerTest extends KernelTestCase
{
$tokenManager = $this->tokenManager;
$user = (new User())->setUsernameCanonical('test');
$expiration = (new DateTimeImmutable('now'))->sub(new DateInterval('PT1S'));
$expiration = (new \DateTimeImmutable('now'))->sub(new \DateInterval('PT1S'));
$tokens = $tokenManager->generate($user, $expiration);

View File

@@ -18,6 +18,7 @@ use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
/**
* @internal
*
* @coversNothing
*/
final class CenterResolverDispatcherTest extends KernelTestCase

View File

@@ -19,6 +19,7 @@ use PHPUnit\Framework\TestCase;
/**
* @internal
*
* @coversNothing
*/
final class DefaultScopeResolverTest extends TestCase

View File

@@ -20,6 +20,7 @@ use PHPUnit\Framework\TestCase;
/**
* @internal
*
* @coversNothing
*/
final class ScopeResolverDispatcherTest extends TestCase
@@ -54,6 +55,7 @@ final class ScopeResolverDispatcherTest extends TestCase
* @var Scope[]
*/
private array $scopes = [];
public function __construct(Scope $scopeA, Scope $scopeB)
{
$this->scopes = [$scopeA, $scopeB];