From 75aa600a201c04cdbf39750552e0e9adcd13b3e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 13 Sep 2021 12:41:55 +0200 Subject: [PATCH 1/3] fix composer.json and upgrade base app --- composer.json | 3 ++- tests/app | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 88e3c520a..04ff52e3d 100644 --- a/composer.json +++ b/composer.json @@ -95,6 +95,7 @@ } }, "config": { - "bin-dir": "bin" + "bin-dir": "bin", + "vendor-dir": "tests/app/vendor" } } diff --git a/tests/app b/tests/app index 8839b431f..bd95d3c96 160000 --- a/tests/app +++ b/tests/app @@ -1 +1 @@ -Subproject commit 8839b431f296733b792c788f2ef58e5ecd6419d3 +Subproject commit bd95d3c96a437757b7e8f35cdfd30da9aeac1a01 From ed31dc3157fb245880e6903ef92a6ad416cc961b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 13 Sep 2021 13:13:17 +0200 Subject: [PATCH 2/3] enable test for calendar --- phpunit.xml.dist | 5 +- .../Controller/CalendarControllerTest.php | 59 +++++++++++-------- 2 files changed, 37 insertions(+), 27 deletions(-) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 25c5f0ff0..96f7461eb 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -10,7 +10,7 @@ - + @@ -31,6 +31,9 @@ src/Bundle/ChillPersonBundle/Tests/Controller/PersonDuplicateControllerViewTest.php + + src/Bundle/ChillCalendarBundle/Tests/ + diff --git a/src/Bundle/ChillCalendarBundle/Tests/Controller/CalendarControllerTest.php b/src/Bundle/ChillCalendarBundle/Tests/Controller/CalendarControllerTest.php index c94238a51..00fca668a 100644 --- a/src/Bundle/ChillCalendarBundle/Tests/Controller/CalendarControllerTest.php +++ b/src/Bundle/ChillCalendarBundle/Tests/Controller/CalendarControllerTest.php @@ -2,65 +2,72 @@ namespace Chill\CalendarBundle\Tests\Controller; +use Chill\PersonBundle\Repository\AccompanyingPeriodRepository; +use Doctrine\ORM\EntityManagerInterface; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; use Symfony\Component\HttpFoundation\Request; use Chill\PersonBundle\Entity\AccompanyingPeriod; class CalendarControllerTest extends WebTestCase { - - /** - * Setup before the first test of this class (see phpunit doc) - */ - public static function setUpBeforeClass() - { - static::bootKernel(); - } /** * Setup before each test method (see phpunit doc) */ public function setUp() { + static::bootKernel(); $this->client = static::createClient(array(), array( 'PHP_AUTH_USER' => 'center a_social', 'PHP_AUTH_PW' => 'password', )); } - - private function getAccompanyingPeriodFromFixtures(): AccompanyingPeriod + + public function provideAccompanyingPeriod(): iterable { - $em = static::$kernel->getContainer() - ->get('doctrine.orm.entity_manager'); + static::bootKernel(); + $em= static::$container->get(EntityManagerInterface::class); - $accompanying_period = $em->getRepository('ChillPersonBundle:AccompanyingPeriod')->find(1); + $nb = $em->createQueryBuilder() + ->from(AccompanyingPeriod::class, 'ac') + ->select('COUNT(ac) AS nb') + ->getQuery() + ->getSingleScalarResult() + ; - if ($accompanying_period === NULL) { - throw new \RuntimeException("We need an accompanying course with id = 1. Did you add fixtures ?"); - } - - return $accompanying_period; + yield [ $em->createQueryBuilder() + ->from(AccompanyingPeriod::class, 'ac') + ->select('ac.id') + ->setFirstResult(\random_int(0, $nb)) + ->setMaxResults(1) + ->getQuery() + ->getSingleScalarResult() + ]; } - public function testList() + /** + * @dataProvider provideAccompanyingPeriod + */ + public function testList(int $accompanyingPeriodId) { $this->client->request( - Request::METHOD_GET, - sprintf('/fr/calendar/?accompanying_period_id=%d', $this->getAccompanyingPeriodFromFixtures()->getId()) + Request::METHOD_GET, + sprintf('/fr/calendar/calendar/?accompanying_period_id=%d', $accompanyingPeriodId) ); $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); } - - public function testNew() + /** + * @dataProvider provideAccompanyingPeriod + */ + public function testNew(int $accompanyingPeriodId) { $this->client->request( - Request::METHOD_GET, - sprintf('/fr/calendar/new?accompanying_period_id=%d', $this->getAccompanyingPeriodFromFixtures()->getId()) + Request::METHOD_GET, + sprintf('/fr/calendar/calendar/new?accompanying_period_id=%d', $accompanyingPeriodId) ); $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); } - } From f7cb93fdac337c10c3efd8a57db1c4a2966153cb Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Tue, 14 Sep 2021 10:30:52 +0200 Subject: [PATCH 3/3] Update controller and the way they are autoloaded --- .../config/services/controller.yaml | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/Bundle/ChillDocStoreBundle/config/services/controller.yaml b/src/Bundle/ChillDocStoreBundle/config/services/controller.yaml index 9899ffa2e..6675102d9 100644 --- a/src/Bundle/ChillDocStoreBundle/config/services/controller.yaml +++ b/src/Bundle/ChillDocStoreBundle/config/services/controller.yaml @@ -1,11 +1,9 @@ services: - Chill\DocStoreBundle\Controller\: - resource: '../../Controller' - tags: ['controller.service_arguments'] - - Chill\DocStoreBundle\Controller\DocumentPersonController: - arguments: - $translator: '@Symfony\Component\Translation\TranslatorInterface' - $eventDispatcher: '@Symfony\Component\EventDispatcher\EventDispatcherInterface' - $authorizationHelper: '@Chill\MainBundle\Security\Authorization\AuthorizationHelper' - tags: ['controller.service_arguments'] \ No newline at end of file + _defaults: + autowire: true + autoconfigure: true + + Chill\DocStoreBundle\Controller\: + resource: "../../Controller" + tags: ["controller.service_arguments"] +