symfony / maker-bundle

Symfony Maker Bundle
https://symfony.com/
MIT License
3.35k stars 406 forks source link

[make:crud][Test] Create and Flush EntityManager when all entities are removed ? #1377

Closed HiroKX closed 11 months ago

HiroKX commented 11 months ago

When generating the test associated with a controller, the setUp method doesn't create an instance of the EntityManager and doesn't flush after removing all the entities in the manager.

Is this expected behavior, or should we address it?

What we have now : image

How i fixed it : image

weaverryan commented 11 months ago

Yup! Can you open a PR? And actually, we already have a template that is correct I think - https://github.com/symfony/maker-bundle/blob/main/src/Resources/skeleton/crud/test/Test.EntityManager.tpl.php

The bug was introduced when we removed some methods from the repository generation. So I think the fix is:

PR appreciated!