Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/coding-standards.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ on:
jobs:
coding-standards:
name: "Coding Standards"
uses: "doctrine/.github/.github/workflows/coding-standards.yml@1.3.0"
uses: "doctrine/.github/.github/workflows/coding-standards.yml@7.2.0"
with:
php-version: '8.0'
php-version: '8.4'
composer-options: '--prefer-dist --ignore-platform-req=php'

30 changes: 8 additions & 22 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,13 @@ jobs:
fail-fast: false
matrix:
php-version:
- "8.0"
- "8.1"
- "8.2"
- "8.3"
- "8.4"
dependencies:
- "highest"
- "lowest"
optional-dependencies:
- true
- false
include:
- php-version: "8.0"
dependencies: "lowest"
optional-dependencies: false
- php-version: "8.0"
dependencies: "lowest"
optional-dependencies: true

steps:
- name: "Checkout"
Expand All @@ -52,26 +43,21 @@ jobs:

- name: "Install dependencies with Composer"
uses: "ramsey/composer-install@v1"
if: "! startsWith(matrix.php-version, '8')"
with:
dependency-versions: "${{ matrix.dependencies }}"
composer-options: "--prefer-dist --no-suggest"
composer-options: "--prefer-dist"

- name: "Install dependencies with Composer (--ignore-platform-req=php)"
uses: "ramsey/composer-install@v1"
if: "startsWith(matrix.php-version, '8')"
with:
dependency-versions: "${{ matrix.dependencies }}"
composer-options: "--prefer-dist --no-suggest --ignore-platform-req=php"
- name: "Show Composer packages"
run: "composer show"

- name: "Run PHPUnit"
run: "vendor/bin/phpunit --coverage-clover=coverage.xml"

- name: "Upload coverage file"
uses: "actions/upload-artifact@v2"
uses: "codecov/codecov-action@v4"
with:
name: "phpunit-${{ matrix.php-version }}-${{ matrix.dependencies }}-${{ matrix.dbal-version }}.coverage"
path: "coverage.xml"
files: "./coverage.xml"

upload_coverage:
name: "Upload coverage to Codecov"
Expand All @@ -86,7 +72,7 @@ jobs:
fetch-depth: 2

- name: "Download coverage files"
uses: "actions/download-artifact@v2"
uses: "actions/download-artifact@v4"
with:
path: "reports"

Expand Down
36 changes: 0 additions & 36 deletions .github/workflows/php.yml

This file was deleted.

4 changes: 2 additions & 2 deletions .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ jobs:
steps:
- uses: shivammathur/setup-php@15c43e89cdef867065b0213be354c2841860869e
with:
php-version: '8.0'
- uses: actions/checkout@v2
php-version: '8.4'
- uses: actions/checkout@v4
- 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
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
/.phpcs-cache
/.phpunit.cache/
/coverage/
.phpunit.result.cache
27 changes: 18 additions & 9 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@
"description": "Doctrine Data Fixtures for Laravel",
"type": "library",
"require": {
"php": "^8.0",
"doctrine/data-fixtures": "^1.5",
"laravel/framework": "^8.82 || ^9.0 || ^10.0 || ^11.0"
"php": "^8.3",
"doctrine/data-fixtures": "^2.0",
"laravel/framework": "^12.0"
},
"require-dev": {
"phpunit/phpunit": "^9.5",
"doctrine/coding-standard": "^9",
"doctrine/dbal": "^2.13",
"laravel-doctrine/orm": "^1.7",
"orchestra/testbench": "^6.24",
"vimeo/psalm": "^4.20 || ^5.0"
"doctrine/coding-standard": "^12.0",
"doctrine/dbal": "^4.0",
"laravel-doctrine/orm": "^3.1",
"orchestra/testbench": "^10.1",
"vimeo/psalm": "^6.8",
"php-parallel-lint/php-parallel-lint": "^1.4"
},
"license": "MIT",
"autoload": {
Expand Down Expand Up @@ -43,5 +43,14 @@
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true
}
},
"scripts": {
"test": [
"vendor/bin/parallel-lint ./src/ ./test",
"vendor/bin/phpcs",
"vendor/bin/psalm",
"vendor/bin/phpunit"
],
"coverage": "XDEBUG_MODE=coverage vendor/bin/phpunit --coverage-html=coverage"
}
}
5 changes: 5 additions & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,9 @@
<directory name="vendor" />
</ignoreFiles>
</projectFiles>
<issueHandlers>
<InvalidCast errorLevel="suppress" />
<PossiblyUnusedMethod errorLevel="suppress" />
<UnusedClass errorLevel="suppress" />
</issueHandlers>
</psalm>
3 changes: 2 additions & 1 deletion src/Console/Commands/ListCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use Illuminate\Console\Command;

use function array_keys;
use function config;

class ListCommand extends Command
Expand Down Expand Up @@ -41,7 +42,7 @@ public function handle(): int
}

if (! $this->argument('group')) {
foreach ($this->config as $groupName => $groupConfig) {
foreach (array_keys($this->config) as $groupName) {
$this->info($groupName);
}

Expand Down
2 changes: 2 additions & 0 deletions src/ServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use ApiSkeletons\Laravel\Doctrine\DataFixtures\Console\Commands\ImportCommand;
use ApiSkeletons\Laravel\Doctrine\DataFixtures\Console\Commands\ListCommand;
use Illuminate\Support\ServiceProvider as LaravelServiceProvider;
use Override;

use function config_path;

Expand All @@ -15,6 +16,7 @@ class ServiceProvider extends LaravelServiceProvider
/**
* Register any application services.
*/
#[Override]
public function register(): void
{
}
Expand Down
20 changes: 20 additions & 0 deletions test/Feature/ServiceProviderTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

declare(strict_types=1);

namespace ApiSkeletonsTest\Laravel\Doctrine\DataFixtures;

use ApiSkeletons\Laravel\Doctrine\DataFixtures\ServiceProvider;

class ServiceProviderTest extends TestCase
{
public function testServiceProvider(): void
{
$serviceProvider = new ServiceProvider($this->app);

$serviceProvider->boot();
$serviceProvider->register();

$this->assertTrue(true);
}
}
29 changes: 15 additions & 14 deletions test/Fixtures/Fixture1.php
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
<?php

declare(strict_types=1);

namespace ApiSkeletonsTest\Laravel\Doctrine\DataFixtures\Fixtures;

use Doctrine\Persistence\ObjectManager;
use Doctrine\Common\DataFixtures\FixtureInterface;
use ApiSkeletonsTest\Laravel\Doctrine\DataFixtures\Entity\Fixture1 as Fixture1Entity;
use Doctrine\Common\DataFixtures\FixtureInterface;
use Doctrine\Persistence\ObjectManager;

class Fixture1 implements
FixtureInterface
{
const GUEST_ID = 1;
const USER_ID = 2;
const ADMIN_ID = 3;
public const GUEST_ID = 1;
public const USER_ID = 2;
public const ADMIN_ID = 3;

const GUEST = 'guest';
const USER = 'user';
const ADMIN = 'admin';
public const GUEST = 'guest';
public const USER = 'user';
public const ADMIN = 'admin';

public function load(ObjectManager $objectManager)
public function load(ObjectManager $manager): void
{
$data = [
[
Expand All @@ -35,22 +37,21 @@ public function load(ObjectManager $objectManager)
];

foreach ($data as $row) {
$entity = $objectManager
$entity = $manager
->getRepository(Fixture1Entity::class)
->find($row['id']);

if (! $entity) {
$entity = new Fixture1Entity();

$entity->setId($row['id']);
$objectManager->persist($entity);
$manager->persist($entity);
}

$entity
->setName($row['name'])
;
->setName($row['name']);

$objectManager->flush();
$manager->flush();
}
}
}
29 changes: 15 additions & 14 deletions test/Fixtures/Fixture2.php
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
<?php

declare(strict_types=1);

namespace ApiSkeletonsTest\Laravel\Doctrine\DataFixtures\Fixtures;

use Doctrine\Persistence\ObjectManager;
use Doctrine\Common\DataFixtures\FixtureInterface;
use ApiSkeletonsTest\Laravel\Doctrine\DataFixtures\Entity\Fixture2 as Fixture2Entity;
use Doctrine\Common\DataFixtures\FixtureInterface;
use Doctrine\Persistence\ObjectManager;

class Fixture2 implements
FixtureInterface
{
const GUEST_ID = 4;
const USER_ID = 5;
const ADMIN_ID = 6;
public const GUEST_ID = 4;
public const USER_ID = 5;
public const ADMIN_ID = 6;

const GUEST = 'guest2';
const USER = 'user2';
const ADMIN = 'admin2';
public const GUEST = 'guest2';
public const USER = 'user2';
public const ADMIN = 'admin2';

public function load(ObjectManager $objectManager)
public function load(ObjectManager $manager): void
{
$data = [
[
Expand All @@ -35,22 +37,21 @@ public function load(ObjectManager $objectManager)
];

foreach ($data as $row) {
$entity = $objectManager
$entity = $manager
->getRepository(Fixture2Entity::class)
->find($row['id']);

if (! $entity) {
$entity = new Fixture2Entity();

$entity->setId($row['id']);
$objectManager->persist($entity);
$manager->persist($entity);
}

$entity
->setName($row['name'])
;
->setName($row['name']);

$objectManager->flush();
$manager->flush();
}
}
}
Loading