thephpleague / factory-muffin

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

DataMapper support with Doctrine tests #415

Closed DavertMik closed 8 years ago

DavertMik commented 8 years ago

Now you can use have FactoryMuffin to work with DataMapper pattern, especially with Doctrine. To have FactoryMuffin to be initialized with Doctine you should use RepositoryStore instead of ModelStore class:

$em = EntityManager::create($dbParams, $config);
$fm = new FactoryMuffin(new RepositoryStore($em));

Unlike model store you can't use factory prefix to create associated models. factory creation method is supported to create a record and recturn its id, while Doctrine expects to receive a complete entity into association. That's why you should use entity to get a record into association

'user_id' => 'factory|User', // to receive id of a record
// vs
'user' => 'entity|User', // to receive a record

Also Doctrine added as dev dependency and tests for it added.

GrahamCampbell commented 8 years ago

Thanks. I've left a few comments.

GrahamCampbell commented 8 years ago

Could you skip the failing tests on hhvm too please?

DavertMik commented 8 years ago

Done.

DavertMik commented 8 years ago

updtd

DavertMik commented 8 years ago

done

DavertMik commented 8 years ago

Ping-ping?

DavertMik commented 8 years ago

Done. But I hope that was the last part of codestyling and dockblock bureaucracy )

GrahamCampbell commented 8 years ago

Thanks for all your work here. I appreciate it very much. I'll do a final review of this at the weekend and then merge. :)

DavertMik commented 8 years ago

Ok, will be waiting for that and for final release of 3.0 :+1:

DavertMik commented 8 years ago

@GrahamCampbell yep, about 3.0. With this PR I have plans to include factory-muffin in Codeception 2.2 but I need to know your release plans so to decide If I can stick to it. It's not a nice idea to rely on beta dependency (

GrahamCampbell commented 8 years ago

Thank you @DavertMik.

GrahamCampbell commented 8 years ago

@DavertMik v3.0.0 is released now, even with incomplete upgrading docs. That was the main reason I was holding off, but it'a already like 18 months late, so I'm just going to ship it.

GrahamCampbell commented 8 years ago

Factory Muffin 3.x will be maintained into the future, and follows semver.

DavertMik commented 8 years ago

Awesome!