-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
InvalidArgumentException: "App\DataFixtures\UserFixtures" is not a registered fixture #64
Comments
Please try these suggestions: #57 (comment) |
Hello, I don't understand what I must try because my fixtures are in the src/Datafixtures repository. |
In the fixture, I changed the Doctrine\Common\DataFixtures\FixtureInterface implementation to Doctrine\Common\DataFixtures\AbstractFixture implementation. I don't have anymore the previously error, but the data aren't saved in the database. |
You need to persist data: https://symfony.com/doc/3.0/bundles/DoctrineFixturesBundle/index.html#writing-fixtures Add this for every entity:
|
Of course! Really sorry for this mistake on my part and thank you very much for your help. |
are you saying that we need to edit : I also saw an article where someone was flushing in the loop, so I'm really curious if there is something i don't know about. |
@vulkanosaure you can call If you add tens or hundreds of entities, check the doc about Batch Processing: https://www.doctrine-project.org/projects/doctrine-orm/en/2.16/reference/batch-processing.html See also this answer on Stack Overflow: https://stackoverflow.com/a/21335487/2257664 (spoiler: it's mine 😁) |
thanks but why isn't using one single |
Adding hundreds of records then:
Between these 2 cases, batch processing is a trade-off and it can help to not overwhelm Doctrine. It depends on the amount of data to be stored, so the first step is to test and see if you encounter performance issues, if that's the case then you can try different sizes for the batch. If you have no slowness when adding entities, keep one |
ok, thanks for the insights ! |
by the way, while i'm here :)
from my understanding, we always have to define our fixture in a separate
class,
what i would really like is to define the fixture data inside my test
function, (maybe not always but at least sometimes)
i really like the idea of having a tight coupling between a test and the
specific data it requires, to avoid creating some kind of global state that
will be likely to break at scale.
Is there any way to achieve that with your lib ?
something like
$this->databaseTool->loadFixturesInline(function(){ //define fixture code
here... });
Thanks
…On Wed, Nov 8, 2023 at 6:30 PM Alexis Lefebvre ***@***.***> wrote:
Adding hundreds of records then:
- using only flush at the end may use a lot of RAM (hydrated entities
can be pretty heavy). If I remember correctly Doctrine had performance
issues when dealing with thousand of entities and the final flush was
slow. It was about 10 years ago though so it may be better now
- using flush on every iteration of the loop may be slower since it
will perform many requests
Between these 2 cases, batch processing is a trade-off and it can help to
not overwhelm Doctrine. It depends on the amount of data to be stored, so
the first step is to test and see if you encounter performance issues. If
you have no slowness when adding entities, keep one flush.
—
Reply to this email directly, view it on GitHub
<#64 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABGJ2XBPQHABG5QD6FPZVMLYDNUNHAVCNFSM4MTXPGP2U5DIOJSWCZC7NNSXTN2JONZXKZKDN5WW2ZLOOQ5TCOBQGE3TAMZSHA3A>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
--
*Vincent Huss*
*Développeur Fullstack | *Symfony - Angular - Ionic
*(+33)6 76 67 53 37 | **skype : *vincent.huss * | * *website : *
www.appinstrasbourg.com <http://appinstrasbourg.com/>
|
@vulkanosaure Let's discuss this there: |
I'm using Symfony 5. I installed "LiipTestFixturesBundle" with
composer require --dev liip/test-fixtures-bundle
.I created this fixture :
I created this test :
When I run
php bin/phpunit
, I have this error :The text was updated successfully, but these errors were encountered: