From f251e6f1008051469d0536b7499dd9faf344a240 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Wed, 14 Feb 2024 12:28:14 +0100 Subject: [PATCH] upgrade phpunit: make data provider static --- rector.php | 6 ++ .../AsideActivityControllerTest.php | 2 +- .../Controller/CalendarControllerTest.php | 2 +- .../MSGraph/MSUserAbsenceReaderTest.php | 2 +- .../MSGraph/MSUserAbsenceSyncTest.php | 2 +- .../DefaultRangeGeneratorTest.php | 2 +- .../CustomFields/CustomFieldsChoiceTest.php | 4 +- .../Serializer/Encoder/DocGenEncoderTest.php | 2 +- .../TempUrlOpenstackGeneratorTest.php | 4 +- .../Templating/AsyncUploadExtensionTest.php | 2 +- ...ngCourseDocumentGenericDocProviderTest.php | 2 +- .../PersonDocumentGenericDocProviderTest.php | 2 +- .../PersonDocumentACLAwareRepositoryTest.php | 2 +- .../Tests/StoredObjectManagerTest.php | 2 +- .../EventACLAwareRepositoryTest.php | 2 +- .../Controller/AddressControllerTest.php | 2 +- .../AddressReferenceApiControllerTest.php | 2 +- .../Controller/SearchApiControllerTest.php | 2 +- .../Tests/Doctrine/DQL/AgeTest.php | 2 +- .../Doctrine/DQL/JsonBuildObjectTest.php | 2 +- .../Tests/Doctrine/DQL/JsonExtractTest.php | 2 +- .../Tests/Entity/NotificationTest.php | 2 +- .../Tests/Pagination/PageTest.php | 4 +- .../Tests/Pagination/PaginatorTest.php | 8 +- .../Phonenumber/PhonenumberHelperTest.php | 2 +- .../Utils/ExtractDateFromPatternTest.php | 2 +- .../ExtractPhonenumberFromPatternTest.php | 2 +- .../Normalizer/DateNormalizerTest.php | 2 +- .../DoctrineExistingEntityNormalizerTest.php | 2 +- .../Normalizer/PhonenumberNormalizerTest.php | 2 +- .../Normalizer/UserNormalizerTest.php | 2 +- .../RollingDate/RollingDateConverterTest.php | 2 +- .../Templating/Entity/AddressRenderTest.php | 18 ++--- ...ccompanyingPeriodStepChangeCronjobTest.php | 2 +- .../ConflictTest.php | 2 +- .../AccompanyingCourseApiControllerTest.php | 8 +- .../AccompanyingCourseControllerTest.php | 2 +- .../Controller/HouseholdApiControllerTest.php | 4 +- .../Controller/HouseholdControllerTest.php | 2 +- .../HouseholdMemberControllerTest.php | 4 +- .../Controller/PersonApiControllerTest.php | 4 +- ...onControllerUpdateWithHiddenFieldsTest.php | 2 +- .../PersonDuplicateControllerViewTest.php | 2 +- .../RelationshipApiControllerTest.php | 2 +- .../EventListener/PersonCreateEventTest.php | 4 +- .../ActiveOnDateFilterTest.php | 4 +- ...FilterListAccompanyingPeriodHelperTest.php | 7 +- ...companyingPeriodACLAwareRepositoryTest.php | 79 +++++++++++-------- .../Normalizer/PersonDocGenNormalizerTest.php | 4 +- .../AccompanyingPeriodContextTest.php | 2 +- .../DocGenerator/PersonContextTest.php | 2 +- ...ngPeriodCalendarGenericDocProviderTest.php | 14 ++-- ...odWorkEvaluationGenericDocProviderTest.php | 2 +- .../PersonCalendarGenericDocProviderTest.php | 7 +- .../Entity/ClosingMotiveRenderTest.php | 2 +- .../TimelineAccompanyingPeriodTest.php | 2 +- .../Household/MaxHolderValidatorTest.php | 2 +- 57 files changed, 142 insertions(+), 121 deletions(-) diff --git a/rector.php b/rector.php index ae5c97531..b46dd36a6 100644 --- a/rector.php +++ b/rector.php @@ -41,6 +41,12 @@ return static function (RectorConfig $rectorConfig): void { \Rector\PHPUnit\Set\PHPUnitLevelSetList::UP_TO_PHPUNIT_90, ]); + // migrate for phpunit + $rectorConfig->rules([ + \Rector\PHPUnit\PHPUnit100\Rector\Class_\StaticDataProviderClassMethodRector::class, + \Rector\PHPUnit\PHPUnit100\Rector\Class_\PublicDataProviderClassMethodRector::class + ]); + // some routes are added twice if it remains activated // $rectorConfig->rule(\Rector\Symfony\Configs\Rector\ClassMethod\AddRouteAnnotationRector::class); diff --git a/src/Bundle/ChillAsideActivityBundle/src/Tests/Controller/AsideActivityControllerTest.php b/src/Bundle/ChillAsideActivityBundle/src/Tests/Controller/AsideActivityControllerTest.php index 3c2137d84..21e78e6cf 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Tests/Controller/AsideActivityControllerTest.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Tests/Controller/AsideActivityControllerTest.php @@ -30,7 +30,7 @@ final class AsideActivityControllerTest extends WebTestCase self::ensureKernelShutdown(); } - public function generateAsideActivityId(): iterable + public static function generateAsideActivityId(): iterable { self::bootKernel(); diff --git a/src/Bundle/ChillCalendarBundle/Tests/Controller/CalendarControllerTest.php b/src/Bundle/ChillCalendarBundle/Tests/Controller/CalendarControllerTest.php index 37b97fcf9..ef2597367 100644 --- a/src/Bundle/ChillCalendarBundle/Tests/Controller/CalendarControllerTest.php +++ b/src/Bundle/ChillCalendarBundle/Tests/Controller/CalendarControllerTest.php @@ -42,7 +42,7 @@ final class CalendarControllerTest extends WebTestCase self::ensureKernelShutdown(); } - public function provideAccompanyingPeriod(): iterable + public static function provideAccompanyingPeriod(): iterable { self::bootKernel(); $em = self::getContainer()->get(EntityManagerInterface::class); diff --git a/src/Bundle/ChillCalendarBundle/Tests/RemoteCalendar/Connector/MSGraph/MSUserAbsenceReaderTest.php b/src/Bundle/ChillCalendarBundle/Tests/RemoteCalendar/Connector/MSGraph/MSUserAbsenceReaderTest.php index 4307f32a3..3d3a71854 100644 --- a/src/Bundle/ChillCalendarBundle/Tests/RemoteCalendar/Connector/MSGraph/MSUserAbsenceReaderTest.php +++ b/src/Bundle/ChillCalendarBundle/Tests/RemoteCalendar/Connector/MSGraph/MSUserAbsenceReaderTest.php @@ -59,7 +59,7 @@ class MSUserAbsenceReaderTest extends TestCase self::assertNull($absenceReader->isUserAbsent($user), 'when no user found, absence should be null'); } - public function provideDataTestUserAbsence(): iterable + public static function provideDataTestUserAbsence(): iterable { // contains data that was retrieved from microsoft graph api on 2023-07-06 diff --git a/src/Bundle/ChillCalendarBundle/Tests/RemoteCalendar/Connector/MSGraph/MSUserAbsenceSyncTest.php b/src/Bundle/ChillCalendarBundle/Tests/RemoteCalendar/Connector/MSGraph/MSUserAbsenceSyncTest.php index 244c7e468..690fe5222 100644 --- a/src/Bundle/ChillCalendarBundle/Tests/RemoteCalendar/Connector/MSGraph/MSUserAbsenceSyncTest.php +++ b/src/Bundle/ChillCalendarBundle/Tests/RemoteCalendar/Connector/MSGraph/MSUserAbsenceSyncTest.php @@ -46,7 +46,7 @@ class MSUserAbsenceSyncTest extends TestCase self::assertEquals($expectedAbsenceStart, $user->getAbsenceStart(), $message); } - public function provideDataTestSyncUserAbsence(): iterable + public static function provideDataTestSyncUserAbsence(): iterable { yield [new User(), false, false, null, 'user present remains present']; yield [new User(), true, true, new \DateTimeImmutable('2023-07-01T12:00:00'), 'user present becomes absent']; diff --git a/src/Bundle/ChillCalendarBundle/Tests/Service/ShortMessageNotification/DefaultRangeGeneratorTest.php b/src/Bundle/ChillCalendarBundle/Tests/Service/ShortMessageNotification/DefaultRangeGeneratorTest.php index 552595414..1d28c43c0 100644 --- a/src/Bundle/ChillCalendarBundle/Tests/Service/ShortMessageNotification/DefaultRangeGeneratorTest.php +++ b/src/Bundle/ChillCalendarBundle/Tests/Service/ShortMessageNotification/DefaultRangeGeneratorTest.php @@ -35,7 +35,7 @@ final class DefaultRangeGeneratorTest extends TestCase * * Jeudi => envoi des rdv du samedi et dimanche * * Vendredi => Envoi des rdv du lundi. */ - public function generateData(): \Iterator + public static function generateData(): \Iterator { yield [ new \DateTimeImmutable('2022-06-13 10:45:00'), diff --git a/src/Bundle/ChillCustomFieldsBundle/Tests/CustomFields/CustomFieldsChoiceTest.php b/src/Bundle/ChillCustomFieldsBundle/Tests/CustomFields/CustomFieldsChoiceTest.php index 48d4847d6..b9d00d052 100644 --- a/src/Bundle/ChillCustomFieldsBundle/Tests/CustomFields/CustomFieldsChoiceTest.php +++ b/src/Bundle/ChillCustomFieldsBundle/Tests/CustomFields/CustomFieldsChoiceTest.php @@ -55,7 +55,7 @@ final class CustomFieldsChoiceTest extends KernelTestCase * * @return array */ - public function emptyDataProvider() + public static function emptyDataProvider() { return [ // 0 @@ -101,7 +101,7 @@ final class CustomFieldsChoiceTest extends KernelTestCase ]; } - public function serializedRepresentationDataProvider() + public static function serializedRepresentationDataProvider() { return [ [ diff --git a/src/Bundle/ChillDocGeneratorBundle/tests/Serializer/Encoder/DocGenEncoderTest.php b/src/Bundle/ChillDocGeneratorBundle/tests/Serializer/Encoder/DocGenEncoderTest.php index a5aa1e9e9..b48f19719 100644 --- a/src/Bundle/ChillDocGeneratorBundle/tests/Serializer/Encoder/DocGenEncoderTest.php +++ b/src/Bundle/ChillDocGeneratorBundle/tests/Serializer/Encoder/DocGenEncoderTest.php @@ -31,7 +31,7 @@ final class DocGenEncoderTest extends TestCase $this->encoder = new DocGenEncoder(); } - public function generateEncodeData() + public static function generateEncodeData() { yield [['tests' => 'ok'], ['tests' => 'ok'], 'A simple test with a simple array']; diff --git a/src/Bundle/ChillDocStoreBundle/Tests/AsyncUpload/Driver/OpenstackObjectStore/TempUrlOpenstackGeneratorTest.php b/src/Bundle/ChillDocStoreBundle/Tests/AsyncUpload/Driver/OpenstackObjectStore/TempUrlOpenstackGeneratorTest.php index 77d2f8252..e6250202f 100644 --- a/src/Bundle/ChillDocStoreBundle/Tests/AsyncUpload/Driver/OpenstackObjectStore/TempUrlOpenstackGeneratorTest.php +++ b/src/Bundle/ChillDocStoreBundle/Tests/AsyncUpload/Driver/OpenstackObjectStore/TempUrlOpenstackGeneratorTest.php @@ -107,7 +107,7 @@ class TempUrlOpenstackGeneratorTest extends TestCase self::assertGreaterThanOrEqual(20, strlen($signedUrl->prefix)); } - public function dataProviderGenerate(): iterable + public static function dataProviderGenerate(): iterable { $now = \DateTimeImmutable::createFromFormat('U', '1702041743'); $expireDelay = 1800; @@ -138,7 +138,7 @@ class TempUrlOpenstackGeneratorTest extends TestCase } } - public function dataProviderGeneratePost(): iterable + public static function dataProviderGeneratePost(): iterable { $now = \DateTimeImmutable::createFromFormat('U', '1702041743'); $expireDelay = 1800; diff --git a/src/Bundle/ChillDocStoreBundle/Tests/AsyncUpload/Templating/AsyncUploadExtensionTest.php b/src/Bundle/ChillDocStoreBundle/Tests/AsyncUpload/Templating/AsyncUploadExtensionTest.php index 78ed1a1d9..e309c02ec 100644 --- a/src/Bundle/ChillDocStoreBundle/Tests/AsyncUpload/Templating/AsyncUploadExtensionTest.php +++ b/src/Bundle/ChillDocStoreBundle/Tests/AsyncUpload/Templating/AsyncUploadExtensionTest.php @@ -68,7 +68,7 @@ class AsyncUploadExtensionTest extends KernelTestCase self::assertEquals('url', $actual); } - public function dataProviderStoredObject(): iterable + public static function dataProviderStoredObject(): iterable { yield [(new StoredObject())->setFilename('blabla')]; diff --git a/src/Bundle/ChillDocStoreBundle/Tests/GenericDoc/Providers/AccompanyingCourseDocumentGenericDocProviderTest.php b/src/Bundle/ChillDocStoreBundle/Tests/GenericDoc/Providers/AccompanyingCourseDocumentGenericDocProviderTest.php index 6c2afe08c..a4f5234d5 100644 --- a/src/Bundle/ChillDocStoreBundle/Tests/GenericDoc/Providers/AccompanyingCourseDocumentGenericDocProviderTest.php +++ b/src/Bundle/ChillDocStoreBundle/Tests/GenericDoc/Providers/AccompanyingCourseDocumentGenericDocProviderTest.php @@ -69,7 +69,7 @@ class AccompanyingCourseDocumentGenericDocProviderTest extends KernelTestCase self::assertIsInt($nb); } - public function provideSearchArguments(): iterable + public static function provideSearchArguments(): iterable { yield [null, null, null]; yield [new \DateTimeImmutable('1 month ago'), null, null]; diff --git a/src/Bundle/ChillDocStoreBundle/Tests/GenericDoc/Providers/PersonDocumentGenericDocProviderTest.php b/src/Bundle/ChillDocStoreBundle/Tests/GenericDoc/Providers/PersonDocumentGenericDocProviderTest.php index 5b5b2eeb5..602dd7f4c 100644 --- a/src/Bundle/ChillDocStoreBundle/Tests/GenericDoc/Providers/PersonDocumentGenericDocProviderTest.php +++ b/src/Bundle/ChillDocStoreBundle/Tests/GenericDoc/Providers/PersonDocumentGenericDocProviderTest.php @@ -73,7 +73,7 @@ class PersonDocumentGenericDocProviderTest extends KernelTestCase self::assertIsInt($nb, 'Test that the query is syntactically correct'); } - public function provideDataBuildFetchQueryForPerson(): iterable + public static function provideDataBuildFetchQueryForPerson(): iterable { yield [null, null, null]; yield [new \DateTimeImmutable('1 year ago'), null, null]; diff --git a/src/Bundle/ChillDocStoreBundle/Tests/Repository/PersonDocumentACLAwareRepositoryTest.php b/src/Bundle/ChillDocStoreBundle/Tests/Repository/PersonDocumentACLAwareRepositoryTest.php index e20f2da86..c1db6ad3e 100644 --- a/src/Bundle/ChillDocStoreBundle/Tests/Repository/PersonDocumentACLAwareRepositoryTest.php +++ b/src/Bundle/ChillDocStoreBundle/Tests/Repository/PersonDocumentACLAwareRepositoryTest.php @@ -142,7 +142,7 @@ class PersonDocumentACLAwareRepositoryTest extends KernelTestCase yield [$period, new \DateTimeImmutable('2 years ago'), new \DateTimeImmutable('1 year ago'), 'test']; } - public function provideDataBuildFetchQueryForPerson(): iterable + public static function provideDataBuildFetchQueryForPerson(): iterable { yield [null, null, null]; yield [new \DateTimeImmutable('1 year ago'), null, null]; diff --git a/src/Bundle/ChillDocStoreBundle/Tests/StoredObjectManagerTest.php b/src/Bundle/ChillDocStoreBundle/Tests/StoredObjectManagerTest.php index e0a9eca35..94558c1b0 100644 --- a/src/Bundle/ChillDocStoreBundle/Tests/StoredObjectManagerTest.php +++ b/src/Bundle/ChillDocStoreBundle/Tests/StoredObjectManagerTest.php @@ -31,7 +31,7 @@ use Symfony\Contracts\HttpClient\HttpClientInterface; */ final class StoredObjectManagerTest extends TestCase { - public function getDataProvider(): \Generator + public static function getDataProvider(): \Generator { /* HAPPY SCENARIO */ diff --git a/src/Bundle/ChillEventBundle/Tests/Repository/EventACLAwareRepositoryTest.php b/src/Bundle/ChillEventBundle/Tests/Repository/EventACLAwareRepositoryTest.php index 15160c3c7..4bcaac1f6 100644 --- a/src/Bundle/ChillEventBundle/Tests/Repository/EventACLAwareRepositoryTest.php +++ b/src/Bundle/ChillEventBundle/Tests/Repository/EventACLAwareRepositoryTest.php @@ -60,7 +60,7 @@ class EventACLAwareRepositoryTest extends KernelTestCase $this->assertIsArray($repository->findAllViewable($filters)); } - public function generateFilters(): iterable + public static function generateFilters(): iterable { yield [[]]; } diff --git a/src/Bundle/ChillMainBundle/Tests/Controller/AddressControllerTest.php b/src/Bundle/ChillMainBundle/Tests/Controller/AddressControllerTest.php index e16293a7e..4a65c434c 100644 --- a/src/Bundle/ChillMainBundle/Tests/Controller/AddressControllerTest.php +++ b/src/Bundle/ChillMainBundle/Tests/Controller/AddressControllerTest.php @@ -32,7 +32,7 @@ final class AddressControllerTest extends \Symfony\Bundle\FrameworkBundle\Test\W self::ensureKernelShutdown(); } - public function generateAddressIds(): iterable + public static function generateAddressIds(): iterable { self::bootKernel(); $em = self::getContainer()->get(EntityManagerInterface::class); diff --git a/src/Bundle/ChillMainBundle/Tests/Controller/AddressReferenceApiControllerTest.php b/src/Bundle/ChillMainBundle/Tests/Controller/AddressReferenceApiControllerTest.php index dfce605d2..335f6f29b 100644 --- a/src/Bundle/ChillMainBundle/Tests/Controller/AddressReferenceApiControllerTest.php +++ b/src/Bundle/ChillMainBundle/Tests/Controller/AddressReferenceApiControllerTest.php @@ -25,7 +25,7 @@ final class AddressReferenceApiControllerTest extends WebTestCase { use PrepareClientTrait; - public function provideData() + public static function provideData() { self::bootKernel(); /** @var EntityManagerInterface $em */ diff --git a/src/Bundle/ChillMainBundle/Tests/Controller/SearchApiControllerTest.php b/src/Bundle/ChillMainBundle/Tests/Controller/SearchApiControllerTest.php index 925fa1527..4f265658b 100644 --- a/src/Bundle/ChillMainBundle/Tests/Controller/SearchApiControllerTest.php +++ b/src/Bundle/ChillMainBundle/Tests/Controller/SearchApiControllerTest.php @@ -24,7 +24,7 @@ final class SearchApiControllerTest extends WebTestCase { use PrepareClientTrait; - public function generateSearchData() + public static function generateSearchData() { yield ['per', ['person', 'thirdparty']]; diff --git a/src/Bundle/ChillMainBundle/Tests/Doctrine/DQL/AgeTest.php b/src/Bundle/ChillMainBundle/Tests/Doctrine/DQL/AgeTest.php index f52e250f3..cdb24b4b7 100644 --- a/src/Bundle/ChillMainBundle/Tests/Doctrine/DQL/AgeTest.php +++ b/src/Bundle/ChillMainBundle/Tests/Doctrine/DQL/AgeTest.php @@ -31,7 +31,7 @@ final class AgeTest extends KernelTestCase $this->entityManager = self::getContainer()->get(EntityManagerInterface::class); } - public function generateQueries(): iterable + public static function generateQueries(): iterable { yield [ 'SELECT AGE(a.validFrom, a.validTo) FROM '.Address::class.' a', diff --git a/src/Bundle/ChillMainBundle/Tests/Doctrine/DQL/JsonBuildObjectTest.php b/src/Bundle/ChillMainBundle/Tests/Doctrine/DQL/JsonBuildObjectTest.php index 23665eaf8..a62b3a92e 100644 --- a/src/Bundle/ChillMainBundle/Tests/Doctrine/DQL/JsonBuildObjectTest.php +++ b/src/Bundle/ChillMainBundle/Tests/Doctrine/DQL/JsonBuildObjectTest.php @@ -51,7 +51,7 @@ class JsonBuildObjectTest extends KernelTestCase self::assertIsArray($result); } - public function provideQueries(): iterable + public static function provideQueries(): iterable { yield ['SELECT JSON_BUILD_OBJECT(1, 2, 3, 4) FROM '.Address::class.' a', [], []]; yield ["SELECT JSON_BUILD_OBJECT('st', a.street, 'sn', a.streetNumber) FROM ".Address::class.' a', [], []]; diff --git a/src/Bundle/ChillMainBundle/Tests/Doctrine/DQL/JsonExtractTest.php b/src/Bundle/ChillMainBundle/Tests/Doctrine/DQL/JsonExtractTest.php index 0c113e804..dec63a64c 100644 --- a/src/Bundle/ChillMainBundle/Tests/Doctrine/DQL/JsonExtractTest.php +++ b/src/Bundle/ChillMainBundle/Tests/Doctrine/DQL/JsonExtractTest.php @@ -31,7 +31,7 @@ final class JsonExtractTest extends KernelTestCase $this->em = self::getContainer()->get(EntityManagerInterface::class); } - public function dataGenerateDql(): iterable + public static function dataGenerateDql(): iterable { yield ['SELECT JSON_EXTRACT(c.name, \'fr\') FROM '.Country::class.' c', []]; diff --git a/src/Bundle/ChillMainBundle/Tests/Entity/NotificationTest.php b/src/Bundle/ChillMainBundle/Tests/Entity/NotificationTest.php index f2f259211..26a9b5980 100644 --- a/src/Bundle/ChillMainBundle/Tests/Entity/NotificationTest.php +++ b/src/Bundle/ChillMainBundle/Tests/Entity/NotificationTest.php @@ -44,7 +44,7 @@ final class NotificationTest extends KernelTestCase $em->flush(); } - public function generateNotificationData() + public static function generateNotificationData() { self::bootKernel(); $userRepository = self::getContainer()->get(UserRepository::class); diff --git a/src/Bundle/ChillMainBundle/Tests/Pagination/PageTest.php b/src/Bundle/ChillMainBundle/Tests/Pagination/PageTest.php index 9b0866024..14bb7dfe6 100644 --- a/src/Bundle/ChillMainBundle/Tests/Pagination/PageTest.php +++ b/src/Bundle/ChillMainBundle/Tests/Pagination/PageTest.php @@ -43,7 +43,7 @@ final class PageTest extends KernelTestCase * * @return array */ - public function generateGetFirstItemNumber() + public static function generateGetFirstItemNumber() { return [ [1, 10, 0], @@ -61,7 +61,7 @@ final class PageTest extends KernelTestCase * * @return array */ - public function generateGetLastItemNumber() + public static function generateGetLastItemNumber() { return [ [1, 10, 9], diff --git a/src/Bundle/ChillMainBundle/Tests/Pagination/PaginatorTest.php b/src/Bundle/ChillMainBundle/Tests/Pagination/PaginatorTest.php index 8ba207aa6..579348196 100644 --- a/src/Bundle/ChillMainBundle/Tests/Pagination/PaginatorTest.php +++ b/src/Bundle/ChillMainBundle/Tests/Pagination/PaginatorTest.php @@ -43,7 +43,7 @@ final class PaginatorTest extends KernelTestCase * * @return array */ - public function generateHasNextPage() + public static function generateHasNextPage() { return [ [10, 10, 1, false], @@ -53,7 +53,7 @@ final class PaginatorTest extends KernelTestCase ]; } - public function generateHasPage() + public static function generateHasPage() { return [ [10, 10, -1, false], @@ -72,7 +72,7 @@ final class PaginatorTest extends KernelTestCase * * @return array */ - public function generateHasPreviousPage() + public static function generateHasPreviousPage() { return [ [10, 10, 1, false], @@ -88,7 +88,7 @@ final class PaginatorTest extends KernelTestCase * * @return array */ - public function generatePageNumber() + public static function generatePageNumber() { return [ [12, 10, 2], diff --git a/src/Bundle/ChillMainBundle/Tests/Phonenumber/PhonenumberHelperTest.php b/src/Bundle/ChillMainBundle/Tests/Phonenumber/PhonenumberHelperTest.php index 184c994e4..6f65c612f 100644 --- a/src/Bundle/ChillMainBundle/Tests/Phonenumber/PhonenumberHelperTest.php +++ b/src/Bundle/ChillMainBundle/Tests/Phonenumber/PhonenumberHelperTest.php @@ -25,7 +25,7 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag; */ final class PhonenumberHelperTest extends KernelTestCase { - public function formatPhonenumbers() + public static function formatPhonenumbers() { yield [ 'BE', diff --git a/src/Bundle/ChillMainBundle/Tests/Search/Utils/ExtractDateFromPatternTest.php b/src/Bundle/ChillMainBundle/Tests/Search/Utils/ExtractDateFromPatternTest.php index f592b0e1a..00339b100 100644 --- a/src/Bundle/ChillMainBundle/Tests/Search/Utils/ExtractDateFromPatternTest.php +++ b/src/Bundle/ChillMainBundle/Tests/Search/Utils/ExtractDateFromPatternTest.php @@ -21,7 +21,7 @@ use PHPUnit\Framework\TestCase; */ final class ExtractDateFromPatternTest extends TestCase { - public function provideSubjects() + public static function provideSubjects() { yield ['15/06/1981', '', 1, '1981-06-15']; diff --git a/src/Bundle/ChillMainBundle/Tests/Search/Utils/ExtractPhonenumberFromPatternTest.php b/src/Bundle/ChillMainBundle/Tests/Search/Utils/ExtractPhonenumberFromPatternTest.php index 68b1ba9a8..96d7d4622 100644 --- a/src/Bundle/ChillMainBundle/Tests/Search/Utils/ExtractPhonenumberFromPatternTest.php +++ b/src/Bundle/ChillMainBundle/Tests/Search/Utils/ExtractPhonenumberFromPatternTest.php @@ -22,7 +22,7 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag; */ final class ExtractPhonenumberFromPatternTest extends KernelTestCase { - public function provideData() + public static function provideData() { yield ['BE', 'Diallo', 0, [], 'Diallo', 'no phonenumber']; diff --git a/src/Bundle/ChillMainBundle/Tests/Serializer/Normalizer/DateNormalizerTest.php b/src/Bundle/ChillMainBundle/Tests/Serializer/Normalizer/DateNormalizerTest.php index 8d80490c1..74f44d05e 100644 --- a/src/Bundle/ChillMainBundle/Tests/Serializer/Normalizer/DateNormalizerTest.php +++ b/src/Bundle/ChillMainBundle/Tests/Serializer/Normalizer/DateNormalizerTest.php @@ -32,7 +32,7 @@ final class DateNormalizerTest extends KernelTestCase $this->prophet = new Prophet(); } - public function generateDataNormalize() + public static function generateDataNormalize() { $datetime = \DateTime::createFromFormat('Y-m-d H:i:sO', '2021-06-05 15:05:01+02:00'); $date = \DateTime::createFromFormat('Y-m-d H:i:sO', '2021-06-05 00:00:00+02:00'); diff --git a/src/Bundle/ChillMainBundle/Tests/Serializer/Normalizer/DoctrineExistingEntityNormalizerTest.php b/src/Bundle/ChillMainBundle/Tests/Serializer/Normalizer/DoctrineExistingEntityNormalizerTest.php index 3587a406f..da1adbf89 100644 --- a/src/Bundle/ChillMainBundle/Tests/Serializer/Normalizer/DoctrineExistingEntityNormalizerTest.php +++ b/src/Bundle/ChillMainBundle/Tests/Serializer/Normalizer/DoctrineExistingEntityNormalizerTest.php @@ -35,7 +35,7 @@ final class DoctrineExistingEntityNormalizerTest extends KernelTestCase $this->normalizer = new DoctrineExistingEntityNormalizer($em, $serializerFactory); } - public function dataProviderUserId() + public static function dataProviderUserId() { self::bootKernel(); diff --git a/src/Bundle/ChillMainBundle/Tests/Serializer/Normalizer/PhonenumberNormalizerTest.php b/src/Bundle/ChillMainBundle/Tests/Serializer/Normalizer/PhonenumberNormalizerTest.php index 583dfc4cc..b36abdd3f 100644 --- a/src/Bundle/ChillMainBundle/Tests/Serializer/Normalizer/PhonenumberNormalizerTest.php +++ b/src/Bundle/ChillMainBundle/Tests/Serializer/Normalizer/PhonenumberNormalizerTest.php @@ -28,7 +28,7 @@ final class PhonenumberNormalizerTest extends TestCase { use ProphecyTrait; - public function dataProviderNormalizePhonenumber() + public static function dataProviderNormalizePhonenumber() { $phonenumberUtil = PhoneNumberUtil::getInstance(); diff --git a/src/Bundle/ChillMainBundle/Tests/Serializer/Normalizer/UserNormalizerTest.php b/src/Bundle/ChillMainBundle/Tests/Serializer/Normalizer/UserNormalizerTest.php index 15334298e..ab59e0a63 100644 --- a/src/Bundle/ChillMainBundle/Tests/Serializer/Normalizer/UserNormalizerTest.php +++ b/src/Bundle/ChillMainBundle/Tests/Serializer/Normalizer/UserNormalizerTest.php @@ -40,7 +40,7 @@ final class UserNormalizerTest extends TestCase /** * @throws NumberParseException */ - public function dataProviderUserNormalizer() + public static function dataProviderUserNormalizer() { $user = new User(); $userNoPhone = new User(); diff --git a/src/Bundle/ChillMainBundle/Tests/Services/RollingDate/RollingDateConverterTest.php b/src/Bundle/ChillMainBundle/Tests/Services/RollingDate/RollingDateConverterTest.php index 25f3d03e6..5b2dfb954 100644 --- a/src/Bundle/ChillMainBundle/Tests/Services/RollingDate/RollingDateConverterTest.php +++ b/src/Bundle/ChillMainBundle/Tests/Services/RollingDate/RollingDateConverterTest.php @@ -29,7 +29,7 @@ final class RollingDateConverterTest extends TestCase $this->converter = new RollingDateConverter(); } - public function generateDataConversionDate(): iterable + public static function generateDataConversionDate(): iterable { $format = 'Y-m-d His'; diff --git a/src/Bundle/ChillMainBundle/Tests/Templating/Entity/AddressRenderTest.php b/src/Bundle/ChillMainBundle/Tests/Templating/Entity/AddressRenderTest.php index 0e72807c5..0fbc69eab 100644 --- a/src/Bundle/ChillMainBundle/Tests/Templating/Entity/AddressRenderTest.php +++ b/src/Bundle/ChillMainBundle/Tests/Templating/Entity/AddressRenderTest.php @@ -30,7 +30,7 @@ final class AddressRenderTest extends KernelTestCase self::bootKernel(); } - public function addressDataProviderBEWithBuilding(): \Iterator + public static function addressDataProviderBEWithBuilding(): \Iterator { $addr = new Address(); $country = (new Country()) @@ -50,7 +50,7 @@ final class AddressRenderTest extends KernelTestCase yield [$addr, 'Résidence "Les Bleuets" — Rue ABC, 5 — 012345 Locality — Belgium']; } - public function addressDataProviderBEWithSteps(): \Iterator + public static function addressDataProviderBEWithSteps(): \Iterator { $addr = new Address(); $country = (new Country()) @@ -70,7 +70,7 @@ final class AddressRenderTest extends KernelTestCase yield [$addr, 'esc 4 — Rue ABC, 5 — 012345 Locality — Belgium']; } - public function addressDataProviderFRWithBuilding(): \Iterator + public static function addressDataProviderFRWithBuilding(): \Iterator { $addr = new Address(); $country = (new Country()) @@ -90,7 +90,7 @@ final class AddressRenderTest extends KernelTestCase yield [$addr, 'Résidence "Les Bleuets" — 5, Rue ABC — 012345 Locality — France']; } - public function addressDataProviderFRWithSteps(): \Iterator + public static function addressDataProviderFRWithSteps(): \Iterator { $addr = new Address(); $country = (new Country()) @@ -110,7 +110,7 @@ final class AddressRenderTest extends KernelTestCase yield [$addr, 'esc 4 — 5, Rue ABC — 012345 Locality — France']; } - public function complexAddressDataProviderBE(): \Iterator + public static function complexAddressDataProviderBE(): \Iterator { $addr = new Address(); $country = (new Country()) @@ -134,7 +134,7 @@ final class AddressRenderTest extends KernelTestCase yield [$addr, 'Résidence "Les Bleuets" - appart 1 - ét 2 - coul 3 - esc 4 — Rue ABC, 5 — 012345 Locality — Belgium']; } - public function complexAddressDataProviderFR(): \Iterator + public static function complexAddressDataProviderFR(): \Iterator { $addr = new Address(); $country = (new Country()) @@ -160,7 +160,7 @@ final class AddressRenderTest extends KernelTestCase yield [$addr, 'appart 1 - ét 2 - coul 3 - esc 4 — Résidence "Les Bleuets" — 5, Rue ABC — A droite de la porte — 012345 Locality CEDEX — France']; } - public function noFullAddressDataProviderBE(): \Iterator + public static function noFullAddressDataProviderBE(): \Iterator { $addr = new Address(); $country = (new Country()) @@ -177,7 +177,7 @@ final class AddressRenderTest extends KernelTestCase yield [$addr, '012345 Locality — Belgium']; } - public function simpleAddressDataProviderBE(): \Iterator + public static function simpleAddressDataProviderBE(): \Iterator { $addr = new Address(); $country = (new Country()) @@ -195,7 +195,7 @@ final class AddressRenderTest extends KernelTestCase yield [$addr, 'Rue ABC, 5 — 012345 Locality — Belgium']; } - public function simpleAddressDataProviderFR(): \Iterator + public static function simpleAddressDataProviderFR(): \Iterator { $addr = new Address(); $country = (new Country()) diff --git a/src/Bundle/ChillPersonBundle/Tests/AccompanyingPeriod/Lifecycle/AccompanyingPeriodStepChangeCronjobTest.php b/src/Bundle/ChillPersonBundle/Tests/AccompanyingPeriod/Lifecycle/AccompanyingPeriodStepChangeCronjobTest.php index bdfca0d58..a3e361e55 100644 --- a/src/Bundle/ChillPersonBundle/Tests/AccompanyingPeriod/Lifecycle/AccompanyingPeriodStepChangeCronjobTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/AccompanyingPeriod/Lifecycle/AccompanyingPeriodStepChangeCronjobTest.php @@ -41,7 +41,7 @@ class AccompanyingPeriodStepChangeCronjobTest extends TestCase $this->assertEquals($canRun, $cronJob->canRun($cronJobExecution)); } - public function provideRunTimes(): iterable + public static function provideRunTimes(): iterable { // can run, during the night yield ['2023-01-15T01:00:00+02:00', new \DateTimeImmutable('2023-01-14T00:00:00+02:00'), true]; diff --git a/src/Bundle/ChillPersonBundle/Tests/Controller/AccompanyingCoursWorkApiController/ConflictTest.php b/src/Bundle/ChillPersonBundle/Tests/Controller/AccompanyingCoursWorkApiController/ConflictTest.php index 3926c19d2..8f182cac5 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Controller/AccompanyingCoursWorkApiController/ConflictTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Controller/AccompanyingCoursWorkApiController/ConflictTest.php @@ -120,7 +120,7 @@ class ConflictTest extends WebTestCase self::assertResponseStatusCodeSame(409); } - public function generateAccompanyingPeriodWork(): iterable + public static function generateAccompanyingPeriodWork(): iterable { self::bootKernel(); $em = self::getContainer()->get(EntityManagerInterface::class); diff --git a/src/Bundle/ChillPersonBundle/Tests/Controller/AccompanyingCourseApiControllerTest.php b/src/Bundle/ChillPersonBundle/Tests/Controller/AccompanyingCourseApiControllerTest.php index 8d4283b30..301d90056 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Controller/AccompanyingCourseApiControllerTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Controller/AccompanyingCourseApiControllerTest.php @@ -48,7 +48,7 @@ final class AccompanyingCourseApiControllerTest extends WebTestCase self::ensureKernelShutdown(); } - public function dataGenerateNewAccompanyingCourse() + public static function dataGenerateNewAccompanyingCourse() { self::bootKernel(); $em = self::getContainer()->get(EntityManagerInterface::class); @@ -85,7 +85,7 @@ final class AccompanyingCourseApiControllerTest extends WebTestCase self::ensureKernelShutdown(); } - public function dataGenerateRandomAccompanyingCourse() + public static function dataGenerateRandomAccompanyingCourse() { // note about max result for person query, and maxGenerated: // @@ -152,7 +152,7 @@ final class AccompanyingCourseApiControllerTest extends WebTestCase self::ensureKernelShutdown(); } - public function dataGenerateRandomAccompanyingCourseWithSocialIssue() + public static function dataGenerateRandomAccompanyingCourseWithSocialIssue() { // note about max result for person query, and maxGenerated: // @@ -224,7 +224,7 @@ final class AccompanyingCourseApiControllerTest extends WebTestCase self::ensureKernelShutdown(); } - public function dataGenerateRandomRequestorValidData(): \Iterator + public static function dataGenerateRandomRequestorValidData(): \Iterator { $dataLength = 2; $maxResults = 100; diff --git a/src/Bundle/ChillPersonBundle/Tests/Controller/AccompanyingCourseControllerTest.php b/src/Bundle/ChillPersonBundle/Tests/Controller/AccompanyingCourseControllerTest.php index 0f553162a..4f8f1453d 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Controller/AccompanyingCourseControllerTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Controller/AccompanyingCourseControllerTest.php @@ -41,7 +41,7 @@ final class AccompanyingCourseControllerTest extends WebTestCase self::ensureKernelShutdown(); } - public function dataGenerateRandomUsers(): \Iterator + public static function dataGenerateRandomUsers(): \Iterator { self::bootKernel(); $em = self::getContainer()->get(EntityManagerInterface::class); diff --git a/src/Bundle/ChillPersonBundle/Tests/Controller/HouseholdApiControllerTest.php b/src/Bundle/ChillPersonBundle/Tests/Controller/HouseholdApiControllerTest.php index d01455a96..fc73123cb 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Controller/HouseholdApiControllerTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Controller/HouseholdApiControllerTest.php @@ -92,7 +92,7 @@ final class HouseholdApiControllerTest extends WebTestCase self::ensureKernelShutdown(); } - public function generateHouseholdId() + public static function generateHouseholdId() { self::bootKernel(); @@ -124,7 +124,7 @@ final class HouseholdApiControllerTest extends WebTestCase self::ensureKernelShutdown(); } - public function generatePersonId() + public static function generatePersonId() { self::bootKernel(); diff --git a/src/Bundle/ChillPersonBundle/Tests/Controller/HouseholdControllerTest.php b/src/Bundle/ChillPersonBundle/Tests/Controller/HouseholdControllerTest.php index 25827600b..92ed1460a 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Controller/HouseholdControllerTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Controller/HouseholdControllerTest.php @@ -39,7 +39,7 @@ final class HouseholdControllerTest extends WebTestCase self::ensureKernelShutdown(); } - public function generateValidHouseholdIds() + public static function generateValidHouseholdIds() { self::bootKernel(); $em = self::getContainer()->get(EntityManagerInterface::class); diff --git a/src/Bundle/ChillPersonBundle/Tests/Controller/HouseholdMemberControllerTest.php b/src/Bundle/ChillPersonBundle/Tests/Controller/HouseholdMemberControllerTest.php index 0c7105fc5..66b754eb3 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Controller/HouseholdMemberControllerTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Controller/HouseholdMemberControllerTest.php @@ -30,7 +30,7 @@ final class HouseholdMemberControllerTest extends WebTestCase { use PrepareClientTrait; - public function provideValidDataEditMember(): \Iterator + public static function provideValidDataEditMember(): \Iterator { self::bootKernel(); $em = self::getContainer()->get(EntityManagerInterface::class); @@ -48,7 +48,7 @@ final class HouseholdMemberControllerTest extends WebTestCase yield [\array_pop($membershipIds)['id']]; } - public function provideValidDataMove(): \Iterator + public static function provideValidDataMove(): \Iterator { self::bootKernel(); $em = self::getContainer()->get(EntityManagerInterface::class); diff --git a/src/Bundle/ChillPersonBundle/Tests/Controller/PersonApiControllerTest.php b/src/Bundle/ChillPersonBundle/Tests/Controller/PersonApiControllerTest.php index 74b5f3d98..397dfdc78 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Controller/PersonApiControllerTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Controller/PersonApiControllerTest.php @@ -26,7 +26,7 @@ final class PersonApiControllerTest extends WebTestCase { use PrepareClientTrait; - public function dataGetPersonFromCenterA(): \Iterator + public static function dataGetPersonFromCenterA(): \Iterator { self::bootKernel(); $em = self::getContainer()->get(EntityManagerInterface::class); @@ -49,7 +49,7 @@ final class PersonApiControllerTest extends WebTestCase yield \array_pop($personIds); } - public function dataGetPersonFromCenterB(): \Iterator + public static function dataGetPersonFromCenterB(): \Iterator { self::bootKernel(); $em = self::getContainer()->get(EntityManagerInterface::class); diff --git a/src/Bundle/ChillPersonBundle/Tests/Controller/PersonControllerUpdateWithHiddenFieldsTest.php b/src/Bundle/ChillPersonBundle/Tests/Controller/PersonControllerUpdateWithHiddenFieldsTest.php index db77c5672..a290e56e8 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Controller/PersonControllerUpdateWithHiddenFieldsTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Controller/PersonControllerUpdateWithHiddenFieldsTest.php @@ -188,7 +188,7 @@ final class PersonControllerUpdateWithHiddenFieldsTest extends WebTestCase * * @return mixed[] */ - public function validTextFieldsProvider() + public static function validTextFieldsProvider() { return [ ['firstName', 'random Value', static fn (Person $person) => $person->getFirstName()], diff --git a/src/Bundle/ChillPersonBundle/Tests/Controller/PersonDuplicateControllerViewTest.php b/src/Bundle/ChillPersonBundle/Tests/Controller/PersonDuplicateControllerViewTest.php index b425ac71c..e64711e43 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Controller/PersonDuplicateControllerViewTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Controller/PersonDuplicateControllerViewTest.php @@ -23,7 +23,7 @@ use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; */ final class PersonDuplicateControllerViewTest extends WebTestCase { - public function providePersonData(): iterable + public static function providePersonData(): iterable { self::bootKernel(); diff --git a/src/Bundle/ChillPersonBundle/Tests/Controller/RelationshipApiControllerTest.php b/src/Bundle/ChillPersonBundle/Tests/Controller/RelationshipApiControllerTest.php index d62b4c863..0de5e8b12 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Controller/RelationshipApiControllerTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Controller/RelationshipApiControllerTest.php @@ -40,7 +40,7 @@ final class RelationshipApiControllerTest extends WebTestCase self::ensureKernelShutdown(); } - public function personProvider(): array + public static function personProvider(): array { self::bootKernel(); $em = self::getContainer()->get(EntityManagerInterface::class); diff --git a/src/Bundle/ChillPersonBundle/Tests/EventListener/PersonCreateEventTest.php b/src/Bundle/ChillPersonBundle/Tests/EventListener/PersonCreateEventTest.php index c05e5dd5d..417cc6d01 100644 --- a/src/Bundle/ChillPersonBundle/Tests/EventListener/PersonCreateEventTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/EventListener/PersonCreateEventTest.php @@ -21,7 +21,7 @@ use PHPUnit\Framework\TestCase; */ final class PersonCreateEventTest extends TestCase { - public function generateAltNames(): iterator + public static function generateAltNames(): iterator { yield ['vinCENT', 'VINCENT']; @@ -32,7 +32,7 @@ final class PersonCreateEventTest extends TestCase yield ['émile', 'ÉMILE']; } - public function generateNames(): iterator + public static function generateNames(): iterator { yield ['émelie-marie', 'Émelie-Marie', 'lenaerts', 'LENAERTS']; diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/AccompanyingCourseFilters/ActiveOnDateFilterTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/AccompanyingCourseFilters/ActiveOnDateFilterTest.php index 8927cf858..09be30f1f 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/AccompanyingCourseFilters/ActiveOnDateFilterTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/AccompanyingCourseFilters/ActiveOnDateFilterTest.php @@ -38,7 +38,7 @@ final class ActiveOnDateFilterTest extends AbstractFilterTest return $this->filter; } - public function getFormData(): array + public static function getFormData(): array { return [ [ @@ -47,7 +47,7 @@ final class ActiveOnDateFilterTest extends AbstractFilterTest ]; } - public function getQueryBuilders(): array + public static function getQueryBuilders(): array { self::bootKernel(); diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Helper/FilterListAccompanyingPeriodHelperTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Helper/FilterListAccompanyingPeriodHelperTest.php index ee4e7bdfe..0cdbea864 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Helper/FilterListAccompanyingPeriodHelperTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Helper/FilterListAccompanyingPeriodHelperTest.php @@ -90,10 +90,11 @@ final class FilterListAccompanyingPeriodHelperTest extends KernelTestCase self::assertIsArray($result); } - public function dataProviderTestAddFilterAccompanyingPeriod(): iterable + public static function dataProviderTestAddFilterAccompanyingPeriod(): iterable { - self::setUp(); - $qb = $this->entityManager->createQueryBuilder(); + self::bootKernel(); + $entityManager = self::getContainer()->get(EntityManagerInterface::class); + $qb = $entityManager->createQueryBuilder(); $qb ->select('acp.id') diff --git a/src/Bundle/ChillPersonBundle/Tests/Repository/AccompanyingPeriodACLAwareRepositoryTest.php b/src/Bundle/ChillPersonBundle/Tests/Repository/AccompanyingPeriodACLAwareRepositoryTest.php index 1486b1890..917a42ef2 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Repository/AccompanyingPeriodACLAwareRepositoryTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Repository/AccompanyingPeriodACLAwareRepositoryTest.php @@ -140,20 +140,23 @@ class AccompanyingPeriodACLAwareRepositoryTest extends KernelTestCase } } - public function provideDataFindByUserAndPostalCodesOpenedAccompanyingPeriod(): iterable + public static function provideDataFindByUserAndPostalCodesOpenedAccompanyingPeriod(): iterable { - $this->setUp(); + self::bootKernel(); + $entityManager = self::getContainer()->get(EntityManagerInterface::class); + $scopeRepository = self::getContainer()->get(ScopeRepositoryInterface::class); + $centerRepository = self::getContainer()->get(CenterRepositoryInterface::class); - if (null === $user = $this->entityManager->createQuery('SELECT u FROM '.User::class.' u')->setMaxResults(1)->getSingleResult()) { + if (null === $user = $entityManager->createQuery('SELECT u FROM '.User::class.' u')->setMaxResults(1)->getSingleResult()) { throw new \RuntimeException('no user found'); } - if (null === $anotherUser = $this->entityManager->createQuery('SELECT u FROM '.User::class.' u WHERE u.id != :uid')->setParameter('uid', $user->getId()) + if (null === $anotherUser = $entityManager->createQuery('SELECT u FROM '.User::class.' u WHERE u.id != :uid')->setParameter('uid', $user->getId()) ->setMaxResults(1)->getSingleResult()) { throw new \RuntimeException('no user found'); } - $persons = $this->entityManager + $persons = $entityManager ->createQuery('SELECT p FROM '.Person::class.' p JOIN p.centerCurrent current_center') ->setMaxResults(4) ->getResult(); @@ -165,7 +168,7 @@ class AccompanyingPeriodACLAwareRepositoryTest extends KernelTestCase /** @var Person $person */ [$person, $anotherPerson, $person2, $person3] = $persons; - $scopes = $this->scopeRepository->findAll(); + $scopes = $scopeRepository->findAll(); if (3 > count($scopes)) { throw new \RuntimeException('not enough scopes for this test'); @@ -173,14 +176,14 @@ class AccompanyingPeriodACLAwareRepositoryTest extends KernelTestCase $scopesCanSee = [$scopes[0]]; $scopesGroup2 = [$scopes[1]]; - $centers = $this->centerRepository->findActive(); + $centers = $centerRepository->findActive(); $aCenterNotAssociatedToPerson = array_values(array_filter($centers, fn (Center $c) => $c !== $person->getCenter()))[0]; if (2 > count($centers)) { throw new \RuntimeException('not enough centers for this test'); } - $period = $this->buildPeriod($person, $scopesCanSee, $user, true); + $period = self::buildPeriod($person, $scopesCanSee, $user, true); $period->setUser($user); yield [ @@ -233,7 +236,7 @@ class AccompanyingPeriodACLAwareRepositoryTest extends KernelTestCase 'period should not be visible for user having right in another scope (with multiple centers)', ]; - $period = $this->buildPeriod($person, $scopesCanSee, $user, true); + $period = self::buildPeriod($person, $scopesCanSee, $user, true); $period->setUser($user); $period->setConfidential(true); @@ -267,7 +270,7 @@ class AccompanyingPeriodACLAwareRepositoryTest extends KernelTestCase 'period confidential be visible if user has required scopes', ]; - $this->entityManager->flush(); + $entityManager->flush(); } /** @@ -314,21 +317,24 @@ class AccompanyingPeriodACLAwareRepositoryTest extends KernelTestCase } } - public function provideDataFindByUndispatched(): iterable + public static function provideDataFindByUndispatched(): iterable { - $this->setUp(); + self::bootKernel(); + $entityManager = self::getContainer()->get(EntityManagerInterface::class); + $scopeRepository = self::getContainer()->get(ScopeRepositoryInterface::class); + $centerRepository = self::getContainer()->get(CenterRepositoryInterface::class); - if (null === $user = $this->entityManager->createQuery('SELECT u FROM '.User::class.' u')->setMaxResults(1)->getSingleResult()) { + if (null === $user = $entityManager->createQuery('SELECT u FROM '.User::class.' u')->setMaxResults(1)->getSingleResult()) { throw new \RuntimeException('no user found'); } - if (null === $anotherUser = $this->entityManager->createQuery('SELECT u FROM '.User::class.' u WHERE u.id != :uid')->setParameter('uid', $user->getId()) + if (null === $anotherUser = $entityManager->createQuery('SELECT u FROM '.User::class.' u WHERE u.id != :uid')->setParameter('uid', $user->getId()) ->setMaxResults(1)->getSingleResult()) { throw new \RuntimeException('no user found'); } /** @var Person $person */ - $persons = $this->entityManager + $persons = $entityManager ->createQuery('SELECT p FROM '.Person::class.' p ') ->setMaxResults(4) ->getResult(); @@ -339,7 +345,7 @@ class AccompanyingPeriodACLAwareRepositoryTest extends KernelTestCase [$person, $anotherPerson, $person2, $person3] = $persons; - $scopes = $this->scopeRepository->findAll(); + $scopes = $scopeRepository->findAll(); if (3 > count($scopes)) { throw new \RuntimeException('not enough scopes for this test'); @@ -347,13 +353,13 @@ class AccompanyingPeriodACLAwareRepositoryTest extends KernelTestCase $scopesCanSee = [$scopes[0]]; $scopesGroup2 = [$scopes[1]]; - $centers = $this->centerRepository->findActive(); + $centers = $centerRepository->findActive(); if (2 > count($centers)) { throw new \RuntimeException('not enough centers for this test'); } - $period = $this->buildPeriod($person, $scopesCanSee, $user, true); + $period = self::buildPeriod($person, $scopesCanSee, $user, true); // expected scope: can see the period yield [ @@ -405,7 +411,7 @@ class AccompanyingPeriodACLAwareRepositoryTest extends KernelTestCase 'period should not be visible for user having right in another scope (with multiple centers)', ]; - $this->entityManager->flush(); + $entityManager->flush(); } /** @@ -445,20 +451,22 @@ class AccompanyingPeriodACLAwareRepositoryTest extends KernelTestCase } } - public function provideDataForFindByPerson(): iterable + public static function provideDataForFindByPerson(): iterable { - $this->setUp(); + self::bootKernel(); + $entityManager = self::getContainer()->get(EntityManagerInterface::class); + $scopeRepository = self::getContainer()->get(ScopeRepositoryInterface::class); - if (null === $user = $this->entityManager->createQuery('SELECT u FROM '.User::class.' u')->setMaxResults(1)->getSingleResult()) { + if (null === $user = $entityManager->createQuery('SELECT u FROM '.User::class.' u')->setMaxResults(1)->getSingleResult()) { throw new \RuntimeException('no user found'); } - if (null === $anotherUser = $this->entityManager->createQuery('SELECT u FROM '.User::class.' u WHERE u.id != :uid')->setParameter('uid', $user->getId()) + if (null === $anotherUser = $entityManager->createQuery('SELECT u FROM '.User::class.' u WHERE u.id != :uid')->setParameter('uid', $user->getId()) ->setMaxResults(1)->getSingleResult()) { throw new \RuntimeException('no user found'); } - if (null === $centerA = $this->entityManager->createQuery('SELECT c FROM '.Center::class.' c WHERE c.name LIKE :cn')->setParameter('cn', 'Center A') + if (null === $centerA = $entityManager->createQuery('SELECT c FROM '.Center::class.' c WHERE c.name LIKE :cn')->setParameter('cn', 'Center A') ->setMaxResults(1)->getSingleResult()) { throw new \RuntimeException('Center A not found'); } @@ -473,13 +481,13 @@ class AccompanyingPeriodACLAwareRepositoryTest extends KernelTestCase ->setBirthdate((new \DateTime('today'))->sub(new \DateInterval('P'.random_int(18, 100).'Y'))) ->setCenter($centerA) ; - $this->entityManager->persist($p); + $entityManager->persist($p); self::$entitiesToDelete[] = [Person::class, $p->getId()]; } [$person, $anotherPerson, $person2, $person3] = $persons; - $scopes = $this->scopeRepository->findAll(); + $scopes = $scopeRepository->findAll(); if (3 > count($scopes)) { throw new \RuntimeException('not enough scopes for this test'); @@ -488,7 +496,7 @@ class AccompanyingPeriodACLAwareRepositoryTest extends KernelTestCase $scopesGroup2 = [$scopes[1]]; // case: a period is in draft state - $period = $this->buildPeriod($person, $scopesCanSee, $user, false); + $period = self::buildPeriod($person, $scopesCanSee, $user, false); yield [$user, $person, $scopesCanSee, [], [$period], 'a user can see his period during draft state']; @@ -496,7 +504,7 @@ class AccompanyingPeriodACLAwareRepositoryTest extends KernelTestCase yield [$anotherUser, $person, $scopesCanSee, [], [], 'another user is not allowed to see the period of someone else in draft state']; // the period is confirmed - $period = $this->buildPeriod($anotherPerson, $scopesCanSee, $user, true); + $period = self::buildPeriod($anotherPerson, $scopesCanSee, $user, true); // the other user can now see it yield [$user, $anotherPerson, $scopesCanSee, [], [$period], 'a user see his period when confirmed']; @@ -504,7 +512,7 @@ class AccompanyingPeriodACLAwareRepositoryTest extends KernelTestCase yield [$anotherUser, $anotherPerson, $scopesGroup2, [], [], 'another user without the required scopes is not allowed to see the period when not draft']; // this period will be confidential - $period = $this->buildPeriod($person2, $scopesCanSee, $user, true); + $period = self::buildPeriod($person2, $scopesCanSee, $user, true); $period->setConfidential(true)->setUser($user, true); yield [$user, $person2, $scopesCanSee, [], [$period], 'a user see his period when confirmed and confidential with required scopes']; @@ -513,16 +521,19 @@ class AccompanyingPeriodACLAwareRepositoryTest extends KernelTestCase yield [$anotherUser, $person2, $scopesCanSee, $scopesCanSee, [$period], 'a user see the period when confirmed and confidential if he has required scope to see the period']; // period draft with creator = null - $period = $this->buildPeriod($person3, $scopesCanSee, null, false); + $period = self::buildPeriod($person3, $scopesCanSee, null, false); yield [$user, $person3, $scopesCanSee, [], [$period], 'a user see a period when draft if no creator on the period']; - $this->entityManager->flush(); + $entityManager->flush(); } /** * @param array $scopes */ - private function buildPeriod(Person $person, array $scopes, User|null $creator, bool $confirm): AccompanyingPeriod + private static function buildPeriod(Person $person, array $scopes, User|null $creator, bool $confirm): AccompanyingPeriod { + $entityManager = self::getContainer()->get(EntityManagerInterface::class); + $registry = self::getContainer()->get(Registry::class); + $period = new AccompanyingPeriod(); $period->addPerson($person); if (null !== $creator) { @@ -533,11 +544,11 @@ class AccompanyingPeriodACLAwareRepositoryTest extends KernelTestCase $period->addScope($scope); } - $this->entityManager->persist($period); + $entityManager->persist($period); self::$periodsIdsToDelete[] = $period->getId(); if ($confirm) { - $workflow = $this->registry->get($period, 'accompanying_period_lifecycle'); + $workflow = $registry->get($period, 'accompanying_period_lifecycle'); $workflow->apply($period, 'confirm'); } diff --git a/src/Bundle/ChillPersonBundle/Tests/Serializer/Normalizer/PersonDocGenNormalizerTest.php b/src/Bundle/ChillPersonBundle/Tests/Serializer/Normalizer/PersonDocGenNormalizerTest.php index 53656136b..4c7ceee42 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Serializer/Normalizer/PersonDocGenNormalizerTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Serializer/Normalizer/PersonDocGenNormalizerTest.php @@ -77,7 +77,7 @@ final class PersonDocGenNormalizerTest extends KernelTestCase $this->normalizer = self::getContainer()->get(NormalizerInterface::class); } - public function dataGeneratorNormalizationNullOrNotNullHaveSameKeys(): iterable + public static function dataGeneratorNormalizationNullOrNotNullHaveSameKeys(): iterable { yield [['docgen:expects' => Person::class, 'groups' => ['docgen:read']]]; @@ -88,7 +88,7 @@ final class PersonDocGenNormalizerTest extends KernelTestCase yield [['docgen:expects' => Person::class, 'groups' => ['docgen:read'], 'docgen:person:with-budget' => true]]; } - public function generateData() + public static function generateData() { $person = new Person(); $person diff --git a/src/Bundle/ChillPersonBundle/Tests/Service/DocGenerator/AccompanyingPeriodContextTest.php b/src/Bundle/ChillPersonBundle/Tests/Service/DocGenerator/AccompanyingPeriodContextTest.php index d2eb29a1a..c73de9f78 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Service/DocGenerator/AccompanyingPeriodContextTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Service/DocGenerator/AccompanyingPeriodContextTest.php @@ -124,7 +124,7 @@ class AccompanyingPeriodContextTest extends KernelTestCase call_user_func($assertionsOnData, $data); } - public function provideNormalizedData(): iterable + public static function provideNormalizedData(): iterable { self::bootKernel(); $em = self::getContainer()->get(EntityManagerInterface::class); diff --git a/src/Bundle/ChillPersonBundle/Tests/Service/DocGenerator/PersonContextTest.php b/src/Bundle/ChillPersonBundle/Tests/Service/DocGenerator/PersonContextTest.php index 4c5c41b9f..ff360ccaa 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Service/DocGenerator/PersonContextTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Service/DocGenerator/PersonContextTest.php @@ -115,7 +115,7 @@ final class PersonContextTest extends KernelTestCase call_user_func($assertionsOnData, $data); } - public function provideNormalizedData(): iterable + public static function provideNormalizedData(): iterable { self::bootKernel(); $em = self::getContainer()->get(EntityManagerInterface::class); diff --git a/src/Bundle/ChillPersonBundle/Tests/Service/GenericDoc/Providers/AccompanyingPeriodCalendarGenericDocProviderTest.php b/src/Bundle/ChillPersonBundle/Tests/Service/GenericDoc/Providers/AccompanyingPeriodCalendarGenericDocProviderTest.php index 2fda9c3b8..cae53d9a5 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Service/GenericDoc/Providers/AccompanyingPeriodCalendarGenericDocProviderTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Service/GenericDoc/Providers/AccompanyingPeriodCalendarGenericDocProviderTest.php @@ -99,11 +99,12 @@ class AccompanyingPeriodCalendarGenericDocProviderTest extends KernelTestCase self::assertStringContainsStringIgnoringCase('TRUE = FALSE', $sql); } - public function provideDataForPerson(): iterable + public static function provideDataForPerson(): iterable { - $this->setUp(); + self::bootKernel(); + $entityManager = self::getContainer()->get(EntityManagerInterface::class); - if (null === $person = $this->entityManager->createQuery('SELECT p FROM '.Person::class.' p WHERE SIZE(p.accompanyingPeriodParticipations) > 0') + if (null === $person = $entityManager->createQuery('SELECT p FROM '.Person::class.' p WHERE SIZE(p.accompanyingPeriodParticipations) > 0') ->setMaxResults(1)->getSingleResult()) { throw new \RuntimeException('There is no person'); } @@ -116,11 +117,12 @@ class AccompanyingPeriodCalendarGenericDocProviderTest extends KernelTestCase yield [$person, null, new \DateTimeImmutable('6 month ago'), null]; } - public function provideDataForAccompanyingPeriod(): iterable + public static function provideDataForAccompanyingPeriod(): iterable { - $this->setUp(); + self::bootKernel(); + $entityManager = self::getContainer()->get(EntityManagerInterface::class); - if (null === $period = $this->entityManager->createQuery('SELECT p FROM '.AccompanyingPeriod::class.' p ') + if (null === $period = $entityManager->createQuery('SELECT p FROM '.AccompanyingPeriod::class.' p ') ->setMaxResults(1)->getSingleResult()) { throw new \RuntimeException('There is no accompanying period'); } diff --git a/src/Bundle/ChillPersonBundle/Tests/Service/GenericDoc/Providers/AccompanyingPeriodWorkEvaluationGenericDocProviderTest.php b/src/Bundle/ChillPersonBundle/Tests/Service/GenericDoc/Providers/AccompanyingPeriodWorkEvaluationGenericDocProviderTest.php index 74ffc2340..8d49a54e8 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Service/GenericDoc/Providers/AccompanyingPeriodWorkEvaluationGenericDocProviderTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Service/GenericDoc/Providers/AccompanyingPeriodWorkEvaluationGenericDocProviderTest.php @@ -70,7 +70,7 @@ class AccompanyingPeriodWorkEvaluationGenericDocProviderTest extends KernelTestC self::assertIsInt($nb, 'Test that there are no errors'); } - public function provideSearchArguments(): iterable + public static function provideSearchArguments(): iterable { yield [null, null, null]; yield [new \DateTimeImmutable('1 month ago'), null, null]; diff --git a/src/Bundle/ChillPersonBundle/Tests/Service/GenericDoc/Providers/PersonCalendarGenericDocProviderTest.php b/src/Bundle/ChillPersonBundle/Tests/Service/GenericDoc/Providers/PersonCalendarGenericDocProviderTest.php index 9bbe500fe..fe11c2374 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Service/GenericDoc/Providers/PersonCalendarGenericDocProviderTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Service/GenericDoc/Providers/PersonCalendarGenericDocProviderTest.php @@ -52,11 +52,12 @@ class PersonCalendarGenericDocProviderTest extends KernelTestCase self::assertIsInt($nb); } - public function provideDataForPerson(): iterable + public static function provideDataForPerson(): iterable { - $this->setUp(); + self::bootKernel(); + $entityManager = self::getContainer()->get(EntityManagerInterface::class); - if (null === $person = $this->entityManager->createQuery('SELECT p FROM '.Person::class.' p ') + if (null === $person = $entityManager->createQuery('SELECT p FROM '.Person::class.' p ') ->setMaxResults(1)->getSingleResult()) { throw new \RuntimeException('There is no person'); } diff --git a/src/Bundle/ChillPersonBundle/Tests/Templating/Entity/ClosingMotiveRenderTest.php b/src/Bundle/ChillPersonBundle/Tests/Templating/Entity/ClosingMotiveRenderTest.php index eba8fc077..e85267981 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Templating/Entity/ClosingMotiveRenderTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Templating/Entity/ClosingMotiveRenderTest.php @@ -50,7 +50,7 @@ class ClosingMotiveRenderTest extends KernelTestCase self::assertStringContainsString($expectedContent, $actual); } - public function provideClosingMotiveWithRenderString(): iterable + public static function provideClosingMotiveWithRenderString(): iterable { $closingMotive = (new ClosingMotive())->setName(['fr' => 'Left']); diff --git a/src/Bundle/ChillPersonBundle/Tests/Timeline/TimelineAccompanyingPeriodTest.php b/src/Bundle/ChillPersonBundle/Tests/Timeline/TimelineAccompanyingPeriodTest.php index 6a2ff3d77..2a81a57d8 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Timeline/TimelineAccompanyingPeriodTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Timeline/TimelineAccompanyingPeriodTest.php @@ -28,7 +28,7 @@ final class TimelineAccompanyingPeriodTest extends WebTestCase { use PrepareClientTrait; - public function provideDataPersonWithAccompanyingPeriod() + public static function provideDataPersonWithAccompanyingPeriod() { self::bootKernel(); diff --git a/src/Bundle/ChillPersonBundle/Tests/Validator/Household/MaxHolderValidatorTest.php b/src/Bundle/ChillPersonBundle/Tests/Validator/Household/MaxHolderValidatorTest.php index c01682804..2880afb35 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Validator/Household/MaxHolderValidatorTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Validator/Household/MaxHolderValidatorTest.php @@ -25,7 +25,7 @@ use Symfony\Component\Validator\Test\ConstraintValidatorTestCase; */ final class MaxHolderValidatorTest extends ConstraintValidatorTestCase { - public function provideInvalidHousehold() + public static function provideInvalidHousehold() { $household = new Household(); $position = (new Position())