thephpleague / factory-muffin

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

Make the error message in DeletingFailedException more descriptive #453

Open Liiva opened 6 years ago

Liiva commented 6 years ago

Currently in DeletingFailedException line 52 an error message is created:

We encountered 1 problem while trying to delete the saved models.  

This (incorrectly) let me to believe the cleanup failed, possibly because of foreign key constraint violations. It would be more useful to show the actual exception messages as in my case the actual error was:

The EntityManager is closed.
Liiva commented 4 years ago

Just for future reference if anyone hits this via a Google search, to troubleshoot the actual messages:

actor: UnitTester
modules:
    enabled:
        - Symfony:
            app_path: 'app'
            environment: 'test'
        # important, must be defined _before_ Doctrine2 module
        - DataFactory:
            depends: Doctrine2
        - Doctrine2:
            depends: Symfony
            cleanup: false
oyepez003 commented 1 year ago

Just for future reference if anyone hits this via a Google search, to troubleshoot the actual messages:

* Make sure the DataFactory module is defined **before** your ORM module, see snippet below.

* If you errors are database constraint violations, enable the [Codeception Logger](https://codeception.com/extensions#Logger) to see the actual error message in your log files (e.g.  `tests/_output/unit-2020-04-24` for unit tests)

* If all else fails, dump the exception messages in `vendor/league/factory-muffin/src/Stores/AbstractStore.php`
actor: UnitTester
modules:
    enabled:
        - Symfony:
            app_path: 'app'
            environment: 'test'
        # important, must be defined _before_ Doctrine2 module
        - DataFactory:
            depends: Doctrine2
        - Doctrine2:
            depends: Symfony
            cleanup: false

Thanks @Liiva This comment should be in the module's documentation!.

https://codeception.com/docs/modules/DataFactory