Fixture generation
You can generate a CRM Core–style fixture from the same CSV files used by the CRM project (e.g. Simpsons contact and relationship data). The Drush command produces a PHP file that inserts rows into the CRM Core and Relation tables.
Running the command
From your Drupal application root:
drush crm-migrate:generate-fixture --dir=/path/to/crm/tests/simpsons
Or with explicit paths:
drush crm-migrate:generate-fixture \
--contact-csv=/path/to/contact.csv \
--relationship-csv=/path/to/relationship.csv \
--output=web/modules/contrib/crm_migrate_crm_core/tests/fixtures/crm_core_fixture_simpsons.php
Options
| Option | Description |
|---|---|
| --dir | Directory containing contact.csv and relationship.csv (e.g. the CRM project’s tests/simpsons). If set, it overrides the individual CSV paths. |
| --contact-csv | Path to the contact CSV file. Ignored if --dir is set. |
| --relationship-csv | Path to the relationship CSV file. Ignored if --dir is set. |
| --output | Path for the generated PHP file. Defaults to the module’s tests/fixtures/crm_core_fixture_simpsons.php. |
| --replace | If set (default), the generated file truncates the CRM Core and relation tables before inserting, so the fixture contains only the CSV data. Omit for append mode. |
The generated file contains only $connection->insert(...) calls (and, with --replace, truncate) for the CRM Core and Relation tables. It does not create tables.
Using the fixture in migration tests
- Load the base D7 fixture in your test (e.g. from
tests/fixtures/crm_core_fixture.php) using your test base’s database dump mechanism. - Then include or execute the generated fixture (e.g.
tests/fixtures/crm_core_fixture_simpsons.php) so that contact and relationship data match the CSVs.
If your test base supports only a single database dump, load the base fixture first, then run the generated fixture’s PHP (e.g. by including the file or evaluating it in the same database connection context) so that the CRM Core and Relation tables are populated with the CSV data.
See CSV format for required columns and type mappings.