From 6df8e6dec85e5a7dc51d6564967f959543d923f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Thu, 6 May 2021 15:55:02 +0200 Subject: [PATCH 1/3] add person suite to phpunit --- phpunit.xml.dist | 2 -- 1 file changed, 2 deletions(-) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 9d74dd61a..6ce1f7b24 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -18,11 +18,9 @@ src/Bundle/ChillMainBundle/Tests/ - From c93d5ceb165565f161c03b8208301ff960c10b72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Fri, 7 May 2021 10:56:49 +0200 Subject: [PATCH 2/3] remove references to ->getContainer in favor of static:: --- .../ChillMainBundle/Test/Export/AbstractExportTest.php | 1 + .../Controller/PersonDuplicateControllerViewTest.php | 2 +- .../Tests/Export/Aggregator/AgeAggregatorTest.php | 6 ++---- .../Tests/Export/Aggregator/GenderAggregatorTest.php | 6 ++---- ...alityAggregator.php => NationalityAggregatorTest.php} | 9 +++------ .../Tests/Export/Export/CountPersonTest.php | 5 +---- .../Tests/Export/Export/ListPersonTest.php | 7 ++----- .../Tests/Export/Filter/AccompanyingPeriodFilterTest.php | 6 ++---- .../Tests/Export/Filter/BirthdayFilterTest.php | 6 ++---- .../Tests/Export/Filter/GenderFilterTest.php | 6 ++---- .../Tests/Security/Authorization/PersonVoterTest.php | 2 +- 11 files changed, 19 insertions(+), 37 deletions(-) rename src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/{NationalityAggregator.php => NationalityAggregatorTest.php} (83%) diff --git a/src/Bundle/ChillMainBundle/Test/Export/AbstractExportTest.php b/src/Bundle/ChillMainBundle/Test/Export/AbstractExportTest.php index d258c0d30..e480ab145 100644 --- a/src/Bundle/ChillMainBundle/Test/Export/AbstractExportTest.php +++ b/src/Bundle/ChillMainBundle/Test/Export/AbstractExportTest.php @@ -172,6 +172,7 @@ abstract class AbstractExportTest extends WebTestCase */ public function testInitiateQuery($modifiers, $acl, $data) { + var_dump($data); $query = $this->getExport()->initiateQuery($modifiers, $acl, $data); $this->assertTrue($query instanceof QueryBuilder || $query instanceof NativeQuery, diff --git a/src/Bundle/ChillPersonBundle/Tests/Controller/PersonDuplicateControllerViewTest.php b/src/Bundle/ChillPersonBundle/Tests/Controller/PersonDuplicateControllerViewTest.php index 1292ecbeb..e6d0c207f 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Controller/PersonDuplicateControllerViewTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Controller/PersonDuplicateControllerViewTest.php @@ -11,7 +11,7 @@ class PersonDuplicateControllerViewTest extends WebTestCase { static::bootKernel(); - $this->em = static::$kernel->getContainer() + $this->em = static::$container ->get('doctrine.orm.entity_manager'); $center = $this->em->getRepository('ChillMainBundle:Center') diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AgeAggregatorTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AgeAggregatorTest.php index 690f873e7..299cc62d5 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AgeAggregatorTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AgeAggregatorTest.php @@ -38,9 +38,7 @@ class AgeAggregatorTest extends AbstractAggregatorTest { static::bootKernel(); - $container = static::$kernel->getContainer(); - - $this->aggregator = $container->get('chill.person.export.aggregator_age'); + $this->aggregator = static::$container->get('chill.person.export.aggregator_age'); } public function getAggregator() @@ -63,7 +61,7 @@ class AgeAggregatorTest extends AbstractAggregatorTest static::bootKernel(); } - $em = static::$kernel->getContainer() + $em = static::$container ->get('doctrine.orm.entity_manager'); return array( diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/GenderAggregatorTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/GenderAggregatorTest.php index fd91305dd..724a793e3 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/GenderAggregatorTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/GenderAggregatorTest.php @@ -37,9 +37,7 @@ class GenderAggregatorTest extends AbstractAggregatorTest { static::bootKernel(); - $container = static::$kernel->getContainer(); - - $this->aggregator = $container->get('chill.person.export.aggregator_gender'); + $this->aggregator = static::$container->get('chill.person.export.aggregator_gender'); } public function getAggregator() @@ -60,7 +58,7 @@ class GenderAggregatorTest extends AbstractAggregatorTest static::bootKernel(); } - $em = static::$kernel->getContainer() + $em = static::$container ->get('doctrine.orm.entity_manager'); return array( diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/NationalityAggregator.php b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/NationalityAggregatorTest.php similarity index 83% rename from src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/NationalityAggregator.php rename to src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/NationalityAggregatorTest.php index 522b8edcd..1c358530c 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/NationalityAggregator.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/NationalityAggregatorTest.php @@ -17,7 +17,6 @@ */ namespace Chill\PersonBundle\Tests\Export\Aggregator; -require_once '/home/julien/dev/chill-dev/vendor/chill-project/main/Test/Export/AbstractAggregatorTest.php'; use Chill\MainBundle\Test\Export\AbstractAggregatorTest; /** @@ -25,7 +24,7 @@ use Chill\MainBundle\Test\Export\AbstractAggregatorTest; * * @author Julien Fastré */ -class NationalityAggregator extends AbstractAggregatorTest +class NationalityAggregatorTest extends AbstractAggregatorTest { /** * @@ -37,9 +36,7 @@ class NationalityAggregator extends AbstractAggregatorTest { static::bootKernel(); - $container = static::$kernel->getContainer(); - - $this->aggregator = $container->get('chill.person.export.aggregator_nationality'); + $this->aggregator = static::$container->get('chill.person.export.aggregator_nationality'); } public function getAggregator() @@ -61,7 +58,7 @@ class NationalityAggregator extends AbstractAggregatorTest static::bootKernel(); } - $em = static::$kernel->getContainer() + $em = static::$container ->get('doctrine.orm.entity_manager'); return array( diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Export/CountPersonTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Export/CountPersonTest.php index 5bb11f59a..8edc6e59d 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Export/CountPersonTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Export/CountPersonTest.php @@ -36,10 +36,7 @@ class CountPersonTest extends AbstractExportTest { static::bootKernel(); - /* @var $container \Symfony\Component\DependencyInjection\ContainerInterface */ - $container = self::$kernel->getContainer(); - - $this->export = $container->get('chill.person.export.export_count_person'); + $this->export = static::$container->get('chill.person.export.export_count_person'); } diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Export/ListPersonTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Export/ListPersonTest.php index 44ab79f96..2ca369a24 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Export/ListPersonTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Export/ListPersonTest.php @@ -40,10 +40,7 @@ class ListPersonTest extends AbstractExportTest { static::bootKernel(); - /* @var $container \Symfony\Component\DependencyInjection\ContainerInterface */ - $container = self::$kernel->getContainer(); - - $this->export = $container->get('chill.person.export.list_person'); + $this->export = static::$container->get('chill.person.export.list_person'); // add a fake request with a default locale (used in translatable string) $prophet = new \Prophecy\Prophet; @@ -51,7 +48,7 @@ class ListPersonTest extends AbstractExportTest $request->willExtend(\Symfony\Component\HttpFoundation\Request::class); $request->getLocale()->willReturn('fr'); - $container->get('request_stack') + static::$container->get('request_stack') ->push($request->reveal()); } diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/AccompanyingPeriodFilterTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/AccompanyingPeriodFilterTest.php index a0f4ed1be..bf040619c 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/AccompanyingPeriodFilterTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/AccompanyingPeriodFilterTest.php @@ -36,10 +36,8 @@ class AccompanyingPeriodFilterTest extends AbstractFilterTest { static::bootKernel(); - $container = static::$kernel->getContainer(); - try { - $this->filter = $container->get('chill.person.export.filter_accompanying_period'); + $this->filter = static::$container->get('chill.person.export.filter_accompanying_period'); } catch (ServiceNotFoundException $e) { $this->markTestSkipped("The current configuration does not use accompanying_periods"); } @@ -67,7 +65,7 @@ class AccompanyingPeriodFilterTest extends AbstractFilterTest static::bootKernel(); } - $em = static::$kernel->getContainer() + $em = static::$container ->get('doctrine.orm.entity_manager'); return array( diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/BirthdayFilterTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/BirthdayFilterTest.php index 1bcb040e4..e580c0f20 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/BirthdayFilterTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/BirthdayFilterTest.php @@ -36,9 +36,7 @@ class BirthdayFilterTest extends AbstractFilterTest { static::bootKernel(); - $container = static::$kernel->getContainer(); - - $this->filter = $container->get('chill.person.export.filter_birthdate'); + $this->filter = static::$container->get('chill.person.export.filter_birthdate'); } @@ -63,7 +61,7 @@ class BirthdayFilterTest extends AbstractFilterTest static::bootKernel(); } - $em = static::$kernel->getContainer() + $em = static::$container ->get('doctrine.orm.entity_manager'); return array( diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/GenderFilterTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/GenderFilterTest.php index dce198344..2d6d7e309 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/GenderFilterTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/GenderFilterTest.php @@ -43,9 +43,7 @@ class GenderFilterTest extends AbstractFilterTest $request->willExtend(\Symfony\Component\HttpFoundation\Request::class); $request->getLocale()->willReturn('fr'); - $container = static::$kernel->getContainer(); - - $this->filter = $container->get('chill.person.export.filter_gender'); + $this->filter = static::$container->get('chill.person.export.filter_gender'); } @@ -75,7 +73,7 @@ class GenderFilterTest extends AbstractFilterTest static::bootKernel(); } - $em = static::$kernel->getContainer() + $em = static::$container ->get('doctrine.orm.entity_manager'); return array( diff --git a/src/Bundle/ChillPersonBundle/Tests/Security/Authorization/PersonVoterTest.php b/src/Bundle/ChillPersonBundle/Tests/Security/Authorization/PersonVoterTest.php index 474fbc103..09f6cc2ba 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Security/Authorization/PersonVoterTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Security/Authorization/PersonVoterTest.php @@ -60,7 +60,7 @@ class PersonVoterTest extends KernelTestCase public function setUp() { static::bootKernel(); - $this->voter = static::$kernel->getContainer() + $this->voter = static::$container ->get('chill.person.security.authorization.person'); $this->prophet = new \Prophecy\Prophet(); } From d76f6d716f9541cc0850fcc55749233543f7ffd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Thu, 13 May 2021 21:44:09 +0200 Subject: [PATCH 3/3] exclude tests which concerns exports for persons --- phpunit.xml.dist | 1 + 1 file changed, 1 insertion(+) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 6ce1f7b24..ab9e69052 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -20,6 +20,7 @@ src/Bundle/ChillPersonBundle/Tests/ + src/Bundle/ChillPersonBundle/Tests/Export/*