Correction fixtures Project/Request
This commit is contained in:
parent
7666509ea8
commit
eda015a5ec
|
@ -16,75 +16,46 @@ class ProjectFixtures extends Fixture implements DependentFixtureInterface
|
||||||
{
|
{
|
||||||
|
|
||||||
//NEW PROJECT
|
//NEW PROJECT
|
||||||
$user = $manager
|
$dev1 = $manager
|
||||||
->getRepository(User::class)
|
->getRepository(User::class)
|
||||||
->findOneByUsername('dev1')
|
->findOneByUsername('dev1')
|
||||||
;
|
;
|
||||||
|
|
||||||
$project = new Project();
|
$client1 = $manager
|
||||||
$request = $manager
|
|
||||||
->getRepository(Request::class)
|
|
||||||
->findOneByTitle('Demande num 1')
|
|
||||||
;
|
|
||||||
$project->addRequest($request);
|
|
||||||
$request = $manager
|
|
||||||
->getRepository(Request::class)
|
|
||||||
->findOneByTitle('Demande num 2')
|
|
||||||
;
|
|
||||||
$project->addRequest($request);
|
|
||||||
$request = $manager
|
|
||||||
->getRepository(Request::class)
|
|
||||||
->findOneByTitle('Demande num 3')
|
|
||||||
;
|
|
||||||
$project->addRequest($request);
|
|
||||||
|
|
||||||
$project->setName("Projet 1");
|
|
||||||
$project->addUser($user);
|
|
||||||
$manager->persist($project);
|
|
||||||
|
|
||||||
//NEW PROJECT
|
|
||||||
$user = $manager
|
|
||||||
->getRepository(User::class)
|
->getRepository(User::class)
|
||||||
->findOneByUsername('client1')
|
->findOneByUsername('client1')
|
||||||
;
|
;
|
||||||
|
|
||||||
$project = new Project();
|
$client2 = $manager
|
||||||
|
|
||||||
$request = $manager
|
|
||||||
->getRepository(Request::class)
|
|
||||||
->findOneByTitle('Demande num 4')
|
|
||||||
;
|
|
||||||
$project->addRequest($request);
|
|
||||||
$request = $manager
|
|
||||||
->getRepository(Request::class)
|
|
||||||
->findOneByTitle('Demande num 5')
|
|
||||||
;
|
|
||||||
$project->addRequest($request);
|
|
||||||
|
|
||||||
$project->setName("Projet 2");
|
|
||||||
$project->addUser($user);
|
|
||||||
$manager->persist($project);
|
|
||||||
|
|
||||||
//NEW PROJECT
|
|
||||||
$user = $manager
|
|
||||||
->getRepository(User::class)
|
|
||||||
->findOneByUsername('client1')
|
|
||||||
;
|
|
||||||
|
|
||||||
$project = new Project();
|
|
||||||
$project->setName("Projet 3");
|
|
||||||
$project->addUser($user);
|
|
||||||
$manager->persist($project);
|
|
||||||
|
|
||||||
//NEW PROJECT
|
|
||||||
$user = $manager
|
|
||||||
->getRepository(User::class)
|
->getRepository(User::class)
|
||||||
->findOneByUsername('client2')
|
->findOneByUsername('client2')
|
||||||
;
|
;
|
||||||
|
|
||||||
|
$project = new Project();
|
||||||
|
$project->setName("Projet 1");
|
||||||
|
$project->addUser($dev1);
|
||||||
|
$manager->persist($project);
|
||||||
|
|
||||||
|
//NEW PROJECT
|
||||||
|
$project = new Project();
|
||||||
|
$project->setName("Projet 2");
|
||||||
|
$project->addUser($client1);
|
||||||
|
$project->addUser($dev1);
|
||||||
|
$manager->persist($project);
|
||||||
|
|
||||||
|
//NEW PROJECT
|
||||||
|
|
||||||
|
$project = new Project();
|
||||||
|
$project->setName("Projet 3");
|
||||||
|
$project->addUser($client1);
|
||||||
|
$project->addUser($dev1);
|
||||||
|
$manager->persist($project);
|
||||||
|
|
||||||
|
//NEW PROJECT
|
||||||
|
|
||||||
$project = new Project();
|
$project = new Project();
|
||||||
$project->setName("Projet 4");
|
$project->setName("Projet 4");
|
||||||
$project->addUser($user);
|
$project->addUser($client2);
|
||||||
$manager->persist($project);
|
$manager->persist($project);
|
||||||
|
|
||||||
$manager->flush();
|
$manager->flush();
|
||||||
|
@ -95,7 +66,6 @@ class ProjectFixtures extends Fixture implements DependentFixtureInterface
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
UserFixtures::class,
|
UserFixtures::class,
|
||||||
RequestFixtures::class
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
namespace App\DataFixtures;
|
namespace App\DataFixtures;
|
||||||
|
|
||||||
|
use App\Entity\Project;
|
||||||
use App\Entity\Request;
|
use App\Entity\Request;
|
||||||
use App\Entity\RequestStatus;
|
use App\Entity\RequestStatus;
|
||||||
use App\Entity\User;
|
use App\Entity\User;
|
||||||
|
@ -15,94 +16,45 @@ class RequestFixtures extends Fixture implements DependentFixtureInterface
|
||||||
|
|
||||||
public function load(ObjectManager $manager)
|
public function load(ObjectManager $manager)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//NEW REQUEST
|
//NEW REQUEST
|
||||||
$user = $manager
|
$client1 = $manager
|
||||||
->getRepository(User::class)
|
->getRepository(User::class)
|
||||||
->findOneByUsername('client1')
|
->findOneByUsername('client1')
|
||||||
;
|
;
|
||||||
|
|
||||||
$status = $manager
|
$enAttenteStatus = $manager
|
||||||
->getRepository(RequestStatus::class)
|
->getRepository(RequestStatus::class)
|
||||||
->findOneBySlug('en-attente')
|
->findOneBySlug('en-attente')
|
||||||
;
|
;
|
||||||
|
|
||||||
$request = new Request();
|
$prisEnCompteStatus = $manager
|
||||||
$request->setTitle("Demande num 1");
|
|
||||||
$request->setAuthor($user);
|
|
||||||
$request->setCreatedAt(new DateTime());
|
|
||||||
$request->setStatus($status);
|
|
||||||
$manager->persist($request);
|
|
||||||
|
|
||||||
//NEW REQUEST
|
|
||||||
$user = $manager
|
|
||||||
->getRepository(User::class)
|
|
||||||
->findOneByUsername('client1')
|
|
||||||
;
|
|
||||||
|
|
||||||
$status = $manager
|
|
||||||
->getRepository(RequestStatus::class)
|
->getRepository(RequestStatus::class)
|
||||||
->findOneBySlug('pris-en-compte')
|
->findOneBySlug('pris-en-compte')
|
||||||
;
|
;
|
||||||
|
|
||||||
|
$project2 = $manager
|
||||||
|
->getRepository(Project::class)
|
||||||
|
->findOneByName('Projet 2')
|
||||||
|
;
|
||||||
|
|
||||||
|
$request = new Request();
|
||||||
|
$request->setTitle("Demande num 1");
|
||||||
|
$request->setAuthor($client1);
|
||||||
|
$request->setCreatedAt(new DateTime());
|
||||||
|
$request->setStatus($enAttenteStatus);
|
||||||
|
$request->setProject($project2);
|
||||||
|
$manager->persist($request);
|
||||||
|
|
||||||
|
|
||||||
$request = new Request();
|
$request = new Request();
|
||||||
$request->setTitle("Demande num 2");
|
$request->setTitle("Demande num 2");
|
||||||
$request->setAuthor($user);
|
$request->setAuthor($client1);
|
||||||
$request->setCreatedAt(new DateTime());
|
$request->setCreatedAt(new DateTime());
|
||||||
$request->setStatus($status);
|
$request->setStatus($prisEnCompteStatus);
|
||||||
$manager->persist($request);
|
$request->setProject($project2);
|
||||||
|
|
||||||
//NEW REQUEST
|
|
||||||
$user = $manager
|
|
||||||
->getRepository(User::class)
|
|
||||||
->findOneByUsername('client1')
|
|
||||||
;
|
|
||||||
|
|
||||||
$status = $manager
|
|
||||||
->getRepository(RequestStatus::class)
|
|
||||||
->findOneBySlug('en-cours-de-traitement')
|
|
||||||
;
|
|
||||||
|
|
||||||
$request = new Request();
|
|
||||||
$request->setTitle("Demande num 3");
|
|
||||||
$request->setAuthor($user);
|
|
||||||
$request->setCreatedAt(new DateTime());
|
|
||||||
$request->setStatus($status);
|
|
||||||
$manager->persist($request);
|
|
||||||
|
|
||||||
//NEW REQUEST
|
|
||||||
$user = $manager
|
|
||||||
->getRepository(User::class)
|
|
||||||
->findOneByUsername('client2')
|
|
||||||
;
|
|
||||||
|
|
||||||
$status = $manager
|
|
||||||
->getRepository(RequestStatus::class)
|
|
||||||
->findOneBySlug('traite')
|
|
||||||
;
|
|
||||||
|
|
||||||
$request = new Request();
|
|
||||||
$request->setTitle("Demande num 4");
|
|
||||||
$request->setAuthor($user);
|
|
||||||
$request->setCreatedAt(new DateTime());
|
|
||||||
$request->setStatus($status);
|
|
||||||
$manager->persist($request);
|
|
||||||
|
|
||||||
//NEW REQUEST
|
|
||||||
$user = $manager
|
|
||||||
->getRepository(User::class)
|
|
||||||
->findOneByUsername('client2')
|
|
||||||
;
|
|
||||||
|
|
||||||
$status = $manager
|
|
||||||
->getRepository(RequestStatus::class)
|
|
||||||
->findOneBySlug('clos')
|
|
||||||
;
|
|
||||||
|
|
||||||
$request = new Request();
|
|
||||||
$request->setTitle("Demande num 5");
|
|
||||||
$request->setAuthor($user);
|
|
||||||
$request->setCreatedAt(new DateTime());
|
|
||||||
$request->setStatus($status);
|
|
||||||
$manager->persist($request);
|
$manager->persist($request);
|
||||||
|
|
||||||
$manager->flush();
|
$manager->flush();
|
||||||
|
@ -114,6 +66,7 @@ class RequestFixtures extends Fixture implements DependentFixtureInterface
|
||||||
return [
|
return [
|
||||||
RequestStatusFixtures::class,
|
RequestStatusFixtures::class,
|
||||||
UserFixtures::class,
|
UserFixtures::class,
|
||||||
|
ProjectFixtures::class,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,35 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace DoctrineMigrations;
|
||||||
|
|
||||||
|
use Doctrine\DBAL\Schema\Schema;
|
||||||
|
use Doctrine\Migrations\AbstractMigration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Auto-generated Migration: Please modify to your needs!
|
||||||
|
*/
|
||||||
|
final class Version20200219122346 extends AbstractMigration
|
||||||
|
{
|
||||||
|
public function getDescription() : string
|
||||||
|
{
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function up(Schema $schema) : void
|
||||||
|
{
|
||||||
|
// this up() migration is auto-generated, please modify it to your needs
|
||||||
|
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');
|
||||||
|
|
||||||
|
$this->addSql('ALTER TABLE request_status ADD slug VARCHAR(64) NOT NULL');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(Schema $schema) : void
|
||||||
|
{
|
||||||
|
// this down() migration is auto-generated, please modify it to your needs
|
||||||
|
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');
|
||||||
|
|
||||||
|
$this->addSql('ALTER TABLE request_status DROP slug');
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue