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

@@ -28,22 +28,20 @@ use Doctrine\ORM\QueryBuilder;
use Prophecy\Argument;
use Prophecy\Prophet;
use Psr\Log\LoggerInterface;
use RuntimeException;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage;
use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
use Symfony\Component\Security\Core\Role\Role;
use Symfony\Component\Security\Core\User\UserInterface;
use Symfony\Contracts\Translation\TranslatorInterface;
use function count;
/**
* Test the export manager.
*
* @internal
*
* @coversNothing
*/
final class ExportManagerTest extends KernelTestCase
@@ -111,23 +109,22 @@ final class ExportManagerTest extends KernelTestCase
$filters
);
$obtained = iterator_to_array($exportManager->getAggregatorsApplyingOn($exportFoo, $centers));
$this->assertEquals(1, count($obtained));
$this->assertEquals(1, \count($obtained));
$this->assertContains('foo', array_keys($obtained));
$obtained = iterator_to_array($exportManager->getAggregatorsApplyingOn($exportBar, $centers));
$this->assertEquals(1, count($obtained));
$this->assertEquals(1, \count($obtained));
$this->assertContains('bar', array_keys($obtained));
$obtained = iterator_to_array($exportManager->getAggregatorsApplyingOn($exportFooBar, $centers));
$this->assertEquals(2, count($obtained));
$this->assertEquals(2, \count($obtained));
$this->assertContains('bar', array_keys($obtained));
$this->assertContains('foo', array_keys($obtained));
// test with empty centers
$obtained = iterator_to_array($exportManager->getAggregatorsApplyingOn($exportFooBar, []));
$this->assertEquals(0, count($obtained));
$this->assertEquals(0, \count($obtained));
}
public function testFiltersApplyingOn()
@@ -161,27 +158,27 @@ final class ExportManagerTest extends KernelTestCase
);
$obtained = iterator_to_array($exportManager->getFiltersApplyingOn($exportFoo, $centers));
$this->assertEquals(1, count($obtained));
$this->assertEquals(1, \count($obtained));
$this->assertContains('foo', array_keys($obtained));
$obtained = iterator_to_array($exportManager->getFiltersApplyingOn($exportBar, $centers));
$this->assertEquals(1, count($obtained));
$this->assertEquals(1, \count($obtained));
$this->assertContains('bar', array_keys($obtained));
$obtained = iterator_to_array($exportManager->getFiltersApplyingOn($exportFooBar, $centers));
$this->assertEquals(2, count($obtained));
$this->assertEquals(2, \count($obtained));
$this->assertContains('bar', array_keys($obtained));
$this->assertContains('foo', array_keys($obtained));
$obtained = iterator_to_array($exportManager->getFiltersApplyingOn($exportFooBar, []));
$this->assertEquals(0, count($obtained));
$this->assertEquals(0, \count($obtained));
}
public function testFormattersByTypes()
{
$exportManager = $this->createExportManager();
//create a formatter
// create a formatter
$formatterFoo = $this->prophet->prophesize();
$formatterFoo->willImplement(\Chill\MainBundle\Export\FormatterInterface::class);
$formatterFoo->getType()->willReturn('foo');
@@ -259,7 +256,7 @@ final class ExportManagerTest extends KernelTestCase
case '_header':
return 'export';
default: throw new RuntimeException(sprintf('The value %s is not valid', $value));
default: throw new \RuntimeException(sprintf('The value %s is not valid', $value));
}
});
@@ -297,7 +294,7 @@ final class ExportManagerTest extends KernelTestCase
'_header' => 'foo_header',
'cat a' => 'label cat a',
'cat b' => 'label cat b',
default => throw new RuntimeException(sprintf('This value (%s) is not valid', $value)),
default => throw new \RuntimeException(sprintf('This value (%s) is not valid', $value)),
});
$aggregator->addRole()->willReturn(null);
$aggregator->addRole()->shouldBeCalled();
@@ -314,7 +311,7 @@ final class ExportManagerTest extends KernelTestCase
$filters
);
//add formatter interface
// add formatter interface
$formatter = new \Chill\MainBundle\Export\Formatter\SpreadSheetFormatter(
self::$container->get(TranslatorInterface::class),
$exportManager
@@ -486,7 +483,7 @@ final class ExportManagerTest extends KernelTestCase
public function testNonExistingFormatter()
{
$this->expectException(RuntimeException::class);
$this->expectException(\RuntimeException::class);
$exportManager = $this->createExportManager();
@@ -501,11 +498,11 @@ final class ExportManagerTest extends KernelTestCase
* user 'center a_social' from database.
*/
protected function createExportManager(
?LoggerInterface $logger = null,
?EntityManagerInterface $em = null,
?AuthorizationCheckerInterface $authorizationChecker = null,
?AuthorizationHelper $authorizationHelper = null,
?UserInterface $user = null,
LoggerInterface $logger = null,
EntityManagerInterface $em = null,
AuthorizationCheckerInterface $authorizationChecker = null,
AuthorizationHelper $authorizationHelper = null,
UserInterface $user = null,
array $exports = [],
array $aggregators = [],
array $filters = [],
@@ -541,20 +538,26 @@ class DummyFilterWithApplying implements FilterInterface
{
return 'dummy';
}
public function buildForm(FormBuilderInterface $builder) {}
public function getFormDefaultData(): array
{
return [];
}
public function describeAction($data, $format = 'string')
{
return ['dummy filter', []];
}
public function addRole(): ?string
{
return $this->role;
}
public function alterQuery(QueryBuilder $qb, $data) {}
public function applyOn()
{
return $this->applyOn;