add dependency on fixtures

This commit is contained in:
Tykayn 2021-04-21 11:30:22 +02:00 committed by tykayn
parent 108cc473e4
commit 1570a1cf0f
5 changed files with 1486 additions and 47 deletions

View File

@ -0,0 +1,80 @@
<?xml version="1.0" encoding="UTF-8"?>
<Diagram>
<ID>DATABASE</ID>
<OriginalElement>2c3996c6-29d5-4c17-9504-1606d308e53c.SCHEMA:framadate_api</OriginalElement>
<nodes>
<node x="0.0" y="1296.0">2c3996c6-29d5-4c17-9504-1606d308e53c.TABLE:framadate_api.stack_of_votes</node>
<node x="307.25" y="0.0">2c3996c6-29d5-4c17-9504-1606d308e53c.TABLE:framadate_api.owner</node>
<node x="615.25" y="1256.0">2c3996c6-29d5-4c17-9504-1606d308e53c.TABLE:framadate_api.comment</node>
<node x="251.140625" y="347.0">2c3996c6-29d5-4c17-9504-1606d308e53c.TABLE:framadate_api.poll</node>
<node x="250.90625" y="1605.0">2c3996c6-29d5-4c17-9504-1606d308e53c.TABLE:framadate_api.vote</node>
<node x="297.0" y="1276.0">2c3996c6-29d5-4c17-9504-1606d308e53c.TABLE:framadate_api.choice</node>
</nodes>
<notes />
<edges>
<edge source="2c3996c6-29d5-4c17-9504-1606d308e53c.TABLE:framadate_api.comment" target="2c3996c6-29d5-4c17-9504-1606d308e53c.TABLE:framadate_api.owner" relationship="REFERENCES">
<point x="70.5" y="-148.5" />
<point x="826.75" y="322.0" />
<point x="507.75" y="322.0" />
<point x="0.0" y="148.5" />
</edge>
<edge source="2c3996c6-29d5-4c17-9504-1606d308e53c.TABLE:framadate_api.comment" target="2c3996c6-29d5-4c17-9504-1606d308e53c.TABLE:framadate_api.poll" relationship="REFERENCES">
<point x="-70.5" y="-148.5" />
<point x="685.75" y="1230.0" />
<point x="509.140625" y="1230.0" />
<point x="0.0" y="428.5" />
</edge>
<edge source="2c3996c6-29d5-4c17-9504-1606d308e53c.TABLE:framadate_api.vote" target="2c3996c6-29d5-4c17-9504-1606d308e53c.TABLE:framadate_api.choice" relationship="REFERENCES">
<point x="0.0" y="-148.5" />
<point x="409.40625" y="1579.0" />
<point x="434.0" y="1579.0" />
<point x="0.0" y="128.5" />
</edge>
<edge source="2c3996c6-29d5-4c17-9504-1606d308e53c.TABLE:framadate_api.stack_of_votes" target="2c3996c6-29d5-4c17-9504-1606d308e53c.TABLE:framadate_api.owner" relationship="REFERENCES">
<point x="-69.25" y="-108.5" />
<point x="69.25" y="322.0" />
<point x="507.75" y="322.0" />
<point x="0.0" y="148.5" />
</edge>
<edge source="2c3996c6-29d5-4c17-9504-1606d308e53c.TABLE:framadate_api.stack_of_votes" target="2c3996c6-29d5-4c17-9504-1606d308e53c.TABLE:framadate_api.poll" relationship="REFERENCES">
<point x="69.25" y="-108.5" />
<point x="207.75" y="1230.0" />
<point x="509.140625" y="1230.0" />
<point x="0.0" y="428.5" />
</edge>
<edge source="2c3996c6-29d5-4c17-9504-1606d308e53c.TABLE:framadate_api.vote" target="2c3996c6-29d5-4c17-9504-1606d308e53c.TABLE:framadate_api.stack_of_votes" relationship="REFERENCES">
<point x="-105.66666666666669" y="-148.5" />
<point x="303.7395833333333" y="1579.0" />
<point x="138.5" y="1579.0" />
<point x="0.0" y="108.5" />
</edge>
<edge source="2c3996c6-29d5-4c17-9504-1606d308e53c.TABLE:framadate_api.poll" target="2c3996c6-29d5-4c17-9504-1606d308e53c.TABLE:framadate_api.owner" relationship="REFERENCES">
<point x="0.0" y="-428.5" />
<point x="509.140625" y="322.0" />
<point x="507.75" y="322.0" />
<point x="0.0" y="148.5" />
</edge>
<edge source="2c3996c6-29d5-4c17-9504-1606d308e53c.TABLE:framadate_api.vote" target="2c3996c6-29d5-4c17-9504-1606d308e53c.TABLE:framadate_api.poll" relationship="REFERENCES">
<point x="105.66666666666663" y="-148.5" />
<point x="515.0729166666666" y="1579.0" />
<point x="581.5" y="1579.0" />
<point x="581.5" y="1230.0" />
<point x="509.140625" y="1230.0" />
<point x="0.0" y="428.5" />
</edge>
<edge source="2c3996c6-29d5-4c17-9504-1606d308e53c.TABLE:framadate_api.choice" target="2c3996c6-29d5-4c17-9504-1606d308e53c.TABLE:framadate_api.poll" relationship="REFERENCES">
<point x="0.0" y="-128.5" />
<point x="434.0" y="1230.0" />
<point x="509.140625" y="1230.0" />
<point x="0.0" y="428.5" />
</edge>
</edges>
<settings layout="Hierarchic" zoom="0.3090530697190427" showDependencies="false" x="449.0" y="951.0" />
<SelectedNodes />
<Categories>
<Category>Columns</Category>
<Category>Key columns</Category>
<Category>Virtual foreign keys</Category>
</Categories>
</Diagram>

BIN
doc/framadate_api.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 192 KiB

1346
doc/framadate_api.svg Normal file

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 147 KiB

View File

@ -13,6 +13,8 @@ use Doctrine\Bundle\FixturesBundle\Fixture;
use Doctrine\Persistence\ObjectManager;
class AppPollFixtures extends Fixture {
public const POLL_FIXTURE_ONE = 'citron-poll-fixture';
public function load( ObjectManager $manager ) {
/**
@ -35,41 +37,44 @@ class AppPollFixtures extends Fixture {
$manager->flush();
$poll = new Poll();
$poll->setTitle( 'citron ou orange' )
$pollCitronOrange = new Poll();
$pollCitronOrange->setTitle( 'citron ou orange' )
->setCustomUrl('citron')
->setDescription( 'votre sorbert préféré' )
->setAdminKey( uniqid() )
->setModificationPolicy( 'nobody' )
->setPassword('le pass woute woute');
$poll->setMailOnVote( true );
$poll->setOwner( $owner );
$owner->addPoll( $poll );
$this->addReference(self::POLL_FIXTURE_ONE, $pollCitronOrange);
$pollCitronOrange->setMailOnVote( true );
$pollCitronOrange->setOwner( $owner );
$owner->addPoll( $pollCitronOrange );
$choiceA = new Choice();
$choiceA->setName( 'citron' );
$choiceB = new Choice();
$choiceB->setName( 'orange' );
$poll
$pollCitronOrange
->addChoice( $choiceA )
->addChoice( $choiceB );
$manager->persist( $poll );
$manager->persist( $pollCitronOrange );
$stack1 = new StackOfVotes();
$stack1
->setPoll( $poll )
->setPoll( $pollCitronOrange )
->setOwner( $voter );
$voteA = new Vote();
$voteA
->setPoll( $poll )
->setPoll( $pollCitronOrange )
->setStacksOfVotes( $stack1 )
->setValue( "yes" )
->setChoice( $choiceA );
$voteB = new Vote();
$voteB
->setPoll( $poll )
->setPoll( $pollCitronOrange )
->setStacksOfVotes( $stack1 )
->setValue( "yes" )
->setChoice( $choiceB );
@ -81,12 +86,12 @@ class AppPollFixtures extends Fixture {
$stack2 = new StackOfVotes();
$stack2->setPseudo( 'Jean indécis' );
$stack2
->setPoll( $poll )
->setPoll( $pollCitronOrange )
->setOwner( $voter );
$voteA = new Vote();
$voteA
->setPoll( $poll )
->setPoll( $pollCitronOrange )
->setStacksOfVotes( $stack2 )
->setValue( "maybe" )
->setChoice( $choiceA );
@ -94,37 +99,37 @@ class AppPollFixtures extends Fixture {
$manager->persist( $stack2 );
$poll = new Poll();
$pollCitronOrange = new Poll();
$ownerComment = new Comment();
$ownerComment
->setText( "trop bien ce sondage wohooo! signé l'auteur." )
->setPseudo('un gens qui commente')
->setOwner( $owner );
$poll->addComment( $ownerComment );
$pollCitronOrange->addComment( $ownerComment );
$someoneComment = new Comment();
$someoneComment
->setText( "comme l'auteur se la raconte. PFFFF!" )
->setPseudo('un gens qui commente')
->setOwner( $commenterMan );
$poll->addComment( $someoneComment );
$pollCitronOrange->addComment( $someoneComment );
$poll->setTitle( 'démo sondage de texte avec deux commentaires' )
$pollCitronOrange->setTitle( 'démo sondage de texte avec deux commentaires' )
->setCustomUrl('demo')
->setDescription( 'description du sondage 2' );
$poll->setAdminKey( uniqid() );
$poll->setModificationPolicy( 'self' );
$poll->setMailOnComment( true );
$pollCitronOrange->setAdminKey( uniqid() );
$pollCitronOrange->setModificationPolicy( 'self' );
$pollCitronOrange->setMailOnComment( true );
$poll->addTextChoiceArray( [ 'un truc', 'deux trucs' ] );
$poll->setOwner( $owner );
$owner->addPoll( $poll );
$pollCitronOrange->addTextChoiceArray( [ 'un truc', 'deux trucs' ] );
$pollCitronOrange->setOwner( $owner );
$owner->addPoll( $pollCitronOrange );
$manager->persist( $poll );
$manager->persist( $pollCitronOrange );
$manager->persist( $someoneComment );
$manager->persist( $ownerComment );
@ -132,16 +137,16 @@ class AppPollFixtures extends Fixture {
// voting test with 2 people
// poll with date type
$poll = new Poll();
$pollCitronOrange = new Poll();
$choice = new Choice();
$firstDate = new DateTime();
$choice->setName( $firstDate->format( 'Y-m-d H:i:s' ) );
$choice2 = new Choice();
$choice3 = new Choice();
$choice2->setName( $poll->addDaysToDate( $firstDate, 1 )->format( 'Y-m-d H:i:s' ) );
$choice3->setName( $poll->addDaysToDate( $firstDate, 2 )->format( 'Y-m-d H:i:s' ) );
$choice2->setName( $pollCitronOrange->addDaysToDate( $firstDate, 1 )->format( 'Y-m-d H:i:s' ) );
$choice3->setName( $pollCitronOrange->addDaysToDate( $firstDate, 2 )->format( 'Y-m-d H:i:s' ) );
$poll->setTitle( "c'est pour aujourdhui ou pour demain" )
$pollCitronOrange->setTitle( "c'est pour aujourdhui ou pour demain" )
->setCustomUrl('aujourdhui-ou-demain')
->setDescription( 'Vous avez le choix dans la date' )
->setKind( 'date' )
@ -150,11 +155,11 @@ class AppPollFixtures extends Fixture {
->addChoice( $choice2 )
->addChoice( $choice3 )
->setModificationPolicy( 'self' );
$manager->persist( $poll );
$manager->persist( $pollCitronOrange );
// poll with cartoon choices
$poll = new Poll();
$poll->setTitle( 'dessin animé préféré' )
$pollCitronOrange = new Poll();
$pollCitronOrange->setTitle( 'dessin animé préféré' )
->setCustomUrl('dessin-anime')
->setDescription( 'choisissez votre animé préféré' )
->setOwner( $owner )
@ -174,60 +179,60 @@ class AppPollFixtures extends Fixture {
->setPseudo('un gens qui commente')
->setText( "allez boumbo!" )
->setOwner( $commenterMan );
$poll->addComment( $someoneComment );
$pollCitronOrange->addComment( $someoneComment );
$someoneComment2 = new Comment();
$someoneComment2
->setPseudo('un gens qui commente')
->setText( "je suis pour la team rocket de digimon" )
->setOwner( $owner );
$poll->addComment( $someoneComment2 );
$pollCitronOrange->addComment( $someoneComment2 );
$manager->persist( $poll );
$manager->persist( $pollCitronOrange );
$stack = new StackOfVotes();
$stack->setPseudo( 'Wulfila' );
$stack
->setPoll( $poll )
->setPoll( $pollCitronOrange )
->setOwner( $voter );
$vote = new Vote();
$vote
->setPoll( $poll )
->setPoll( $pollCitronOrange )
->setStacksOfVotes( $stack )
->setValue( "yes" )
->setChoice( $poll->getChoices()[ 2 ] );
->setChoice( $pollCitronOrange->getChoices()[ 2 ] );
$vote = new Vote();
$vote
->setPoll( $poll )
->setPoll( $pollCitronOrange )
->setStacksOfVotes( $stack )
->setValue( "maybe" )
->setChoice( $poll->getChoices()[ 1 ] );
->setChoice( $pollCitronOrange->getChoices()[ 1 ] );
$manager->persist( $stack );
$stack = new StackOfVotes();
$stack->setPseudo( 'Tykayn' );
$stack
->setPoll( $poll )
->setPoll( $pollCitronOrange )
->setOwner( $voter );
$vote = new Vote();
$vote
->setPoll( $poll )
->setPoll( $pollCitronOrange )
->setStacksOfVotes( $stack )
->setValue( "yes" )
->setChoice( $poll->getChoices()[ 1 ] );
->setChoice( $pollCitronOrange->getChoices()[ 1 ] );
$vote = new Vote();
$vote
->setPoll( $poll )
->setPoll( $pollCitronOrange )
->setStacksOfVotes( $stack )
->setValue( "yes" )
->setChoice( $poll->getChoices()[ 2 ] );
->setChoice( $pollCitronOrange->getChoices()[ 2 ] );
$vote = new Vote();
$vote
->setPoll( $poll )
->setPoll( $pollCitronOrange )
->setStacksOfVotes( $stack )
->setValue( "no" )
->setChoice( $poll->getChoices()[ 2 ] );
->setChoice( $pollCitronOrange->getChoices()[ 2 ] );
$manager->persist( $stack );

View File

@ -6,9 +6,17 @@ use App\Entity\Comment;
use App\Entity\Owner;
use App\Entity\Poll;
use Doctrine\Bundle\FixturesBundle\Fixture;
use Doctrine\Common\DataFixtures\DependentFixtureInterface;
use Doctrine\Persistence\ObjectManager;
class CommentFixtures extends Fixture {
class CommentFixtures extends Fixture implements DependentFixtureInterface {
public function getDependencies()
{
return [
AppPollFixtures::class,
];
}
public function load( ObjectManager $manager ) {
$emPoll = $manager->getRepository( Poll::class );
@ -20,7 +28,7 @@ class CommentFixtures extends Fixture {
->setPseudo( 'Wulfila' );
// comment on "citron ou orange"
$pollCitronOrange = $emPoll->findOneByCustomUrl( 'citron' );
$pollCitronOrange = $this->getReference(AppPollFixtures::POLL_FIXTURE_ONE);
if ( $pollCitronOrange ) {
$comment = new Comment();