From b6ca33082633fbc53b0d8e1bd59b0c9ff7e08881 Mon Sep 17 00:00:00 2001 From: Tykayn Date: Wed, 21 Apr 2021 11:22:01 +0200 Subject: [PATCH] advance on fixtures --- composer.json | 1 + composer.lock | 160 ++++++++++++++++++++++- config/bundles.php | 1 + src/Controller/api/PollController.php | 3 +- src/DataFixtures/AppFixtures.php | 3 +- src/DataFixtures/AppPollFixtures.php | 6 +- src/DataFixtures/CommentFixtures.php | 9 +- src/DataFixtures/VotesStacksFixtures.php | 2 +- symfony.lock | 15 +++ 9 files changed, 192 insertions(+), 8 deletions(-) diff --git a/composer.json b/composer.json index 934ee5a..2e8d27f 100644 --- a/composer.json +++ b/composer.json @@ -70,6 +70,7 @@ } }, "require-dev": { + "doctrine/doctrine-fixtures-bundle": "^3.4", "symfony/maker-bundle": "^1.30" } } diff --git a/composer.lock b/composer.lock index af06021..50c82ad 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "8c0122c4e542f317501dd66ea0f62a40", + "content-hash": "6ae23da7ab3d4ef4c0b8661a284d73c4", "packages": [ { "name": "composer/package-versions-deprecated", @@ -6374,6 +6374,164 @@ } ], "packages-dev": [ + { + "name": "doctrine/data-fixtures", + "version": "1.5.0", + "source": { + "type": "git", + "url": "https://github.com/doctrine/data-fixtures.git", + "reference": "51d3d4880d28951fff42a635a2389f8c63baddc5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/data-fixtures/zipball/51d3d4880d28951fff42a635a2389f8c63baddc5", + "reference": "51d3d4880d28951fff42a635a2389f8c63baddc5", + "shasum": "" + }, + "require": { + "doctrine/common": "^2.13|^3.0", + "doctrine/persistence": "^1.3.3|^2.0", + "php": "^7.2 || ^8.0" + }, + "conflict": { + "doctrine/phpcr-odm": "<1.3.0" + }, + "require-dev": { + "doctrine/coding-standard": "^8.2", + "doctrine/dbal": "^2.5.4", + "doctrine/mongodb-odm": "^1.3.0 || ^2.0.0", + "doctrine/orm": "^2.7.0", + "ext-sqlite3": "*", + "phpunit/phpunit": "^8.0" + }, + "suggest": { + "alcaeus/mongo-php-adapter": "For using MongoDB ODM 1.3 with PHP 7 (deprecated)", + "doctrine/mongodb-odm": "For loading MongoDB ODM fixtures", + "doctrine/orm": "For loading ORM fixtures", + "doctrine/phpcr-odm": "For loading PHPCR ODM fixtures" + }, + "type": "library", + "autoload": { + "psr-4": { + "Doctrine\\Common\\DataFixtures\\": "lib/Doctrine/Common/DataFixtures" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jonathan Wage", + "email": "jonwage@gmail.com" + } + ], + "description": "Data Fixtures for all Doctrine Object Managers", + "homepage": "http://www.doctrine-project.org", + "keywords": [ + "database" + ], + "support": { + "issues": "https://github.com/doctrine/data-fixtures/issues", + "source": "https://github.com/doctrine/data-fixtures/tree/1.5.0" + }, + "funding": [ + { + "url": "https://www.doctrine-project.org/sponsorship.html", + "type": "custom" + }, + { + "url": "https://www.patreon.com/phpdoctrine", + "type": "patreon" + }, + { + "url": "https://tidelift.com/funding/github/packagist/doctrine%2Fdata-fixtures", + "type": "tidelift" + } + ], + "time": "2021-01-23T10:20:43+00:00" + }, + { + "name": "doctrine/doctrine-fixtures-bundle", + "version": "3.4.0", + "source": { + "type": "git", + "url": "https://github.com/doctrine/DoctrineFixturesBundle.git", + "reference": "870189619a7770f468ffb0b80925302e065a3b34" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/DoctrineFixturesBundle/zipball/870189619a7770f468ffb0b80925302e065a3b34", + "reference": "870189619a7770f468ffb0b80925302e065a3b34", + "shasum": "" + }, + "require": { + "doctrine/data-fixtures": "^1.3", + "doctrine/doctrine-bundle": "^1.11|^2.0", + "doctrine/orm": "^2.6.0", + "doctrine/persistence": "^1.3.7|^2.0", + "php": "^7.1 || ^8.0", + "symfony/config": "^3.4|^4.3|^5.0", + "symfony/console": "^3.4|^4.3|^5.0", + "symfony/dependency-injection": "^3.4|^4.3|^5.0", + "symfony/doctrine-bridge": "^3.4|^4.1|^5.0", + "symfony/http-kernel": "^3.4|^4.3|^5.0" + }, + "require-dev": { + "doctrine/coding-standard": "^6.0", + "phpunit/phpunit": "^7.4 || ^8.0 || ^9.2", + "symfony/phpunit-bridge": "^4.1|^5.0" + }, + "type": "symfony-bundle", + "autoload": { + "psr-4": { + "Doctrine\\Bundle\\FixturesBundle\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Doctrine Project", + "homepage": "http://www.doctrine-project.org" + }, + { + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + } + ], + "description": "Symfony DoctrineFixturesBundle", + "homepage": "http://www.doctrine-project.org", + "keywords": [ + "Fixture", + "persistence" + ], + "support": { + "issues": "https://github.com/doctrine/DoctrineFixturesBundle/issues", + "source": "https://github.com/doctrine/DoctrineFixturesBundle/tree/3.4.0" + }, + "funding": [ + { + "url": "https://www.doctrine-project.org/sponsorship.html", + "type": "custom" + }, + { + "url": "https://www.patreon.com/phpdoctrine", + "type": "patreon" + }, + { + "url": "https://tidelift.com/funding/github/packagist/doctrine%2Fdoctrine-fixtures-bundle", + "type": "tidelift" + } + ], + "time": "2020-11-14T09:36:49+00:00" + }, { "name": "nikic/php-parser", "version": "v4.10.4", diff --git a/config/bundles.php b/config/bundles.php index b101c2a..d0fd45c 100644 --- a/config/bundles.php +++ b/config/bundles.php @@ -10,4 +10,5 @@ return [ Symfony\Bundle\TwigBundle\TwigBundle::class => ['all' => true], Symfony\Bundle\MakerBundle\MakerBundle::class => ['dev' => true], Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle::class => ['all' => true], + Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle::class => ['dev' => true, 'test' => true], ]; diff --git a/src/Controller/api/PollController.php b/src/Controller/api/PollController.php index 5bb2d47..826e5ab 100644 --- a/src/Controller/api/PollController.php +++ b/src/Controller/api/PollController.php @@ -77,8 +77,7 @@ class PollController extends EmailsController { * get a poll config by its custom URL, we do not want polls to be reachable by their numeric id * @Get( * path = "/{customUrl}", - * name = "get_poll", - * requirements = {"customUrl"="\w+"} + * name = "get_poll" * ) * * @param SerializerInterface $serializer diff --git a/src/DataFixtures/AppFixtures.php b/src/DataFixtures/AppFixtures.php index fece475..8838f8f 100755 --- a/src/DataFixtures/AppFixtures.php +++ b/src/DataFixtures/AppFixtures.php @@ -3,7 +3,8 @@ namespace App\DataFixtures; use Doctrine\Bundle\FixturesBundle\Fixture; -use Doctrine\Common\Persistence\ObjectManager; +use Doctrine\Persistence\ObjectManager; + class AppFixtures extends Fixture { diff --git a/src/DataFixtures/AppPollFixtures.php b/src/DataFixtures/AppPollFixtures.php index d62e78d..838f8fa 100755 --- a/src/DataFixtures/AppPollFixtures.php +++ b/src/DataFixtures/AppPollFixtures.php @@ -10,7 +10,7 @@ use App\Entity\StackOfVotes; use App\Entity\Vote; use DateTime; use Doctrine\Bundle\FixturesBundle\Fixture; -use Doctrine\Common\Persistence\ObjectManager; +use Doctrine\Persistence\ObjectManager; class AppPollFixtures extends Fixture { public function load( ObjectManager $manager ) { @@ -99,12 +99,14 @@ class AppPollFixtures extends Fixture { $ownerComment = new Comment(); $ownerComment ->setText( "trop bien ce sondage wohooo! signé l'auteur." ) + ->setPseudo('un gens qui commente') ->setOwner( $owner ); $poll->addComment( $ownerComment ); $someoneComment = new Comment(); $someoneComment ->setText( "comme l'auteur se la raconte. PFFFF!" ) + ->setPseudo('un gens qui commente') ->setOwner( $commenterMan ); $poll->addComment( $someoneComment ); @@ -169,11 +171,13 @@ class AppPollFixtures extends Fixture { $someoneComment = new Comment(); $someoneComment + ->setPseudo('un gens qui commente') ->setText( "allez boumbo!" ) ->setOwner( $commenterMan ); $poll->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 ); diff --git a/src/DataFixtures/CommentFixtures.php b/src/DataFixtures/CommentFixtures.php index 64d0055..9beb15d 100644 --- a/src/DataFixtures/CommentFixtures.php +++ b/src/DataFixtures/CommentFixtures.php @@ -6,7 +6,7 @@ use App\Entity\Comment; use App\Entity\Owner; use App\Entity\Poll; use Doctrine\Bundle\FixturesBundle\Fixture; -use Doctrine\Common\Persistence\ObjectManager; +use Doctrine\Persistence\ObjectManager; class CommentFixtures extends Fixture { public function load( ObjectManager $manager ) { @@ -20,9 +20,10 @@ class CommentFixtures extends Fixture { ->setPseudo( 'Wulfila' ); // comment on "citron ou orange" - $pollCitronOrange = $emPoll->find( 1 ); + $pollCitronOrange = $emPoll->findOneByCustomUrl( 'citron' ); $comment = new Comment(); $comment->setOwner( $commenterMan ) + ->setPseudo( 'the indécis people' ) ->setText( 'quelle indécision wololo! finalement citron. heu non orange. AAAAh!' ); $pollCitronOrange->addComment( $comment ); $manager->persist( $comment ); @@ -34,6 +35,7 @@ class CommentFixtures extends Fixture { $poll = $emPoll->find( 2 ); $comment = new Comment(); $comment->setOwner( $commenterMan2 ) + ->setPseudo( 'The Hayroule king' ) ->setText( 'il est écrit Squalala.' ); $pollCitronOrange->addComment( $comment ); $manager->persist( $comment ); @@ -43,6 +45,7 @@ class CommentFixtures extends Fixture { $comment = new Comment(); $comment->setOwner( $commenterMan ) + ->setPseudo( 'The Hayroule king' ) ->setText( "Zelda. Orange." ); $pollCitronOrange->addComment( $comment ); $manager->persist( $comment ); @@ -55,6 +58,7 @@ class CommentFixtures extends Fixture { $poll = $emPoll->find( 3 ); $comment = new Comment(); $comment->setOwner( $commenterMan ) + ->setPseudo( 'The Hayroule king' ) ->setText( "va pour demain" ); $pollCitronOrange->addComment( $comment ); $manager->persist( $comment ); @@ -66,6 +70,7 @@ class CommentFixtures extends Fixture { $poll = $emPoll->find( 4 ); $comment = new Comment(); $comment->setOwner( $commenterMan2 ) + ->setPseudo( 'The Hayroule king' ) ->setText( "Ceci est un commentaire de fixture créé avec le CipherBliss poweur." ); $pollCitronOrange->addComment( $comment ); $manager->persist( $comment ); diff --git a/src/DataFixtures/VotesStacksFixtures.php b/src/DataFixtures/VotesStacksFixtures.php index 2fb35d5..37e0141 100644 --- a/src/DataFixtures/VotesStacksFixtures.php +++ b/src/DataFixtures/VotesStacksFixtures.php @@ -7,7 +7,7 @@ use App\Entity\Poll; use App\Entity\StackOfVotes; use App\Entity\Vote; use Doctrine\Bundle\FixturesBundle\Fixture; -use Doctrine\Common\Persistence\ObjectManager; +use Doctrine\Persistence\ObjectManager; class VotesStacksFixtures extends Fixture { public function load( ObjectManager $manager ) { diff --git a/symfony.lock b/symfony.lock index d874e2e..9ff7297 100644 --- a/symfony.lock +++ b/symfony.lock @@ -23,6 +23,9 @@ "doctrine/common": { "version": "3.1.2" }, + "doctrine/data-fixtures": { + "version": "1.5.0" + }, "doctrine/dbal": { "version": "2.13.0" }, @@ -45,6 +48,18 @@ "src/Repository/.gitignore" ] }, + "doctrine/doctrine-fixtures-bundle": { + "version": "3.0", + "recipe": { + "repo": "github.com/symfony/recipes", + "branch": "master", + "version": "3.0", + "ref": "e5b542d4ef47d8a003c91beb35650c76907f7e53" + }, + "files": [ + "src/DataFixtures/AppFixtures.php" + ] + }, "doctrine/doctrine-migrations-bundle": { "version": "3.1", "recipe": {