khepin / KhepinYamlFixturesBundle

Easy loading of fixtures defined in YAML files for Symfony2 and Doctrine2
MIT License
58 stars 42 forks source link

Define YamlLoader class in config.yml ilo hardcoded #18

Open chess-server opened 12 years ago

chess-server commented 12 years ago

Great Bundle! I am using it a lot to setup the base data of the application before populating the database with the data of the symfony1 application. However, for test purposes, I would like to be in the position to load only a few fixtures, The first tests should see an empty DB, then loading - test by test - the database from scratch, but test 1 would contain only 1 fixture, test 2 the first 2 or 3 etc. This would require to modify YamlLoader::loadFixtureFiles only. I would like to create a class to extend YamlLoader and overwrite loadFixtureFiles and/or loadFixtures. Can you make the bundle flexible enough to load a different class ilo Khepin\YamlFixturesBundle\Loader\YamlLoader to be specified in the config file? (cf FOSUserBundle)

khepin commented 12 years ago

The "tag" functionality already allows you to do this and chose exactly which features you want to load. Or am I missing your point?

chess-server commented 12 years ago

Am 04.09.2012 05:42, schrieb Sebastien Armand:

The "tag" functionality already allows you to do this and chose exactly which features you want to load. Or am I missing your point?

— Reply to this email directly or view it on GitHub https://github.com/khepin/KhepinYamlFixturesBundle/issues/18#issuecomment-8251716.

If I would need only one type of database setup, I could use the tags, but the way I am setting it up I would need many tags. The idea is to load test by test more fixtures: BookControllerTest requires 001_book.yml LanguageControllerTest requires 001_book.yml and 002_language.yml CatalogueControllerTest requires 001_book.yml and 002_language.yml and 003_catalogue.yml etc. etc.

khepin commented 12 years ago

Ok, so normally if you only have one database it would still work. If you have 2 (or more) databases and therefore (2 or more doctrine entity managers), then some works needs to be done. If you don't use the "purge" option, you also could load things incrementally:

etc...

If it still doesn't fit your needs, feel free to make a pull request to allow setting the loader through the config. Add a test. And then we're good to go.