1
0
mirror of https://framagit.org/tykayn/date-poll-api synced 2023-08-25 08:23:11 +02:00
date-poll-api/src/DataFixtures/AppPollFixtures.php

106 lines
3.0 KiB
PHP
Raw Normal View History

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-05 17:22:30 +01:00
use App\Entity\Owner;
2019-11-05 16:31:27 +01:00
use App\Entity\Poll;
2019-11-12 12:00:06 +01:00
use App\Entity\StackOfVotes;
2019-11-11 10:44:19 +01:00
use App\Entity\Vote;
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-12 11:55:11 +01:00
->setPseudo( 'tk_TEST' )
->setModifierToken( uniqid() );
$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
// $product = new Product();
$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' );
$poll->setCreationDate( new \DateTime() );
$poll->setExpiracyDate( new \DateTime() );
$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' )
->setCreationDate( new DateTime() )
->setChoice( $choiceA );
$voteA = new Vote();
$voteA->setPseudo( 'Néo' )
->setCreationDate( new DateTime() )
->setChoice( $choiceB );
2019-11-05 17:22:30 +01:00
$manager->persist( $poll );
$poll = new Poll();
$poll->setTitle( 'démo sondage de texte 2' );
$poll->setDescription( 'description du sondage 2' );
$poll->setKind( 'date' );
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 );
$poll->setCreationDate( new \DateTime() );
$poll->setExpiracyDate( new \DateTime() );
$poll->setOwner( $owner );
$owner->addPoll( $poll );
$manager->persist( $poll );
2019-11-12 12:00:06 +01:00
// voting test with 2 people
$stack1 = new StackOfVotes();
$stack1->setOwner( $voter )
->addVote( $poll->getChoices()[ 0 ] );
$stack2 = new StackOfVotes();
$stack1->setOwner( $owner )->addVote( $poll->getChoices()[ 1 ] );
$voter->addStackOfVote( $stack1 );
$owner->addStackOfVote( $stack2 );
2019-11-05 17:22:30 +01:00
$poll = new Poll();
$poll->setTitle( 'accès restreint sondage de texte' );
$poll->setKind( 'text' );
$poll->setPassword( md5( 'mot_de_passe_super' ) );
$poll->setModificationPolicy( 'everybody' );
2019-11-12 12:00:06 +01:00
$poll->setDescription( 'description du sondage a accès restreint. le mot de passe est mot_de_passe_super' );
2019-11-12 11:55:11 +01:00
$poll->setAdminKey( uniqid() );
2019-11-05 17:23:21 +01:00
$poll->setCustomUrl( 'boudoum_podom_podom' );
2019-11-05 16:31:27 +01:00
$poll->setCreationDate( new \DateTime() );
2019-11-05 17:22:30 +01:00
$poll->setExpiracyDate( new \DateTime() );
$poll->setMailOnComment( true );
$poll->setMailOnVote( true );
$poll->setOwner( $owner );
$owner->addPoll( $poll );
2019-11-05 16:31:27 +01:00
$manager->persist( $poll );
2019-11-05 17:22:30 +01:00
$manager->persist( $owner );
2019-11-12 11:55:11 +01:00
$manager->persist( $voter );
2019-11-05 16:31:27 +01:00
$manager->flush();
}
}