From 59cb293d80a4df321ce8fff9c84e42a31ee58429 Mon Sep 17 00:00:00 2001 From: Tom H Anderson Date: Fri, 4 Feb 2022 17:29:03 -0700 Subject: [PATCH 1/3] Added descriptions to Import options --- src/Console/Commands/ImportCommand.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Console/Commands/ImportCommand.php b/src/Console/Commands/ImportCommand.php index 4dfea5b..d31da83 100644 --- a/src/Console/Commands/ImportCommand.php +++ b/src/Console/Commands/ImportCommand.php @@ -18,7 +18,11 @@ class ImportCommand extends Command * * @var string */ - protected $signature = 'doctrine:data-fixtures:import {group} {--purge-with-truncate} {--do-not-append}'; + protected $signature = 'doctrine:data-fixtures:import + {group : The fixtures group name} + {--purge-with-truncate : if specified will purge the object manager tables before running fixtures for the ORMPurger only} + {--do-not-append : will delete ALL data in the database before running fixtures} + '; /** * The console command description. From 3fcb3d8e26586e8e65d96a7fe1b881e2473f98f9 Mon Sep 17 00:00:00 2001 From: Tom H Anderson Date: Fri, 4 Feb 2022 17:37:22 -0700 Subject: [PATCH 2/3] Added Psalm --- .github/workflows/static-analysis.yml | 26 ++++++++++++++++++++++++++ README.md | 20 +++++++++++++------- composer.json | 3 ++- psalm.xml | 15 +++++++++++++++ 4 files changed, 56 insertions(+), 8 deletions(-) create mode 100644 .github/workflows/static-analysis.yml create mode 100644 psalm.xml diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml new file mode 100644 index 0000000..c2f179d --- /dev/null +++ b/.github/workflows/static-analysis.yml @@ -0,0 +1,26 @@ +name: "Static analysis" + +on: + pull_request: + branches: + - "*.x" + - "main" + push: + branches: + - "*.x" + - "main" + +jobs: + psalm: + name: "Static Analysis" + runs-on: ubuntu-latest + + steps: + - uses: shivammathur/setup-php@15c43e89cdef867065b0213be354c2841860869e + with: + php-version: '8.0' + - uses: actions/checkout@v2 + - name: Install Dependencies + run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist + - name: Execute tests (Unit and Feature tests) via PHPUnit + run: vendor/bin/psalm diff --git a/README.md b/README.md index eef2bb7..b50305c 100644 --- a/README.md +++ b/README.md @@ -90,8 +90,10 @@ List all groups or list all fixtures for a group. php artisan doctrine:data-fixtures:list [] ``` -### Executing Fixture Group through Artisan command ---------------------------------------------------- +The `` is optional. + + +### Executing a Fixture Group through Artisan command ```sh php artisan doctrine:data-fixtures:import [--purge-with-truncate] [--do-not-append] @@ -109,23 +111,27 @@ running fixtures for the ORMPurger only. `--do-not-append` will delete all data in the database before running fixtures. -Executing Fixture Group from code +Executing a Fixture Group from code --------------------------------- For unit testing or other times you must run your fixtures from within code, follow this example: ```php -$config = $application['config']['doctrine-data-fixtures.' . $groupName]; +use use Doctrine\Common\DataFixtures\Loader; + +$config = config('doctrine-data-fixtures')[$groupName]; -$objectManager = $application->get($config['objectManager']); -$loader = $application->get($config['loader']); -$purger = $application->get($config['purger']); +$objectManager = app($config['objectManager']); +$purger = app($config['purger']); +$executorClass = $config['executor']; +$loader = new Loader(); foreach ($config['fixtures'] as $fixture) { $loader->addFixture($fixture); } +$executor = new $executorClass($objectManager, $purger); $executor->execute($loader->getFixtures()); ``` diff --git a/composer.json b/composer.json index 715bfb5..efe5d07 100644 --- a/composer.json +++ b/composer.json @@ -5,7 +5,8 @@ "require": { "php": "^8.0", "doctrine/data-fixtures": "^1.5", - "laravel/framework": "^8.82" + "laravel/framework": "^8.82", + "vimeo/psalm": "^4.20" }, "require-dev": { "phpunit/phpunit": "^9.5", diff --git a/psalm.xml b/psalm.xml new file mode 100644 index 0000000..8dc065a --- /dev/null +++ b/psalm.xml @@ -0,0 +1,15 @@ + + + + + + + + + From 1242d751d46c4708c335b0dc8252b1a83563be08 Mon Sep 17 00:00:00 2001 From: Tom H Anderson Date: Fri, 4 Feb 2022 17:43:50 -0700 Subject: [PATCH 3/3] Set minimum version of dbal --- README.md | 3 +-- composer.json | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index b50305c..f7ad315 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,4 @@ -Laravel Doctrine Data Fixtures ------------------------------- +# Laravel Doctrine Data Fixtures Laravel has built-in support for 'seed' data. In seed data, the classes are not namespaced and many developers treat seed data as a one-time diff --git a/composer.json b/composer.json index efe5d07..6562b52 100644 --- a/composer.json +++ b/composer.json @@ -11,6 +11,7 @@ "require-dev": { "phpunit/phpunit": "^9.5", "doctrine/coding-standard": "^9.0", + "doctrine/dbal": "^2.13", "laravel-doctrine/orm": "^1.7", "orchestra/testbench": "^6.24" },