Skip to content
Draft
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
5 changes: 2 additions & 3 deletions .docker/php/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM php:8.4-fpm-alpine
FROM php:8.5-fpm-alpine

ARG UID
ARG GID
Expand All @@ -13,8 +13,7 @@ RUN apk update && apk add \
bash \
icu-dev \
&& docker-php-ext-configure intl \
&& docker-php-ext-install intl opcache \
&& docker-php-ext-enable opcache
&& docker-php-ext-install intl

RUN ln -s /usr/share/zoneinfo/Europe/Paris /etc/localtime \
&& sed -i "s/^;date.timezone =.*/date.timezone = Europe\/Paris/" $PHP_INI_DIR/php.ini
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/quality.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v6
- name: Install PHP with extensions
uses: shivammathur/setup-php@v2
with:
php-version: '8.4'
php-version: '8.5'
coverage: none
tools: composer:v2
- name: Install Composer dependencies (locked)
Expand All @@ -32,11 +32,11 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v6
- name: Install PHP with extensions
uses: shivammathur/setup-php@v2
with:
php-version: '8.4'
php-version: '8.5'
coverage: none
tools: composer:v2
- name: Install Composer dependencies (locked)
Expand All @@ -49,11 +49,11 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
uses: actions/checkout@v6
- name: Install PHP with extensions
uses: shivammathur/setup-php@v2
with:
php-version: '8.4'
php-version: '8.5'
coverage: none
tools: composer:v2
- name: Install Composer dependencies (locked)
Expand Down
41 changes: 28 additions & 13 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,12 @@ jobs:
- '8.2'
- '8.3'
- '8.4'
- '8.5'
dependencies: [highest]
allowed-to-fail: [false]
symfony-require: ['']
variant: [normal]
include:
- php-version: '8.1'
dependencies: highest
allowed-to-fail: false
symfony-require: 6.4.*
variant: symfony/symfony:"6.4.*"
- php-version: '8.2'
dependencies: highest
allowed-to-fail: false
Expand All @@ -41,8 +37,8 @@ jobs:
- php-version: '8.2'
dependencies: highest
allowed-to-fail: false
symfony-require: 7.3.*
variant: symfony/symfony:"7.3.*"
symfony-require: 7.4.*
variant: symfony/symfony:"7.4.*"
- php-version: '8.3'
dependencies: highest
allowed-to-fail: false
Expand All @@ -51,8 +47,8 @@ jobs:
- php-version: '8.3'
dependencies: highest
allowed-to-fail: false
symfony-require: 7.3.*
variant: symfony/symfony:"7.3.*"
symfony-require: 7.4.*
variant: symfony/symfony:"7.4.*"
- php-version: '8.4'
dependencies: highest
allowed-to-fail: false
Expand All @@ -61,12 +57,31 @@ jobs:
- php-version: '8.4'
dependencies: highest
allowed-to-fail: false
symfony-require: 7.3.*
variant: symfony/symfony:"7.3.*"

symfony-require: 7.4.*
variant: symfony/symfony:"7.4.*"
- php-version: '8.4'
dependencies: highest
allowed-to-fail: false
symfony-require: 8.*
variant: symfony/symfony:"8.*"
- php-version: '8.5'
dependencies: highest
allowed-to-fail: false
symfony-require: 6.4.*
variant: symfony/symfony:"6.4.*"
- php-version: '8.5'
dependencies: highest
allowed-to-fail: false
symfony-require: 7.4.*
variant: symfony/symfony:"7.4.*"
- php-version: '8.5'
dependencies: highest
allowed-to-fail: false
symfony-require: 8.*
variant: symfony/symfony:"8.*"
steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v6
- name: Install PHP with extensions
uses: shivammathur/setup-php@v2
with:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@
.phpunit.cache
.php-cs-fixer.cache
coverage-report
GEMINI.md
7 changes: 3 additions & 4 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,8 @@

return (new PhpCsFixer\Config())
->setRules([
'@PHP71Migration' => true,
'@PHP82Migration' => true,
'@PHPUnit75Migration:risky' => true,
'@PHP8x2Migration' => true,
'@PHPUnit7x5Migration:risky' => true,
'@Symfony' => true,
'@Symfony:risky' => true,
'@DoctrineAnnotation' => true,
Expand All @@ -35,7 +34,7 @@
'header_comment' => ['header' => $fileHeaderComment],
'modernize_strpos' => true,
'get_class_to_class_keyword' => true,
'phpdoc_to_comment' => ['ignored_tags' => ['var']], // Fix issue on initializeStatement method $params variable
'phpdoc_to_comment' => ['ignored_tags' => ['var']], // Fix an issue on initializeStatement method $params variable
])
->setRiskyAllowed(true)
->setFinder(
Expand Down
18 changes: 9 additions & 9 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,21 +49,21 @@
}
},
"require": {
"php": ">=8.1",
"cleverage/process-bundle": "^4.0",
"doctrine/common": "^3.0",
"doctrine/dbal": "^2.9 || ^3.0",
"doctrine/doctrine-bundle": "^2.5",
"doctrine/doctrine-migrations-bundle": "^3.2",
"doctrine/orm": "^2.9 || ^3.0"
"php": ">=8.2",
"cleverage/process-bundle": "^5.0",
"doctrine/common": "^3.5",
"doctrine/dbal": "^3.10 || ^4.4",
"doctrine/doctrine-bundle": "^2.18 || ^3.1",
"doctrine/doctrine-migrations-bundle": "^3.7 || ^4",
"doctrine/orm": "^2.20 || ^3.5"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "*",
"phpstan/extension-installer": "*",
"phpstan/phpstan": "*",
"phpstan/phpstan-doctrine": "^2.0",
"phpstan/phpstan-doctrine": "*",
"phpstan/phpstan-symfony": "*",
"phpunit/phpunit": "<10.0",
"phpunit/phpunit": "*",
"rector/rector": "*",
"roave/security-advisories": "dev-latest",
"symfony/test-pack": "^1.1"
Expand Down
21 changes: 8 additions & 13 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,27 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.6/phpunit.xsd"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/12.0/phpunit.xsd"
bootstrap="vendor/autoload.php"
cacheResultFile=".phpunit.cache/test-results"
cacheDirectory=".phpunit.cache"
executionOrder="depends,defects"
forceCoversAnnotation="true"
beStrictAboutCoversAnnotation="true"
requireCoverageMetadata="true"
beStrictAboutCoverageMetadata="true"
beStrictAboutOutputDuringTests="true"
beStrictAboutTodoAnnotatedTests="true"
convertDeprecationsToExceptions="true"
failOnRisky="true"
failOnWarning="true"
verbose="true">
failOnWarning="true">
<testsuites>
<testsuite name="default">
<directory>tests</directory>
</testsuite>
</testsuites>

<coverage cacheDirectory=".phpunit.cache/code-coverage"
processUncoveredFiles="true">
<source>
<include>
<directory suffix=".php">src</directory>
</include>
</coverage>
</phpunit>
</source>
</phpunit>
8 changes: 4 additions & 4 deletions rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@
use Rector\ValueObject\PhpVersion;

return RectorConfig::configure()
->withPhpVersion(PhpVersion::PHP_84)
->withPhpVersion(PhpVersion::PHP_85)
->withPaths([
__DIR__.'/src',
__DIR__.'/tests',
])
->withPhpSets(php81: true)
// here we can define, what prepared sets of rules will be applied
->withPhpSets(php82: true)
// here we can define what prepared sets of rules will be applied
->withComposerBased(doctrine: true)
->withPreparedSets(deadCode: true, codeQuality: true, doctrineCodeQuality: true, symfonyCodeQuality: true)
->withAttributesSets(symfony: true, doctrine: true)
->withSets([
LevelSetList::UP_TO_PHP_81,
LevelSetList::UP_TO_PHP_82,
SymfonySetList::SYMFONY_64,
SymfonySetList::SYMFONY_CODE_QUALITY,
SymfonySetList::SYMFONY_CONSTRUCTOR_INJECTION,
Expand Down
4 changes: 3 additions & 1 deletion src/Task/Database/DatabaseReaderTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
use CleverAge\ProcessBundle\Model\FinalizableTaskInterface;
use CleverAge\ProcessBundle\Model\IterableTaskInterface;
use CleverAge\ProcessBundle\Model\ProcessState;
use Doctrine\DBAL\ArrayParameterType;
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\ParameterType;
use Doctrine\DBAL\Result;
use Doctrine\DBAL\Types\Type;
use Doctrine\Persistence\ManagerRegistry;
Expand All @@ -37,7 +39,7 @@
* 'offset': ?int,
* 'input_as_params': bool,
* 'params': array<string, mixed>,
* 'types': array<int, int|string|Type|null>|array<string, int|string|Type|null>
* 'types': array<int<0, max>|string, ArrayParameterType|ParameterType|Type|string>
* }
*/
class DatabaseReaderTask extends AbstractConfigurableTask implements IterableTaskInterface, FinalizableTaskInterface
Expand Down
4 changes: 3 additions & 1 deletion src/Task/Database/DatabaseUpdaterTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@

use CleverAge\ProcessBundle\Model\AbstractConfigurableTask;
use CleverAge\ProcessBundle\Model\ProcessState;
use Doctrine\DBAL\ArrayParameterType;
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Exception;
use Doctrine\DBAL\ParameterType;
use Doctrine\DBAL\Types\Type;
use Doctrine\Persistence\ManagerRegistry;
use Psr\Log\LoggerInterface;
Expand All @@ -31,7 +33,7 @@
* 'sql': string,
* 'input_as_params': bool,
* 'params': array<string, mixed>,
* 'types': array<int, int|string|Type|null>|array<string, int|string|Type|null>
* 'types': array<int<0, max>|string, ArrayParameterType|ParameterType|Type|string>
* }
*/
class DatabaseUpdaterTask extends AbstractConfigurableTask
Expand Down
2 changes: 1 addition & 1 deletion src/Task/EntityManager/DoctrineBatchWriterTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ protected function writeBatch(ProcessState $state): void
throw new \UnexpectedValueException("No manager found for class {$class}");
}
$entityManager->persist($entity);
$entityManagers->attach($entityManager);
$entityManagers->offsetSet($entityManager);
}

foreach ($entityManagers as $entityManager) {
Expand Down
39 changes: 39 additions & 0 deletions tests/Task/EntityManager/AbstractDoctrineQueryTaskTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

declare(strict_types=1);

/*
* This file is part of the CleverAge/DoctrineProcessBundle package.
*
* Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace CleverAge\DoctrineProcessBundle\Tests\Task\EntityManager;

use CleverAge\DoctrineProcessBundle\Task\EntityManager\AbstractDoctrineQueryTask;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\QueryBuilder;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\TestCase;

#[CoversClass(AbstractDoctrineQueryTask::class)]
class AbstractDoctrineQueryTaskTest extends TestCase
{
public function testGetQueryBuilderWithInvalidField(): void
{
$this->expectException(\UnexpectedValueException::class);

$task = $this->createStub(AbstractDoctrineQueryTask::class);
$repository = $this->createStub(EntityRepository::class);
$repository->method('createQueryBuilder')->willReturn(new QueryBuilder($this->createStub(EntityManagerInterface::class)));

$reflection = new \ReflectionClass(AbstractDoctrineQueryTask::class);
$method = $reflection->getMethod('getQueryBuilder');

$method->invoke($task, $repository, ['e.field; DROP TABLE dummy;' => 'value'], []);
}
}
52 changes: 52 additions & 0 deletions tests/Task/EntityManager/ClearEntityManagerTaskTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php

declare(strict_types=1);

/*
* This file is part of the CleverAge/DoctrineProcessBundle package.
*
* Copyright (c) Clever-Age
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace CleverAge\DoctrineProcessBundle\Tests\Task\EntityManager;

use CleverAge\DoctrineProcessBundle\Task\EntityManager\ClearEntityManagerTask;
use CleverAge\ProcessBundle\Model\ProcessState;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\Persistence\ManagerRegistry;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\TestCase;

#[CoversClass(ClearEntityManagerTask::class)]
class ClearEntityManagerTaskTest extends TestCase
{
public function testExecute(): void
{
$entityManager = $this->createMock(EntityManagerInterface::class);
$entityManager->expects($this->once())
->method('clear');

$managerRegistry = $this->createMock(ManagerRegistry::class);
$managerRegistry->expects($this->once())
->method('getManager')
->willReturn($entityManager);

$task = $this->getMockBuilder(ClearEntityManagerTask::class)
->setConstructorArgs([$managerRegistry])
->onlyMethods(['getOption']) // Mock only the getOption method
->getMock();

// Ensure getOption returns null for 'entity_manager', mimicking default behavior
$task->expects($this->once())
->method('getOption')
->with(self::anything(), 'entity_manager')
->willReturn(null);

$processState = $this->createStub(ProcessState::class);

$task->execute($processState);
}
}
Loading