mirror of
https://framagit.org/tykayn/date-poll-api
synced 2023-08-25 08:23:11 +02:00
⚡ more stack fixtures
This commit is contained in:
parent
b3bdeb0d4a
commit
158a795446
@ -54,7 +54,6 @@ class AppPollFixtures extends Fixture {
|
||||
->addChoice( $choiceB );
|
||||
$manager->persist( $poll );
|
||||
|
||||
|
||||
$stack1 = new StackOfVotes();
|
||||
$stack1
|
||||
->setPoll( $poll )
|
||||
@ -72,10 +71,7 @@ class AppPollFixtures extends Fixture {
|
||||
->setStacksOfVotes( $stack1 )
|
||||
->setValue( "yes" )
|
||||
->setChoice( $choiceB );
|
||||
|
||||
$stack1->setPseudo( 'chuck norris' );
|
||||
|
||||
|
||||
$manager->persist( $stack1 );
|
||||
|
||||
// voter guy votes again with an other pseudo
|
||||
|
76
src/DataFixtures/CommentFixtures.php
Normal file
76
src/DataFixtures/CommentFixtures.php
Normal file
@ -0,0 +1,76 @@
|
||||
<?php
|
||||
|
||||
namespace App\DataFixtures;
|
||||
|
||||
use App\Entity\Comment;
|
||||
use App\Entity\Owner;
|
||||
use App\Entity\Poll;
|
||||
use Doctrine\Bundle\FixturesBundle\Fixture;
|
||||
use Doctrine\Common\Persistence\ObjectManager;
|
||||
|
||||
class CommentFixtures extends Fixture {
|
||||
public function load( ObjectManager $manager ) {
|
||||
$emPoll = $manager->getRepository( Poll::class );
|
||||
|
||||
$commenterMan = new Owner();
|
||||
$commenterMan->setEmail( 'tktest_commentateur_other@tktest.com' )
|
||||
->setPseudo( 'Bill Murray' );
|
||||
$commenterMan2 = new Owner();
|
||||
$commenterMan2->setEmail( 'wulfila@tktest.com' )
|
||||
->setPseudo( 'Wulfila' );
|
||||
|
||||
// comment on "citron ou orange"
|
||||
$pollCitronOrange = $emPoll->find( 1 );
|
||||
$comment = new Comment();
|
||||
$comment->setOwner( $commenterMan )
|
||||
->setText( 'quelle indécision wololo! finalement citron. heu non orange. AAAAh!' );
|
||||
$pollCitronOrange->addComment( $comment );
|
||||
$manager->persist( $comment );
|
||||
$manager->persist( $pollCitronOrange );
|
||||
$manager->persist( $commenterMan );
|
||||
$manager->flush();
|
||||
|
||||
// comment on "démo sondage de texte avec deux commentaires"
|
||||
$poll = $emPoll->find( 2 );
|
||||
$comment = new Comment();
|
||||
$comment->setOwner( $commenterMan2 )
|
||||
->setText( 'il est écrit Squalala.' );
|
||||
$pollCitronOrange->addComment( $comment );
|
||||
$manager->persist( $comment );
|
||||
$manager->persist( $poll );
|
||||
$manager->persist( $commenterMan2 );
|
||||
$manager->flush();
|
||||
|
||||
$comment = new Comment();
|
||||
$comment->setOwner( $commenterMan )
|
||||
->setText( "Zelda. Orange." );
|
||||
$pollCitronOrange->addComment( $comment );
|
||||
$manager->persist( $comment );
|
||||
$manager->persist( $poll );
|
||||
$manager->persist( $commenterMan );
|
||||
$manager->flush();
|
||||
|
||||
|
||||
// comment on "c'est pour aujourdhui ou pour demain"
|
||||
$poll = $emPoll->find( 3 );
|
||||
$comment = new Comment();
|
||||
$comment->setOwner( $commenterMan )
|
||||
->setText( "va pour demain" );
|
||||
$pollCitronOrange->addComment( $comment );
|
||||
$manager->persist( $comment );
|
||||
$manager->persist( $poll );
|
||||
$manager->persist( $commenterMan );
|
||||
$manager->flush();
|
||||
|
||||
// comment on "dessin animé préféré"
|
||||
$poll = $emPoll->find( 4 );
|
||||
$comment = new Comment();
|
||||
$comment->setOwner( $commenterMan2 )
|
||||
->setText( "Ceci est un commentaire de fixture créé avec le CipherBliss poweur." );
|
||||
$pollCitronOrange->addComment( $comment );
|
||||
$manager->persist( $comment );
|
||||
$manager->persist( $poll );
|
||||
$manager->persist( $commenterMan2 );
|
||||
$manager->flush();
|
||||
}
|
||||
}
|
148
src/DataFixtures/VotesStacksFixtures.php
Normal file
148
src/DataFixtures/VotesStacksFixtures.php
Normal file
@ -0,0 +1,148 @@
|
||||
<?php
|
||||
|
||||
namespace App\DataFixtures;
|
||||
|
||||
use App\Entity\Owner;
|
||||
use App\Entity\Poll;
|
||||
use App\Entity\StackOfVotes;
|
||||
use App\Entity\Vote;
|
||||
use Doctrine\Bundle\FixturesBundle\Fixture;
|
||||
use Doctrine\Common\Persistence\ObjectManager;
|
||||
|
||||
class VotesStacksFixtures extends Fixture {
|
||||
public function load( ObjectManager $manager ) {
|
||||
$emPoll = $manager->getRepository( Poll::class );
|
||||
|
||||
$people1 = new Owner();
|
||||
$people1->setEmail( 'tktest_nikolas_edison@tktest.com' )
|
||||
->setPseudo( 'Nikolas Edison' );
|
||||
$people2 = new Owner();
|
||||
$people2->setEmail( 'wulfila@tktest.com' )
|
||||
->setPseudo( 'Wulfila' );
|
||||
$people3 = new Owner();
|
||||
$people3->setEmail( 'billie_jean@tktest.com' )
|
||||
->setPseudo( 'Billie Jean' );
|
||||
|
||||
// "citron ou orange"
|
||||
$poll = $emPoll->find( 1 );
|
||||
$stack1 = new StackOfVotes();
|
||||
$stack1
|
||||
->setPoll( $poll )
|
||||
->setOwner( $people1 );
|
||||
$voteA = new Vote();
|
||||
$voteA
|
||||
->setPoll( $poll )
|
||||
->setStacksOfVotes( $stack1 )
|
||||
->setValue( "yes" )
|
||||
->setChoice( $poll->getChoices()[ 0 ] );
|
||||
$voteB = new Vote();
|
||||
$voteB
|
||||
->setPoll( $poll )
|
||||
->setStacksOfVotes( $stack1 )
|
||||
->setValue( "maybe" )
|
||||
->setChoice( $poll->getChoices()[ 1 ] );
|
||||
$poll->addStackOfVote( $stack1 );
|
||||
$manager->persist( $poll );
|
||||
$manager->persist( $people1 );
|
||||
$manager->persist( $stack1 );
|
||||
|
||||
$stack2 = new StackOfVotes();
|
||||
$stack2
|
||||
->setPoll( $poll )
|
||||
->setOwner( $people2 );
|
||||
$voteA = new Vote();
|
||||
$voteA
|
||||
->setPoll( $poll )
|
||||
->setStacksOfVotes( $stack2 )
|
||||
->setValue( "no" )
|
||||
->setChoice( $poll->getChoices()[ 0 ] );
|
||||
$voteB = new Vote();
|
||||
$voteB
|
||||
->setPoll( $poll )
|
||||
->setStacksOfVotes( $stack2 )
|
||||
->setValue( "yes" )
|
||||
->setChoice( $poll->getChoices()[ 1 ] );
|
||||
$poll->addStackOfVote( $stack2 );
|
||||
$manager->persist( $poll );
|
||||
$manager->persist( $stack2 );
|
||||
$manager->persist( $people2 );
|
||||
|
||||
// comment on "démo sondage de texte avec deux commentaires"
|
||||
$poll = $emPoll->find( 2 );
|
||||
|
||||
|
||||
// comment on "c'est pour aujourdhui ou pour demain"
|
||||
$poll = $emPoll->find( 3 );
|
||||
|
||||
|
||||
// comment on "dessin animé préféré"
|
||||
$poll = $emPoll->find( 4 );
|
||||
|
||||
$stack1 = new StackOfVotes();
|
||||
$stack1
|
||||
->setPoll( $poll )
|
||||
->setOwner( $people1 );
|
||||
$voteA = new Vote();
|
||||
$voteA
|
||||
->setPoll( $poll )
|
||||
->setStacksOfVotes( $stack1 )
|
||||
->setValue( "maybe" )
|
||||
->setChoice( $poll->getChoices()[ 2 ] );
|
||||
$voteB = new Vote();
|
||||
$voteB
|
||||
->setPoll( $poll )
|
||||
->setStacksOfVotes( $stack1 )
|
||||
->setValue( "maybe" )
|
||||
->setChoice( $poll->getChoices()[ 4 ] );
|
||||
$poll->addStackOfVote( $stack1 );
|
||||
$manager->persist( $poll );
|
||||
$manager->persist( $people1 );
|
||||
$manager->persist( $stack1 );
|
||||
|
||||
|
||||
$stack2 = new StackOfVotes();
|
||||
$stack2
|
||||
->setPoll( $poll )
|
||||
->setOwner( $people2 );
|
||||
$voteA = new Vote();
|
||||
$voteA
|
||||
->setPoll( $poll )
|
||||
->setStacksOfVotes( $stack2 )
|
||||
->setValue( "maybe" )
|
||||
->setChoice( $poll->getChoices()[ 3 ] );
|
||||
$voteB = new Vote();
|
||||
$voteB
|
||||
->setPoll( $poll )
|
||||
->setStacksOfVotes( $stack2 )
|
||||
->setValue( "yes" )
|
||||
->setChoice( $poll->getChoices()[ 5 ] );
|
||||
$poll->addStackOfVote( $stack2 );
|
||||
$manager->persist( $poll );
|
||||
$manager->persist( $people2 );
|
||||
$manager->persist( $stack2 );
|
||||
|
||||
|
||||
$stack3 = new StackOfVotes();
|
||||
$stack3
|
||||
->setPoll( $poll )
|
||||
->setOwner( $people3 );
|
||||
$voteA = new Vote();
|
||||
$voteA
|
||||
->setPoll( $poll )
|
||||
->setStacksOfVotes( $stack3 )
|
||||
->setValue( "yes" )
|
||||
->setChoice( $poll->getChoices()[ 1 ] );
|
||||
$voteB = new Vote();
|
||||
$voteB
|
||||
->setPoll( $poll )
|
||||
->setStacksOfVotes( $stack3 )
|
||||
->setValue( "yes" )
|
||||
->setChoice( $poll->getChoices()[ 3 ] );
|
||||
$poll->addStackOfVote( $stack3 );
|
||||
$manager->persist( $poll );
|
||||
$manager->persist( $people3 );
|
||||
$manager->persist( $stack3 );
|
||||
|
||||
$manager->flush();
|
||||
}
|
||||
}
|
@ -1,17 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity;
|
||||
namespace App\Entity;
|
||||
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use JMS\Serializer\Annotation as Serializer;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use JMS\Serializer\Annotation as Serializer;
|
||||
|
||||
/**
|
||||
/**
|
||||
* contains the votes for one answer to a poll
|
||||
* @ORM\Entity(repositoryClass="App\Repository\StackOfVotesRepository")
|
||||
* @ORM\HasLifecycleCallbacks()
|
||||
*/
|
||||
class StackOfVotes {
|
||||
class StackOfVotes {
|
||||
/**
|
||||
* @ORM\Id()
|
||||
* @ORM\GeneratedValue()
|
||||
@ -71,6 +72,13 @@
|
||||
return $tab;
|
||||
}
|
||||
|
||||
/**
|
||||
* @ORM\PrePersist
|
||||
*/
|
||||
public function prePersist() {
|
||||
$this->setPseudo( $this->getOwner()->getPseudo() );
|
||||
}
|
||||
|
||||
public function __construct() {
|
||||
$this->votes = new ArrayCollection();
|
||||
}
|
||||
@ -138,4 +146,4 @@
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user