2019-11-05 16:31:27 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\DataFixtures;
|
|
|
|
|
2019-11-11 10:44:19 +01:00
|
|
|
use App\Entity\Choice;
|
2019-11-27 16:14:49 +01:00
|
|
|
use App\Entity\Comment;
|
2019-11-05 17:22:30 +01:00
|
|
|
use App\Entity\Owner;
|
2019-11-05 16:31:27 +01:00
|
|
|
use App\Entity\Poll;
|
2019-11-11 10:44:19 +01:00
|
|
|
use App\Entity\Vote;
|
2019-11-27 10:57:06 +01:00
|
|
|
use DateTime;
|
2019-11-05 16:31:27 +01:00
|
|
|
use Doctrine\Bundle\FixturesBundle\Fixture;
|
|
|
|
use Doctrine\Common\Persistence\ObjectManager;
|
|
|
|
|
|
|
|
class AppPollFixtures extends Fixture {
|
|
|
|
public function load( ObjectManager $manager ) {
|
2019-11-05 17:22:30 +01:00
|
|
|
|
|
|
|
$owner = new Owner();
|
|
|
|
$owner->setEmail( 'tktest@tktest.com' )
|
2019-11-27 16:14:49 +01:00
|
|
|
->setPseudo( 'tk_TEST' );
|
|
|
|
$commenterMan = new Owner();
|
|
|
|
$commenterMan->setEmail( 'tktest_commentateur@tktest.com' )
|
|
|
|
->setPseudo( 'tk_TEST_commentateur' );
|
|
|
|
|
2019-11-12 11:55:11 +01:00
|
|
|
$voter = new Owner();
|
|
|
|
$voter->setEmail( 'testing_vote_people@tktest.com' )
|
|
|
|
->setPseudo( 'voting_people_TEST' )
|
|
|
|
->setModifierToken( uniqid() );
|
2019-11-05 17:22:30 +01:00
|
|
|
|
2019-11-05 16:31:27 +01:00
|
|
|
$poll = new Poll();
|
2019-11-11 10:44:19 +01:00
|
|
|
$poll->setTitle( 'citron ou orange' );
|
2019-11-05 17:22:30 +01:00
|
|
|
$poll->setKind( 'text' );
|
2019-11-11 10:44:19 +01:00
|
|
|
$poll->setDescription( 'votre sorbert préféré' );
|
2019-11-12 11:55:11 +01:00
|
|
|
$poll->setAdminKey( uniqid() );
|
2019-11-05 17:22:30 +01:00
|
|
|
$poll->setModificationPolicy( 'nobody' );
|
2019-11-27 10:57:06 +01:00
|
|
|
|
|
|
|
$poll->setExpiracyDate( new DateTime() );
|
2019-11-05 17:22:30 +01:00
|
|
|
$poll->setMailOnVote( true );
|
|
|
|
$poll->setOwner( $owner );
|
|
|
|
$owner->addPoll( $poll );
|
|
|
|
|
2019-11-11 10:44:19 +01:00
|
|
|
$choiceA = new Choice();
|
|
|
|
$choiceA->setName( 'citron' );
|
|
|
|
$choiceB = new Choice();
|
|
|
|
$choiceA->setName( 'orange' );
|
|
|
|
|
|
|
|
$poll
|
|
|
|
->addChoice( $choiceA )
|
|
|
|
->addChoice( $choiceB );
|
|
|
|
|
|
|
|
$voteA = new Vote();
|
|
|
|
$voteA->setPseudo( 'chuck norris' )
|
|
|
|
->setChoice( $choiceA );
|
|
|
|
$voteA = new Vote();
|
|
|
|
$voteA->setPseudo( 'Néo' )
|
|
|
|
->setChoice( $choiceB );
|
|
|
|
|
2019-11-05 17:22:30 +01:00
|
|
|
$manager->persist( $poll );
|
|
|
|
|
|
|
|
|
|
|
|
$poll = new Poll();
|
2019-11-27 16:14:49 +01:00
|
|
|
|
|
|
|
$ownerComment = new Comment();
|
|
|
|
$ownerComment
|
|
|
|
->setText( "trop bien ce sondage wohooo! signé l'auteur." )
|
|
|
|
->setOwner( $owner );
|
|
|
|
$poll->addComment( $ownerComment );
|
|
|
|
|
|
|
|
$someoneComment = new Comment();
|
|
|
|
$someoneComment
|
|
|
|
->setText( "comme l'auteur se la raconte. PFFFF!" )
|
|
|
|
->setOwner( $commenterMan );
|
|
|
|
$poll->addComment( $someoneComment );
|
|
|
|
|
|
|
|
|
|
|
|
$poll->setTitle( 'démo sondage de texte avec deux commentaires' );
|
2019-11-05 17:22:30 +01:00
|
|
|
$poll->setDescription( 'description du sondage 2' );
|
2019-11-27 16:14:49 +01:00
|
|
|
$poll->setKind( 'text' );
|
2019-11-12 11:55:11 +01:00
|
|
|
$poll->setAdminKey( uniqid() );
|
2019-11-05 17:22:30 +01:00
|
|
|
$poll->setModificationPolicy( 'self' );
|
|
|
|
$poll->setMailOnComment( true );
|
2019-11-27 10:57:06 +01:00
|
|
|
$poll->setExpiracyDate( new DateTime() );
|
2019-11-27 11:26:21 +01:00
|
|
|
|
|
|
|
|
|
|
|
$poll->addTextChoiceArray( [ 'un truc', 'deux trucs' ] );
|
2019-11-05 17:22:30 +01:00
|
|
|
$poll->setOwner( $owner );
|
|
|
|
$owner->addPoll( $poll );
|
|
|
|
|
|
|
|
$manager->persist( $poll );
|
2019-11-27 16:14:49 +01:00
|
|
|
$manager->persist( $someoneComment );
|
|
|
|
$manager->persist( $ownerComment );
|
2019-11-05 17:22:30 +01:00
|
|
|
|
2019-11-27 10:57:06 +01:00
|
|
|
|
2019-11-12 12:00:06 +01:00
|
|
|
// voting test with 2 people
|
2019-11-27 16:14:49 +01:00
|
|
|
// $stack1 = new StackOfVotes();
|
|
|
|
// $vote0 = new Vote();
|
|
|
|
// $vote0->setChoice( $poll->getChoices()[ 0 ] );
|
|
|
|
// $stack1->setOwner( $voter )
|
|
|
|
// ->addVote( $vote0 );
|
|
|
|
//
|
|
|
|
// $stack2 = new StackOfVotes();
|
|
|
|
// $vote1 = new Vote();
|
|
|
|
// $vote1
|
|
|
|
// ->setChoice( $poll->getChoices()[ 1 ] );
|
|
|
|
// $stack1
|
|
|
|
// ->setOwner( $owner )
|
|
|
|
// ->addVote( $vote1 );
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// $voter->addStackOfVote( $stack1 );
|
|
|
|
// $owner->addStackOfVote( $stack2 );
|
|
|
|
//
|
|
|
|
// $poll = new Poll();
|
|
|
|
// $poll->setTitle( 'accès restreint sondage de texte' );
|
|
|
|
// $poll->setKind( 'text' );
|
|
|
|
// $poll->setPassword( md5( 'mot_de_passe_super' ) );
|
|
|
|
// $poll->setModificationPolicy( 'everybody' );
|
|
|
|
// $poll->setDescription( 'description du sondage a accès restreint. le mot de passe est mot_de_passe_super' );
|
|
|
|
// $poll->setAdminKey( uniqid() );
|
|
|
|
// $poll->setCustomUrl( 'boudoum_podom_podom' );
|
|
|
|
//
|
|
|
|
// $poll->setExpiracyDate( new DateTime() );
|
|
|
|
// $poll->setMailOnComment( true );
|
|
|
|
// $poll->setMailOnVote( true );
|
|
|
|
// $poll->setOwner( $owner );
|
|
|
|
// $owner->addPoll( $poll );
|
|
|
|
//
|
|
|
|
// $manager->persist( $vote1 );
|
|
|
|
// $manager->persist( $vote0 );
|
|
|
|
// $manager->persist( $stack1 );
|
|
|
|
// $manager->persist( $stack2 );
|
|
|
|
// $manager->persist( $poll );
|
|
|
|
// $manager->persist( $owner );
|
|
|
|
// $manager->persist( $voter );
|
|
|
|
|
|
|
|
|
|
|
|
// poll with date type
|
|
|
|
$poll = new Poll();
|
|
|
|
$choice = new Choice();
|
|
|
|
$firstDate = new DateTime();
|
|
|
|
$choice->setName( $firstDate );
|
|
|
|
$choice2 = new Choice();
|
|
|
|
$choice3 = new Choice();
|
|
|
|
$choice2->setName( $poll->addDaysToDate( $firstDate, 1 ) );
|
|
|
|
$choice3->setName( $poll->addDaysToDate( $firstDate, 2 ) );
|
|
|
|
|
|
|
|
$poll->setTitle( "c'est pour aujourdhui ou pour demain" )
|
|
|
|
->setDescription( 'Vous avez le choix dans la date' )
|
|
|
|
->setExpiracyDate( new DateTime() )
|
|
|
|
->setKind( 'date' )
|
|
|
|
->setOwner( $owner )
|
|
|
|
->addChoice( $choice )
|
|
|
|
->addChoice( $choice2 )
|
|
|
|
->setModificationPolicy( 'self' );
|
2019-11-27 10:57:06 +01:00
|
|
|
|
|
|
|
// poll with cartoon choices
|
|
|
|
$poll = new Poll();
|
|
|
|
$poll->setTitle( 'dessin animé préféré' )
|
|
|
|
->setDescription( 'choisissez votre animé préféré' )
|
2019-11-27 16:14:49 +01:00
|
|
|
->setExpiracyDate( new DateTime() )
|
|
|
|
->setKind( 'text' )
|
|
|
|
->setOwner( $owner )
|
|
|
|
->setModificationPolicy( 'self' )
|
2019-11-27 10:57:06 +01:00
|
|
|
->addTextChoiceArray( [
|
|
|
|
"Vic le viking",
|
|
|
|
"Boumbo petite automobile",
|
|
|
|
"Les mystérieuses cités d'or",
|
|
|
|
"Les mondes engloutis",
|
|
|
|
"Foot 2 rue",
|
|
|
|
"Le chat, la vache, et l'océan",
|
|
|
|
"Digimon",
|
2019-11-27 16:14:49 +01:00
|
|
|
] );
|
2019-11-27 10:57:06 +01:00
|
|
|
|
|
|
|
$manager->persist( $poll );
|
|
|
|
|
2019-11-27 16:14:49 +01:00
|
|
|
$manager->persist( $commenterMan );
|
|
|
|
|
2019-11-05 16:31:27 +01:00
|
|
|
$manager->flush();
|
|
|
|
}
|
|
|
|
}
|