- PHP 88.2%
- Shell 10.8%
- Blade 1%
| .ci | ||
| .github | ||
| app | ||
| bootstrap | ||
| config | ||
| database | ||
| public | ||
| resources | ||
| routes | ||
| scripts | ||
| storage | ||
| tests | ||
| .editorconfig | ||
| .env.example | ||
| .gitattributes | ||
| .gitignore | ||
| artisan | ||
| composer.json | ||
| composer.lock | ||
| license | ||
| package.json | ||
| readme.md | ||
| server.php | ||
| webpack.mix.js | ||
Firefly III test data generator
The Firefly III test data generator generates test databases for Firefly III. It can handle multiple sets of data, so you can create test databases for a variety of use cases.
The data generator also comes with commands to reconfigure Firefly III, so it will use the newly generated data. This is useful if you want to test Firefly III with a specific data set.
Out of the box, this test data generator comes with two data sets:
More data sets exist, and more data sets can be created (by you). Just follow the example of the demo data set.
Usage
The data generator needs a few separate steps to generate a data set and configure Firefly III to use it.
To generate a test data set, run the following commands. Pre-configured scripts that follow ALL steps in the right order are in the scripts-directory.
1: Reconfigure the test data generator for the preferred database
The test data generator can deliver to MySQL, PostgreSQL or SQLite, but must be configured to do so. The easy way to do this is by simply configuring the .env file of the test data generator to match the Firefly III database you wish to generate data for
⚠️ All data in this database will be deleted!
There are a few pre-programmed .env-files for your convenience stored in resources/configurations.
You can add your own files to this directory, and then use the following command. It should be no surprise that test-fixtures refers to the file resources/configurations/test-fixtures.txt.
You can skip this step by manually configuring the data generator using the .env.example file provided.
php artisan test-data:reconfigure-self test-fixtures
2: Reset the database
The next step is to force-drop all tables in the Firefly III destination database. This ensures that the test database is entirely. If you are sure the database is already empty, you can skip this step.
php artisan test-data:drop-tables
3: Run migrations and generate data
The test data generator must copy the necessary database migrations and enums straight from Firefly III. This ensures the data generator always uses the latest data, and it makes sure the data importer does not contain duplicate code, which can only get out of sync.
The next step is to run all the freshly copied migrations. This ensures the database is on-par with the last release of Firefly III. Since you just configured the test data generator to use the same database as Firefly III, this should have the same effect as running this command in the Firefly III folder.
The main command of the test data generator actually generates data. The demo argument refers to the test data set. You can find the test data sets in the resources/data-sets folder. You can always edit them, remove them or add data.
php artisan test-data:copy-migrations local --directory=/your-local/firefly-iii
php artisan migrate:refresh --seed --force --step
php artisan test-data:generate demo
4: Cleanup!
The next step cleans up the test data generator, so it is ready for the next run.
php artisan test-data:cleanup
5: Prepare Firefly III
When necessary, you can tell the test data generator to reconfigure Firefly III according to a pre-existing .env-file. These files are stored in the resources/ff3-config folder. You can see that test-fixtures refers to the file resources/ff3-config/test-fixtures.txt.
php artisan test-data:reconfigure-firefly-iii test-fixtures --directory=$FIREFLY
The Firefly III installation that will use the test data also needs to be prepared. This is done by running the following commands in the Firefly III directory.
These commands clear out the cache, remove lingering local files and validate the content you just generated.
⚠️ Run these commands in the Firefly III directory
cd /your/firefly-iii/directory
rm -f storage/oauth-private.key
rm -f storage/oauth-public.key
php artisan firefly-iii:restore-oauth-keys
php artisan cache:clear
php artisan config:clear
php artisan firefly-iii:upgrade-database
Done!
That should be it! You can now log in to Firefly III and use the test data.
Do you need help, or do you want to get in touch?
Do you want to contact me? You can email me at james@firefly-iii.org or get in touch through one of the following support channels:
- GitHub Discussions for questions and support
- Gitter.im for a good chat and a quick answer
- GitHub Issues for bugs and issues
- Mastodon for news and updates
Support the development of Firefly III
If you like Firefly III and if it helps you save lots of money, why not send me a dime for every dollar saved! 🥳
OK that was a joke. If you feel Firefly III made your life better, please consider contributing as a sponsor. Please check out my Patreon and GitHub Sponsors page for more information. You can also buy me a ☕️ coffee at ko-fi.com. Thank you for your consideration.