Prechádzať zdrojové kódy

move fixture dir and create a functionnal fixture dataset for first test

Olivier Massot 2 rokov pred
rodič
commit
8cb064a0be

+ 1 - 0
composer.json

@@ -107,6 +107,7 @@
     },
     "autoload-dev": {
         "psr-4": {
+            "DataFixtures\\": "tests/Fixture",
             "App\\Tests\\": "tests/"
         }
     },

+ 3 - 0
config/services.yaml

@@ -148,3 +148,6 @@ services:
     Symfony\Component\DependencyInjection\ContainerInterface: '@service_container'
     #########################################
 
+    # To use the test fixtures
+    App\Tests\Fixture\:
+        resource: '%kernel.project_dir%/tests/Fixture/*'

Rozdielové dáta súboru neboli zobrazené, pretože súbor je príliš veľký
+ 0 - 8167
sql/opentalent_test.sql


+ 7 - 7
sql/schema-extensions/002-view_federation_structures.sql

@@ -12,13 +12,13 @@ AS
                AS practices,
            oar.articles, n1.parent_id as parentId, net1.name as parentName,
            CONCAT_WS(',', n1.parent_id, n2.parent_id, n3.parent_id, n4.parent_id, n5.parent_id) as parents
-    FROM opentalent.Organization o
-             INNER JOIN opentalent.Parameters p on o.parameters_id = p.id
-             LEFT JOIN opentalent.OrganizationAddressPostal oa on oa.organization_id = o.id
-             LEFT JOIN opentalent.AddressPostal a on oa.addressPostal_id = a.id
-             LEFT JOIN opentalent.Country c ON (c.id = a.addressCountry_id)
-             LEFT JOIN opentalent.organization_contactpoint ocp ON ocp.organization_id = o.id
-             INNER JOIN (SELECT * FROM opentalent.ContactPoint WHERE `contactType`='PRINCIPAL') cp ON cp.id = ocp.contactPoint_id
+    FROM Organization o
+             INNER JOIN Parameters p on o.parameters_id = p.id
+             LEFT JOIN OrganizationAddressPostal oa on oa.organization_id = o.id
+             LEFT JOIN AddressPostal a on oa.addressPostal_id = a.id
+             LEFT JOIN Country c ON (c.id = a.addressCountry_id)
+             LEFT JOIN organization_contactpoint ocp ON ocp.organization_id = o.id
+             INNER JOIN (SELECT * FROM ContactPoint WHERE `contactType`='PRINCIPAL') cp ON cp.id = ocp.contactPoint_id
              LEFT JOIN (
                 SELECT oar_.organization_id, CONCAT('[', GROUP_CONCAT(COLUMN_JSON(COLUMN_CREATE('id', oar_.id, 'title', oar_.title, 'date', DATE_FORMAT(oar_.date, '%Y-%m-%dT%TZ'), 'link', oar_.link))), ']') as articles
                 FROM (SELECT * FROM OrganizationArticle WHERE link is not null and link != '' ORDER BY date DESC) as oar_

+ 0 - 29
src/DataFixtures/AppFixtures.php

@@ -1,29 +0,0 @@
-<?php
-
-namespace App\DataFixtures;
-
-use App\Entity\Organization\Organization;
-use App\Entity\Organization\Parameters;
-use App\Enum\Organization\LegalEnum;
-use App\Enum\Organization\PrincipalTypeEnum;
-use Doctrine\Bundle\FixturesBundle\Fixture;
-use Doctrine\Persistence\ObjectManager;
-use App\Entity\Booking\Event;
-
-class AppFixtures extends Fixture
-{
-    public function load(ObjectManager $em): void
-    {
-        $parameters = new Parameters();
-        $em->persist($parameters);
-
-        $organization = new Organization();
-        $organization->setName('Organization 1');
-        $organization->setLegalStatus(LegalEnum::ASSOCIATION_LAW_1901()->getValue());
-        $organization->setPrincipalType(PrincipalTypeEnum::ARTISTIC_EDUCATION_ONLY()->getValue());
-        $organization->setParameters($parameters);
-        $em->persist($organization);
-
-        $em->flush();
-    }
-}

+ 2 - 2
tests/Application/Public/PublicStructuresTest.php

@@ -6,9 +6,9 @@ use App\Tests\Application\OtWebTestCase;
 
 class PublicStructuresTest extends OtWebTestCase
 {
-    public function testSomething(): void
+    public function testGetIndex(): void
     {
-        $crawler = $this->get('/api/public/structures');
+        $crawler = $this->get('/api/public/federation_structures');
 
         $this->assertResponseIsSuccessful();
     }

+ 94 - 0
tests/Fixture/OrganizationFixtures.php

@@ -0,0 +1,94 @@
+<?php
+
+namespace App\Tests\Fixture;
+
+use App\Entity\Core\ContactPoint;
+use App\Entity\Network\Network;
+use App\Entity\Network\NetworkOrganization;
+use App\Entity\Organization\Organization;
+use App\Entity\Organization\Parameters;
+use App\Enum\Core\ContactPointTypeEnum;
+use App\Enum\Organization\LegalEnum;
+use App\Enum\Organization\PrincipalTypeEnum;
+use Doctrine\Bundle\FixturesBundle\Fixture;
+use Doctrine\Persistence\ObjectManager;
+use Symfony\Component\Serializer\Context\SerializerContextBuilder;
+
+class OrganizationFixtures extends Fixture
+{
+    public function load(ObjectManager $em): void
+    {
+        $network = new Network();
+        $network->setName('NET');
+        $em->persist($network);
+
+        // Create the root organization (opentalent)
+        $parameters0 = new Parameters();
+        $em->persist($parameters0);
+
+        $contactPoint0 = new ContactPoint();
+        $contactPoint0->setContactType(ContactPointTypeEnum::PRINCIPAL()->getValue());
+        $em->persist($contactPoint0);
+
+        $root = new Organization();
+        $root->setName('Root');
+        $root->setLegalStatus(LegalEnum::COMMERCIAL_SOCIETY()->getValue());
+        $root->setPrincipalType(PrincipalTypeEnum::NATIONAL_FEDERATION()->getValue());
+        $root->setParameters($parameters0);
+        $root->addContactPoint($contactPoint0);
+        $em->persist($root);
+
+        $networkOrganisation0 = new NetworkOrganization();
+        $networkOrganisation0->setOrganization($root);
+        $networkOrganisation0->setNetwork($network);
+        $em->persist($networkOrganisation0);
+
+
+        // Create a federation organization
+        $parameters1 = new Parameters();
+        $em->persist($parameters1);
+
+        $contactPoint1 = new ContactPoint();
+        $contactPoint1->setContactType(ContactPointTypeEnum::PRINCIPAL()->getValue());
+        $em->persist($contactPoint1);
+
+        $fede = new Organization();
+        $fede->setName('Fede 1');
+        $fede->setLegalStatus(LegalEnum::ASSOCIATION_LAW_1901()->getValue());
+        $fede->setPrincipalType(PrincipalTypeEnum::NATIONAL_FEDERATION()->getValue());
+        $fede->setParameters($parameters1);
+        $fede->addContactPoint($contactPoint1);
+        $em->persist($fede);
+
+        $networkOrganisation1 = new NetworkOrganization();
+        $networkOrganisation1->setOrganization($fede);
+        $networkOrganisation1->setNetwork($network);
+        $networkOrganisation1->setParent($root);
+        $em->persist($networkOrganisation1);
+
+        // Create a simple organization
+        $parameters2 = new Parameters();
+        $em->persist($parameters2);
+
+        $contactPoint2 = new ContactPoint();
+        $contactPoint2->setContactType(ContactPointTypeEnum::PRINCIPAL()->getValue());
+        $em->persist($contactPoint2);
+
+        $organization = new Organization();
+        $organization->setName('Organization 2');
+        $organization->setLegalStatus(LegalEnum::ASSOCIATION_LAW_1901()->getValue());
+        $organization->setPrincipalType(PrincipalTypeEnum::ARTISTIC_EDUCATION_ONLY()->getValue());
+        $organization->setParameters($parameters2);
+        $organization->addContactPoint($contactPoint2);
+        $em->persist($organization);
+
+        $networkOrganisation2 = new NetworkOrganization();
+        $networkOrganisation2->setOrganization($organization);
+        $networkOrganisation2->setNetwork($network);
+        $networkOrganisation2->setParent($fede);
+        $em->persist($networkOrganisation2);
+
+
+        $em->flush();
+    }
+}

+ 11 - 2
sql/readme.md → tests/Fixture/readme.md

@@ -1,7 +1,16 @@
-# SQL
+# Générer la DB de test et charger les fixtures
 
-Pour regénérer le SQL de création de la DB vide :
+Pour regénérer le SQL de création de la DB de test :
 
     mysqldump --user=root --password=mysql660 --host=localhost --port=3306 --default-character-set=utf8 --single-transaction=TRUE --no-data --skip-triggers "opentalent" --column-statistics=0 > opentalent_test.sql
 
     mysql --user=root --password=mysql660 --host=127.0.0.1 --port=3306 -D opentalent_test < opentalent_test.sql
+
+Il peut être nécessaire de regénérer les vues :
+
+    bin/console --env=staging doctrine:schema:update
+
+
+Pour recharger les fixtures :
+
+    bin/console --env=staging doctrine:fixtures:load

Niektoré súbory nie sú zobrazené, pretože je v týchto rozdielových dátach zmenené mnoho súborov