API-Skeletons / zf-doctrine-data-fixture

Doctrine Data Fixture Console Route with Service Manager configured Fixtures
BSD 2-Clause "Simplified" License
9 stars 4 forks source link

Reuse symfony/console from DoctrineModule #17

Closed internalsystemerror closed 6 years ago

internalsystemerror commented 6 years ago

This PR includes:

See: https://github.com/API-Skeletons/zf-doctrine-data-fixture/issues/4

internalsystemerror commented 6 years ago

This is a fairly large change and although it passes the local tests in composer ci-check I suggest that you try this with any modules dependent upon it for BC breaks. I've also tested this PR branch in place of the latest stable in an application I'm using it in, and that all runs successfully.

The only thing of note with this, is that php public/index.php will no longer be an access point provided since zend-mvc-console is no longer included. Since it integrates with DoctrineModule, however, I do believe that including zend-mvc-console in your application would allow this access point to be available again.

TomHAnderson commented 6 years ago

The list command does not work for groups:

root@8081e4c8dc6e:/var/www# php public/index.php data-fixture:list

All Fixture Groups
==================

 * zf-doctrine-audit
 * elasticsearch
 * default
 * performance-substitution

root@8081e4c8dc6e:/var/www# php public/index.php data-fixture:list default

All Fixture Groups
==================

 * zf-doctrine-audit
 * elasticsearch
 * default
 * performance-substitution

root@8081e4c8dc6e:/var/www#

php public/index.php data-fixture:list <groupname> should return a list of the data fixtures in that groupname.

TomHAnderson commented 6 years ago

When no fixture group is given to import please create a nicer error message:

root@8081e4c8dc6e:/var/www# php public/index.php data-fixture:import

In ServiceManager.php line 771:

  Service with name "ZF\Doctrine\DataFixture\DataFixtureManager" could not be
   created. Reason: No fixture group given.

In DataFixtureManagerFactory.php line 51:

  No fixture group given.

data-fixture:import [--purge-with-truncate] [--do-not-append] [--] [<group_name>]

root@8081e4c8dc6e:/var/www#
internalsystemerror commented 6 years ago

I've encountered one thing in testing I'm not entirely certain about...

Rerunning the import for a given fixture group gives me duplicate key warnings. Is this intentional? I typically destroy and recreate the db from schema and then importing the fixtures again so its not something I've noticed.

But I recall when writing the help text for the commands that rerunning the fixtures should not be an issue.

internalsystemerror commented 6 years ago

I'd say this is ready now unless you want to change the help message?

TomHAnderson commented 6 years ago

I write all my fixtures to be repeatable. Throwing duplicate key errors is correct for fixtures which are not written to be re-ran.

internalsystemerror commented 6 years ago

I've been using this in a few projects without issue, thoughts?