thephpleague / factory-muffin

Enables the rapid creation of objects for testing
https://factory-muffin.thephpleague.com/
MIT License
534 stars 72 forks source link

Using factory-muffin with data-mapper #289

Closed fesor closed 10 years ago

fesor commented 10 years ago

In readme there is one strange line

It's basically a "factory_girl", simplified for use with PHP.

But this library seems to be working only with Laravel's Active Record models. Do you have any plans to make it usable with Doctrine?

scottrobertson commented 10 years ago

It does work on other systems too, Kohana for example.

I have never used Doctrine in my life, but people are free to submit PR's to see if they can make it work (this would be awesome).

GrahamCampbell commented 10 years ago

I think this is going to be a "no fix" for now. I'm sure I could get basic doctrine support sorted, but it would be so restricted, it's not worth it. Doctrine is fundamentally different to Eloquent. I think we need to keep the focus on doing a good job at supporting Eloquent, and other similar systems, rather than trying to please everybody, and doing a bad job.

As Scott said, we'd be interested if anyone with lots of Doctrine experience could send a pull. I'd definitely consider this for 3.0, and I assume Scott would too.

kirkbushell commented 10 years ago

Doctrine is picking up steam in the Laravel community, and we need something exactly like this to setup our tests nicely.

Am happy to work on a PR if you guys are willing to accept. Would just need some sort of implementation adapter that could handle the attribute assigning.

GrahamCampbell commented 10 years ago

@kirkbushell Sounds cool. If you do write anything, please write it against our experiential branch, which will land as 3.0. Currently, the plans for 3.0 are refactoring, and actually simplifying things.

We can't promise to "accept", but there definitely is an interest.

fesor commented 10 years ago

Unforchantly you will need full redesign of FactoryMuffin to do this. Or this will be just something not so useful. There are already several solutions for Doctrine, but i don't like it. Doctrine entities is more than just table views.

Sad, but there is nothing better than phactory for now (framework-independent, easy-to-use, blazing fast and can restore database state. Requires a lot of boilerplate code.). I thinking about to write component which generates blueprints from Doctrine mapping. It is possible to get ideas from phactory and phpmashinist to build modern and highly flexible solution.

GrahamCampbell commented 10 years ago

@fesor Factory Muffin is framework independent, and is very flexible in the way we set attributes, and the way we persist the changes. We aim to be the best, while trying to reduce complexity.

GrahamCampbell commented 10 years ago

https://github.com/thephpleague/factory-muffin#additional-customisation

kirkbushell commented 10 years ago

@GrahamCampbell roger, will work on something over the next week and put something up.

GrahamCampbell commented 10 years ago

@kirkbushell Awesome. Thanks. :)

GrahamCampbell commented 9 years ago

Ping @kirkbushell.

joshhornby commented 8 years ago

@kirkbushell Did you make any progress with this? Would love to use Factory Muffin with Doctrine.

GrahamCampbell commented 8 years ago

@joshhornby This was implemented already by @DavertMik, and is available in 3.x.

joshhornby commented 8 years ago

@GrahamCampbell Brilliant! Is there any docs on this yet?

GrahamCampbell commented 8 years ago

Sorry, there are no docs, but reading over the tests might help. I have no time to write any decent upgrading docs, or usage docs for the doctrine stuff, sorry.

joshhornby commented 8 years ago

No worries, I will look over the tests. Thank you for the quick response :+1: