thephpleague / factory-muffin

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

setDeleteMethod #423

Closed fireboy1919 closed 8 years ago

fireboy1919 commented 8 years ago

Is this gone forever?

Calling "setDeleteMethod" results in an undefined method in FactoryMuffin 3.0.

If we're using soft deletes in our codebase, then this is a problem. We need to be able to delete using something other than "delete" in tests.

GrahamCampbell commented 8 years ago

Yes, it's still supported. All you need to do is pass the customized store instance to factory muffin when you construct it:

use League\FactoryMuffin\FactoryMuffin;
use League\FactoryMuffin\Stores\ModelStore;

new FactoryMuffin(new ModelStore(null, 'myCustomSoftDeleteMethod'));

Infact, we already have an example on our readme: https://github.com/thephpleague/factory-muffin/blob/master/README.md#real-examples.