From 16e4a0f304ba526e385df0959370ab805bf3c2ca Mon Sep 17 00:00:00 2001 From: Fabrice Gangler <fabrice.gangler@adullact.org> Date: Sun, 23 Mar 2025 22:02:15 +0100 Subject: [PATCH] test(fixture): add i18n organization description --- .../DataFixtures/AppOrganizationFixtures.php | 34 +++++++++++++++++-- .../FunctionalTestOrganizationPagesTest.php | 2 +- 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/webapp/src/DataFixtures/AppOrganizationFixtures.php b/webapp/src/DataFixtures/AppOrganizationFixtures.php index 20518eb..95ba3b0 100644 --- a/webapp/src/DataFixtures/AppOrganizationFixtures.php +++ b/webapp/src/DataFixtures/AppOrganizationFixtures.php @@ -22,6 +22,7 @@ namespace App\DataFixtures; use App\Entity\Organization; +use App\Entity\OrganizationI18n; use App\Entity\OrganizationType; use Doctrine\Bundle\FixturesBundle\Fixture; use Doctrine\Persistence\ObjectManager; @@ -33,14 +34,31 @@ class AppOrganizationFixtures extends Fixture ]; public const ORGANIZATIONS = [ - [ + 1 => [ + 'id' => 1, // must be identical to array key + 'createdAt' => '2016-06-19 13:31:24', + 'updatedAt' => '2025-01-25 14:22:05', + 'type' => 'no_profit', + 'name' => "ADULLACT", + 'slug' => 'adullact', + 'website' => 'https://adullact.org', + 'oldComptoirId' => 999, + 'description' => [ + 'fr' => "Association **des** ...\n" + . "- logiciel libre\n- numrérique libre", + 'en' => 'No **profit** organization...', + ], + ], + 2 => [ + 'id' => 2, // must be identical to array key 'createdAt' => '2022-06-19 13:31:24', 'updatedAt' => '2022-07-25 14:22:05', 'type' => 'public_sector', 'name' => "Mairie d'Abbeville", 'slug' => 'mairie-d-abbeville', ], - [ + 3 => [ + 'id' => 3, // must be identical to array key 'createdAt' => '2023-06-19 13:31:24', 'updatedAt' => '2023-07-25 14:22:05', 'type' => 'public_sector', @@ -80,6 +98,18 @@ public function load(ObjectManager $manager): void } $manager->persist($organization); $manager->flush(); + + if (isset($data['description'])) { + foreach ($data['description'] as $locale => $text) { + $organizationI18n = new OrganizationI18n(); + $organizationI18n->setOrganization($organization); + $organizationI18n->setLocale($locale); + $organizationI18n->setType(1); + $organizationI18n->setText($text); + $manager->persist($organizationI18n); + $manager->flush(); + } + } } } } diff --git a/webapp/tests/Functional/Organization/FunctionalTestOrganizationPagesTest.php b/webapp/tests/Functional/Organization/FunctionalTestOrganizationPagesTest.php index e4b4fac..e00537f 100644 --- a/webapp/tests/Functional/Organization/FunctionalTestOrganizationPagesTest.php +++ b/webapp/tests/Functional/Organization/FunctionalTestOrganizationPagesTest.php @@ -76,7 +76,7 @@ public function testOneOrganizationPageAllowToTruncateUrlToRedirectToAllOrganiza public function testOneOrganizationPageAllowToChangeLocaleInUrl(): void { - $organizationId = AppOrganizationFixtures::ORGANIZATIONS[2]['id']; + $organizationId = AppOrganizationFixtures::ORGANIZATIONS[3]['id']; $organizationSlug = AppOrganizationFixtures::ORGANIZATIONS[$organizationId]['slug']; $client = static::createClient(); $this->checkRedirectionToNewUrl( -- GitLab