|
@@ -2,94 +2,188 @@
|
|
|
|
|
|
|
|
namespace App\Tests\Fixture;
|
|
namespace App\Tests\Fixture;
|
|
|
|
|
|
|
|
|
|
+use DateTime;
|
|
|
|
|
+use App\Service\Utils\Uuid;
|
|
|
|
|
+use App\Entity\Access\Access;
|
|
|
use App\Entity\Booking\Event;
|
|
use App\Entity\Booking\Event;
|
|
|
-use App\Entity\Core\ContactPoint;
|
|
|
|
|
|
|
+use App\Entity\Person\Person;
|
|
|
|
|
+use App\Entity\Education\Cycle;
|
|
|
use App\Entity\Network\Network;
|
|
use App\Entity\Network\Network;
|
|
|
-use App\Entity\Network\NetworkOrganization;
|
|
|
|
|
-use App\Entity\Organization\Organization;
|
|
|
|
|
-use App\Entity\Organization\Parameters;
|
|
|
|
|
|
|
+use App\Entity\Core\ContactPoint;
|
|
|
|
|
+use App\Entity\Education\Education;
|
|
|
use App\Enum\Booking\VisibilityEnum;
|
|
use App\Enum\Booking\VisibilityEnum;
|
|
|
-use App\Enum\Core\ContactPointTypeEnum;
|
|
|
|
|
use App\Enum\Organization\LegalEnum;
|
|
use App\Enum\Organization\LegalEnum;
|
|
|
-use App\Enum\Organization\PrincipalTypeEnum;
|
|
|
|
|
-use Doctrine\Bundle\FixturesBundle\Fixture;
|
|
|
|
|
|
|
+use App\Entity\Billing\AccessBilling;
|
|
|
|
|
+use App\Entity\Billing\ResidenceArea;
|
|
|
|
|
+use App\Entity\Organization\Settings;
|
|
|
|
|
+use App\Entity\Billing\BillingSetting;
|
|
|
|
|
+use App\Entity\Organization\Subdomain;
|
|
|
|
|
+use App\Entity\Organization\Parameters;
|
|
|
|
|
+use App\Enum\Core\ContactPointTypeEnum;
|
|
|
use Doctrine\Persistence\ObjectManager;
|
|
use Doctrine\Persistence\ObjectManager;
|
|
|
|
|
+use Doctrine\ORM\EntityManagerInterface;
|
|
|
|
|
+use App\Entity\Education\EducationTiming;
|
|
|
|
|
+use App\Entity\Organization\Organization;
|
|
|
|
|
+use App\Entity\Education\CycleByEducation;
|
|
|
|
|
+use App\Entity\Education\EducationStudent;
|
|
|
|
|
+use App\Entity\Network\NetworkOrganization;
|
|
|
|
|
+use Doctrine\Bundle\FixturesBundle\Fixture;
|
|
|
|
|
+use App\Enum\Organization\PrincipalTypeEnum;
|
|
|
|
|
+use App\Entity\Education\EducationCurriculum;
|
|
|
|
|
+use Doctrine\Common\DataFixtures\Purger\ORMPurger;
|
|
|
|
|
+use Doctrine\Bundle\FixturesBundle\FixtureGroupInterface;
|
|
|
use Symfony\Component\Serializer\Context\SerializerContextBuilder;
|
|
use Symfony\Component\Serializer\Context\SerializerContextBuilder;
|
|
|
-use App\Service\Utils\Uuid;
|
|
|
|
|
|
|
|
|
|
-class OrganizationFixtures extends Fixture
|
|
|
|
|
|
|
+class OrganizationFixtures extends Fixture implements FixtureGroupInterface
|
|
|
{
|
|
{
|
|
|
|
|
+ protected EntityManagerInterface $em;
|
|
|
|
|
+
|
|
|
|
|
+ public static function getGroups(): array
|
|
|
|
|
+ {
|
|
|
|
|
+ return ['poc'];
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * Delete all DB records before populating fixtures.
|
|
|
|
|
+ *
|
|
|
|
|
+ * @return void
|
|
|
|
|
+ * @throws \Doctrine\DBAL\Exception
|
|
|
|
|
+ */
|
|
|
|
|
+ private function purgeDb()
|
|
|
|
|
+ {
|
|
|
|
|
+ if (!preg_match('/.*test.*/', $this->em->getConnection()->getDatabase())) {
|
|
|
|
|
+ throw new \RuntimeException("The DB name shall contain 'test' in its name to be purge");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ $this->em->getConnection()->exec('SET FOREIGN_KEY_CHECKS = 0;');
|
|
|
|
|
+ $purger = new ORMPurger($this->em);
|
|
|
|
|
+ $purger->setPurgeMode(ORMPurger::PURGE_MODE_DELETE);
|
|
|
|
|
+ $purger->purge();
|
|
|
|
|
+ $this->em->getConnection()->exec('SET FOREIGN_KEY_CHECKS = 1;');
|
|
|
|
|
+ }
|
|
|
public function load(ObjectManager $em): void
|
|
public function load(ObjectManager $em): void
|
|
|
{
|
|
{
|
|
|
|
|
+ // purge DB
|
|
|
|
|
+ $this->em = $em;
|
|
|
|
|
+ $this->purgeDb();
|
|
|
|
|
+
|
|
|
|
|
+ // create an organization with a network, legal status accesses, Param , name, id and settings
|
|
|
$network = new Network();
|
|
$network = new Network();
|
|
|
$network->setName('NET');
|
|
$network->setName('NET');
|
|
|
$em->persist($network);
|
|
$em->persist($network);
|
|
|
|
|
|
|
|
- // Create the root organization (opentalent)
|
|
|
|
|
- $parameters0 = new Parameters();
|
|
|
|
|
- $em->persist($parameters0);
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
$contactPoint0 = new ContactPoint();
|
|
$contactPoint0 = new ContactPoint();
|
|
|
$contactPoint0->setContactType(ContactPointTypeEnum::PRINCIPAL()->getValue());
|
|
$contactPoint0->setContactType(ContactPointTypeEnum::PRINCIPAL()->getValue());
|
|
|
$em->persist($contactPoint0);
|
|
$em->persist($contactPoint0);
|
|
|
|
|
|
|
|
|
|
+ // Create the root organization (opentalent)
|
|
|
$root = new Organization();
|
|
$root = new Organization();
|
|
|
$root->setName('Root');
|
|
$root->setName('Root');
|
|
|
$root->setLegalStatus(LegalEnum::COMMERCIAL_SOCIETY()->getValue());
|
|
$root->setLegalStatus(LegalEnum::COMMERCIAL_SOCIETY()->getValue());
|
|
|
$root->setPrincipalType(PrincipalTypeEnum::NATIONAL_FEDERATION()->getValue());
|
|
$root->setPrincipalType(PrincipalTypeEnum::NATIONAL_FEDERATION()->getValue());
|
|
|
- $root->setParameters($parameters0);
|
|
|
|
|
$root->addContactPoint($contactPoint0);
|
|
$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);
|
|
|
|
|
|
|
+
|
|
|
|
|
+ // subdomain fixtures
|
|
|
|
|
+ $subdomain = new Subdomain();
|
|
|
|
|
+ $subdomain->setOrganization($root);
|
|
|
|
|
+ $subdomain->setSubdomain('subdomain');
|
|
|
|
|
+ $subdomain->setActive(true);
|
|
|
|
|
+
|
|
|
|
|
+ $parameters = new Parameters();
|
|
|
|
|
+ $parameters->setFinancialDate(new DateTime());
|
|
|
|
|
+ $parameters->setMusicalDate(new DateTime());
|
|
|
|
|
+ $parameters->setStartCourseDate(new DateTime());
|
|
|
|
|
+ $parameters->setEndCourseDate(new DateTime());
|
|
|
|
|
+ $parameters->setAverage(20);
|
|
|
|
|
+ $parameters->setEditCriteriaNotationByAdminOnly(true);
|
|
|
|
|
+ $parameters->setSmsSenderName('MySender');
|
|
|
|
|
+ $parameters->setLogoDonorsMove(false);
|
|
|
|
|
+ $parameters->setSubDomain('subdomain');
|
|
|
|
|
+ $parameters->setWebsite('https://www.example.com');
|
|
|
|
|
+ $parameters->setOtherWebsite('https://www.otherwebsite.com');
|
|
|
|
|
+ $parameters->setCustomDomain('https://www.customdomain.com');
|
|
|
|
|
+ $parameters->setDesactivateOpentalentSiteWeb(false);
|
|
|
|
|
+ $parameters->setBulletinPeriod('SomePeriod');
|
|
|
|
|
+ $parameters->setBulletinWithTeacher(false);
|
|
|
|
|
+ $parameters->setBulletinPrintAddress(false);
|
|
|
|
|
+ $parameters->setBulletinSignatureDirector(true);
|
|
|
|
|
+ $parameters->setBulletinDisplayLevelAcquired(true);
|
|
|
|
|
+ $parameters->setBulletinShowEducationWithoutEvaluation(false);
|
|
|
|
|
+ $parameters->setBulletinViewTestResults(false);
|
|
|
|
|
+ $parameters->setBulletinShowAbsences(false);
|
|
|
|
|
+ $parameters->setBulletinShowAverages(true);
|
|
|
|
|
+ $parameters->setBulletinOutput('SomeOutput');
|
|
|
|
|
+ $parameters->setBulletinEditWithoutEvaluation(true);
|
|
|
|
|
+ $parameters->setBulletinReceiver('STUDENTS_AND_THEIR_GUARDIANS');
|
|
|
|
|
+ $parameters->setBulletinCriteriaSort('BY_CRITERIA_INSERT');
|
|
|
|
|
+ $parameters->setUsernameSMS('username');
|
|
|
|
|
+ $parameters->setPasswordSMS('password');
|
|
|
|
|
+ $parameters->setShowAdherentList(true);
|
|
|
|
|
+ $parameters->setStudentsAreAdherents(false);
|
|
|
|
|
+ $parameters->setTimezone('Europe/Paris');
|
|
|
|
|
+ $parameters->setEducationPeriodicity('ANNUAL');
|
|
|
|
|
+ $parameters->setAdvancedEducationNotationType('BY_EDUCATION');
|
|
|
|
|
+ $parameters->setSendAttendanceEmail(false);
|
|
|
|
|
+ $parameters->setSendAttendanceSms(false);
|
|
|
|
|
+ $parameters->setGenerateAttendanceReport(true);
|
|
|
|
|
+ $parameters->setConsultPedagogicResult(true);
|
|
|
|
|
+ $parameters->setConsultTeacherListing(true);
|
|
|
|
|
+ $parameters->setPeriodValidation(true);
|
|
|
|
|
+ $parameters->setNotifyAdministrationAbsence(false);
|
|
|
|
|
+ $root->setParameters($parameters);
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ $settings = new Settings();
|
|
|
|
|
+ $settings->setProduct('school');
|
|
|
|
|
+ $settings->setModules(['BillingAdministration']);
|
|
|
|
|
+ $root->setSettings($settings);
|
|
|
|
|
+
|
|
|
|
|
+ //create acesses with orga
|
|
|
|
|
+ $access = new Access();
|
|
|
|
|
+ $access->setOrganization($root);
|
|
|
|
|
+ $access->setRoles(["ROLE_ADMIN","ROLE_ADMIN_CORE","ROLE_SUPER_ADMIN"]);
|
|
|
|
|
+
|
|
|
|
|
+ $teacherAccess = new Access();
|
|
|
|
|
+ $teacherAccess->setOrganization($root);
|
|
|
|
|
+ $teacherAccess->setRoles(["ROLE_TEACHER"]);
|
|
|
|
|
+
|
|
|
|
|
+ // create a person :
|
|
|
|
|
+ $person = new Person();
|
|
|
|
|
+ $person->addAccess($access);
|
|
|
|
|
+ $person->setUsername('username');
|
|
|
|
|
+ $person->setPassword('password');
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ // create BillingSetting with an organization
|
|
|
|
|
+ $billingSetting = new BillingSetting();
|
|
|
|
|
+ $billingSetting->setOrganization($root);
|
|
|
|
|
+ $em->persist($billingSetting);
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ $residenceArea = new ResidenceArea();
|
|
|
|
|
+ $residenceArea->setLabel('label');
|
|
|
|
|
+ $residenceArea->setBillingSetting($billingSetting);
|
|
|
|
|
+
|
|
|
|
|
+ //create an AccessBilling with an access
|
|
|
|
|
+ $accessBilling = new AccessBilling();
|
|
|
|
|
+ $accessBilling->setAccess($access);
|
|
|
|
|
+ $accessBilling->setResidenceArea($residenceArea);
|
|
|
|
|
+
|
|
|
|
|
+ $education = new Education();
|
|
|
|
|
+ $educationCurriculum = new EducationCurriculum();
|
|
|
|
|
+ $cycleByEducation = new CycleByEducation();
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ $cycle = new Cycle();
|
|
|
|
|
+ $cycle->setOrganization($root);
|
|
|
|
|
+ $cycle->setLabel('cycle');
|
|
|
|
|
+ $cycle->setCycleEnum('CYCLE_1');
|
|
|
|
|
+ $cycle->setIsSystem(false);
|
|
|
|
|
+ $cycle->addCycleByEducation($cycleByEducation);
|
|
|
|
|
|
|
|
|
|
|
|
|
// Booking
|
|
// Booking
|
|
@@ -98,13 +192,22 @@ class OrganizationFixtures extends Fixture
|
|
|
$end = $now->add(new \DateInterval('P1M1D'));
|
|
$end = $now->add(new \DateInterval('P1M1D'));
|
|
|
|
|
|
|
|
$event = new Event();
|
|
$event = new Event();
|
|
|
- $event->setOrganization($organization);
|
|
|
|
|
|
|
+ $event->setOrganization($root);
|
|
|
$event->setName('My Event');
|
|
$event->setName('My Event');
|
|
|
$event->setDatetimeStart($start);
|
|
$event->setDatetimeStart($start);
|
|
|
$event->setDatetimeEnd($end);
|
|
$event->setDatetimeEnd($end);
|
|
|
$event->setVisibility(VisibilityEnum::PUBLIC_VISIBILITY());
|
|
$event->setVisibility(VisibilityEnum::PUBLIC_VISIBILITY());
|
|
|
$event->setUuid(Uuid::uuid());
|
|
$event->setUuid(Uuid::uuid());
|
|
|
|
|
+
|
|
|
|
|
+ $em->persist($root);
|
|
|
$em->persist($event);
|
|
$em->persist($event);
|
|
|
|
|
+ $em->persist($person);
|
|
|
|
|
+ $em->persist($access);
|
|
|
|
|
+ $em->persist($accessBilling);
|
|
|
|
|
+ $em->persist($billingSetting);
|
|
|
|
|
+ $em->persist($residenceArea);
|
|
|
|
|
+ $em->persist($subdomain);
|
|
|
|
|
+ $em->persist($parameters);
|
|
|
|
|
|
|
|
$em->flush();
|
|
$em->flush();
|
|
|
}
|
|
}
|