This pull request makes various changes around the importer commands. Changes include but are not limited to:
Changed the console output, to improve styling.
Tweaked some of the language around command descriptions and argument descriptions.
Added tests to cover all of the importer commands
No tests existed for the importers until now. I had spotted a few errors in my manual testing so I was able to squash them by writing tests.
Fixed an issue when import form submissions
It was still trying to use the ->submissions() relationship on the Form model, which was removed in #177.
I've changed it to instead create directly on the configured Submission model.
Fixed an error when importing asset containers
When the previous importer code was calling ->toModel(), it was touching was a core AssetContainer class which didn't have a toModel class on it, causing it to be sent through the augmentation stuff and error out.
I've added a new makeModelFromContract method to the AssetContainer class, which seems to be how the new importer implementations work.
Refactored the guards around determining which stuff should be imported, by introducing new shouldImport... methods.
Added --only-* arguments to some importers responsible for importing multiple things
These new arguments allow for doing --only-assets or --only-form-submission on importer commands which can import multiple things like importing asset containers & assets or forms & form submissions.
This PR started out small but grew arms and legs once I decided to add tests for everything 😆 .
Related: statamic/cms#9669.
To Do
[x] Fix failing tests in ImportGlobalsTest
[x] Add tests for all the importer commands
[x] Fix failing tests in ImportEntriesTest
The tests seem to be importing entries with their old Stache ID, which is a string. However, the database migration is expecting an integer, causing it to fail. Setting the $shouldUseStringEntryIds property doesn't seem to help.
[x] Fix issue with the collection importer when entries are in the Stache
Target class [statamic.eloquent.entries.model] does not exist.
This pull request makes various changes around the importer commands. Changes include but are not limited to:
->submissions()
relationship on theForm
model, which was removed in #177.Submission
model.->toModel()
, it was touching was a coreAssetContainer
class which didn't have atoModel
class on it, causing it to be sent through the augmentation stuff and error out.makeModelFromContract
method to theAssetContainer
class, which seems to be how the new importer implementations work.shouldImport...
methods.--only-*
arguments to some importers responsible for importing multiple things--only-assets
or--only-form-submission
on importer commands which can import multiple things like importing asset containers & assets or forms & form submissions.This PR started out small but grew arms and legs once I decided to add tests for everything 😆 .
Related: statamic/cms#9669.
To Do
ImportGlobalsTest
ImportEntriesTest
$shouldUseStringEntryIds
property doesn't seem to help.Target class [statamic.eloquent.entries.model] does not exist.