Skip to content

Commit 32ef2b4

Browse files
authored
Merge pull request #2 from TomHAnderson/feature/prep-for-version
Feature/prep for version
2 parents cf5b6d0 + 1242d75 commit 32ef2b4

File tree

5 files changed

+63
-11
lines changed

5 files changed

+63
-11
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: "Static analysis"
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- "*.x"
7+
- "main"
8+
push:
9+
branches:
10+
- "*.x"
11+
- "main"
12+
13+
jobs:
14+
psalm:
15+
name: "Static Analysis"
16+
runs-on: ubuntu-latest
17+
18+
steps:
19+
- uses: shivammathur/setup-php@15c43e89cdef867065b0213be354c2841860869e
20+
with:
21+
php-version: '8.0'
22+
- uses: actions/checkout@v2
23+
- name: Install Dependencies
24+
run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
25+
- name: Execute tests (Unit and Feature tests) via PHPUnit
26+
run: vendor/bin/psalm

README.md

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
Laravel Doctrine Data Fixtures
2-
------------------------------
1+
# Laravel Doctrine Data Fixtures
32

43
Laravel has built-in support for 'seed' data. In seed data, the classes
54
are not namespaced and many developers treat seed data as a one-time
@@ -90,8 +89,10 @@ List all groups or list all fixtures for a group.
9089
php artisan doctrine:data-fixtures:list [<group>]
9190
```
9291

93-
### Executing Fixture Group through Artisan command
94-
---------------------------------------------------
92+
The `<group>` is optional.
93+
94+
95+
### Executing a Fixture Group through Artisan command
9596

9697
```sh
9798
php artisan doctrine:data-fixtures:import <group> [--purge-with-truncate] [--do-not-append]
@@ -109,23 +110,27 @@ running fixtures for the ORMPurger only.
109110
`--do-not-append` will delete all data in the database before running fixtures.
110111

111112

112-
Executing Fixture Group from code
113+
Executing a Fixture Group from code
113114
---------------------------------
114115

115116
For unit testing or other times you must run your fixtures from within code,
116117
follow this example:
117118

118119
```php
119-
$config = $application['config']['doctrine-data-fixtures.' . $groupName];
120+
use use Doctrine\Common\DataFixtures\Loader;
121+
122+
$config = config('doctrine-data-fixtures')[$groupName];
120123

121-
$objectManager = $application->get($config['objectManager']);
122-
$loader = $application->get($config['loader']);
123-
$purger = $application->get($config['purger']);
124+
$objectManager = app($config['objectManager']);
125+
$purger = app($config['purger']);
126+
$executorClass = $config['executor'];
127+
$loader = new Loader();
124128

125129
foreach ($config['fixtures'] as $fixture) {
126130
$loader->addFixture($fixture);
127131
}
128132

133+
$executor = new $executorClass($objectManager, $purger);
129134
$executor->execute($loader->getFixtures());
130135
```
131136

composer.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@
55
"require": {
66
"php": "^8.0",
77
"doctrine/data-fixtures": "^1.5",
8-
"laravel/framework": "^8.82"
8+
"laravel/framework": "^8.82",
9+
"vimeo/psalm": "^4.20"
910
},
1011
"require-dev": {
1112
"phpunit/phpunit": "^9.5",
1213
"doctrine/coding-standard": "^9.0",
14+
"doctrine/dbal": "^2.13",
1315
"laravel-doctrine/orm": "^1.7",
1416
"orchestra/testbench": "^6.24"
1517
},

psalm.xml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version="1.0"?>
2+
<psalm
3+
errorLevel="5"
4+
resolveFromConfigFile="true"
5+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
6+
xmlns="https://getpsalm.org/schema/config"
7+
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
8+
>
9+
<projectFiles>
10+
<directory name="src" />
11+
<ignoreFiles>
12+
<directory name="vendor" />
13+
</ignoreFiles>
14+
</projectFiles>
15+
</psalm>

src/Console/Commands/ImportCommand.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@ class ImportCommand extends Command
1818
*
1919
* @var string
2020
*/
21-
protected $signature = 'doctrine:data-fixtures:import {group} {--purge-with-truncate} {--do-not-append}';
21+
protected $signature = 'doctrine:data-fixtures:import
22+
{group : The fixtures group name}
23+
{--purge-with-truncate : if specified will purge the object manager tables before running fixtures for the ORMPurger only}
24+
{--do-not-append : will delete ALL data in the database before running fixtures}
25+
';
2226

2327
/**
2428
* The console command description.

0 commit comments

Comments
 (0)