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
66 changes: 39 additions & 27 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,36 +15,31 @@ jobs:
- '8.3'
coverage: ['none']
symfony-versions:
- '4.4.*'
- '5.4.*'
- '6.0.*'
- '6.2.*'
- '6.4.*'
- '7.0.*'
- '8.0.*'
exclude:
- php: '8.1'
symfony-versions: '7.0.*'
- php: '8.1'
symfony-versions: '8.0.*'
- php: '8.2'
symfony-versions: '8.0.*'
- php: '8.3'
symfony-versions: '8.0.*'
include:
- php: '7.4'
symfony-versions: '^4.4'
coverage: 'none'
- php: '7.4'
symfony-versions: '^5.4'
coverage: 'none'
- php: '8.0'
symfony-versions: '^4.4'
coverage: 'none'
- php: '8.0'
symfony-versions: '^5.4'
coverage: 'none'
- php: '8.4'
coverage: 'xdebug'
symfony-versions: '^7.0'
description: 'Log Code Coverage'
- php: '8.4'
symfony-versions: '8.0.*'
coverage: 'none'

name: PHP ${{ matrix.php }} Symfony ${{ matrix.symfony-versions }} ${{ matrix.description }}
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4

- uses: actions/cache@v4
with:
Expand All @@ -71,22 +66,39 @@ jobs:
key: ${{ runner.os }}-${{ matrix.php }}-${{ matrix.symfony-versions }}-composer-${{ hashFiles('composer.json') }}
restore-keys: ${{ runner.os }}-${{ matrix.php }}-${{ matrix.symfony-versions }}-composer

- name: Update Symfony version
if: matrix.symfony-versions != ''
run: |
composer require symfony/config:${{ matrix.symfony-versions }} --no-update --no-scripts
composer require symfony/dependency-injection:${{ matrix.symfony-versions }} --no-update --no-scripts
composer require symfony/http-kernel:${{ matrix.symfony-versions }} --no-update --no-scripts

# Pin Symfony for this matrix cell. `composer require` updates the lock in one solve.
# Behat needs the same major for console/translation/yaml as config/di/http-kernel.
# Symfony 8 needs PHP >=8.4 and Behat 4.x-dev (Behat 3 only supports Symfony <=7).
- name: Install dependencies
run: composer install
run: |
set -e
# composer.json may pin platform.php for local lock resolution; CI uses real matrix PHP.
composer config --unset platform.php || true
V="${{ matrix.symfony-versions }}"
if [ -z "$V" ]; then
composer install --no-interaction --prefer-dist
exit 0
fi
REQ=(
"symfony/config:${V}"
"symfony/console:${V}"
"symfony/dependency-injection:${V}"
"symfony/event-dispatcher:${V}"
"symfony/http-kernel:${V}"
"symfony/translation:${V}"
"symfony/yaml:${V}"
)
if [[ "$V" == 8.0.* ]]; then
REQ+=("behat/behat:4.x-dev@dev")
fi
composer require "${REQ[@]}" --with-all-dependencies --no-interaction --prefer-dist

- name: Run PHPUnit tests
run: composer phpunit
if: matrix.coverage == 'none'

- name: PHPUnit tests and Log Code coverage
run: vendor/bin/phpunit --coverage-clover=coverage.xml
run: ./scripts/run-phpunit.sh --coverage-clover=coverage.xml
if: matrix.coverage == 'xdebug'

- name: Run codecov
Expand All @@ -95,4 +107,4 @@ jobs:
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: './coverage.xml'
fail_ci_if_error: true
fail_ci_if_error: false
4 changes: 3 additions & 1 deletion .github/workflows/security.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.3'

- name: Install dependencies
run: composer install --no-progress --no-interaction --prefer-dist
Expand Down
12 changes: 9 additions & 3 deletions .github/workflows/static-analysis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.3'

- name: Install dependencies
run: composer install --no-progress --no-interaction --prefer-dist
Expand All @@ -27,10 +29,12 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.3'

- name: Install dependencies
run: composer install --no-progress --no-interaction --prefer-dist
Expand All @@ -43,10 +47,12 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.3'

- name: Install dependencies
run: composer install --no-progress --no-interaction --prefer-dist
Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
/.idea/
/vendor/
/composer.lock
/vendor/
.DS_Store
/.phpunit.result.cache
/.phpunit.cache/
/clover.xml
9 changes: 5 additions & 4 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@ PHP library (Symfony bundle) providing Behat contexts for Doctrine ORM testing.
All defined in `composer.json` scripts section:

- `composer dev-checks` — runs validate + phpstan + phpcs + phpunit (use this as the full CI check)
- `composer phpunit` — unit tests only
- `composer phpunit` — unit tests only (uses `scripts/run-phpunit.sh`: PHPUnit 10+ gets extra flags for runner warnings; PHPUnit 9 unchanged)
- `composer phpstan` — static analysis (level max)
- `composer code-style` — PHP_CodeSniffer (PSR-12 + Slevomat rules)
- `composer code-style-fix` — auto-fix code style issues
- `composer rector` / `composer rector-fix` — Rector (see `rector.php`)
- `make phpunit` / `make dev-checks` / `make cs-fix` — thin wrappers around the same scripts

### Notes

- PHP 8.3 is installed from the `ondrej/php` PPA. The package supports PHP 7.4–8.4.
- No `composer.lock` is committed — `composer install` resolves from `composer.json` each time.
- PHPUnit config uses `convertErrorsToExceptions`/`convertNoticesToExceptions`/`convertWarningsToExceptions` which emit deprecation notices on PHPUnit 9.6 but tests still pass.
- PHP 8.3 is installed from the `ondrej/php` PPA. The package requires **PHP ^8.1** and **Symfony ^6.4** (6.0–6.3 are not supported).
- `composer.lock` is gitignored. `config.platform.php` defaults to **8.1.0** so dependency resolution matches Symfony 6.4’s minimum PHP.
- `phpcs.xml.dist` has a deprecation warning about comma-separated array syntax for `forbiddenFunctions` property — cosmetic only, does not affect results.
19 changes: 19 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
.PHONY: phpunit phpstan phpcs cs-fix rector dev-checks

phpunit:
composer phpunit

phpstan:
composer phpstan

phpcs:
composer code-style

cs-fix:
composer code-style-fix

rector:
composer rector-fix

dev-checks:
composer dev-checks
28 changes: 18 additions & 10 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,22 @@
],
"require": {
"ext-json": "*",
"php": "^7.4 || ^8.0",
"php": "^8.1",
"behat/behat": "^3.0",
"symfony/config": "^4.4 || ^5.4 || ^6.0 || ^7.0",
"symfony/dependency-injection": "^4.4 || ^5.4.34 || ^6.0 || ^7.0.2",
"symfony/http-kernel": "^4.4 || ^5.4 || ^6.0 || ^7.0",
"symfony/config": "^6.4 || ^7.0 || ^8.0",
"symfony/dependency-injection": "^6.4 || ^7.0 || ^8.0",
"symfony/http-kernel": "^6.4 || ^7.0 || ^8.0",
"symfony/yaml": "^6.4 || ^7.0 || ^8.0",
"macpaw/similar-arrays": "^1.0",
"doctrine/orm": "^2.0"
"doctrine/orm": "^2.0 || ^3.0"
},
"require-dev": {
"phpstan/phpstan": "^1.12",
"phpunit/phpunit": "^9.6",
"slevomat/coding-standard": "^7.2",
"squizlabs/php_codesniffer": "^3.12"
"phpstan/phpstan": "^2.0",
"phpunit/phpunit": "^9.6 || ^10.0 || ^11.0",
"rector/rector": "^0.15 || ^1.0 || ^2.0",
"slevomat/coding-standard": "^7.2 || ^8.0",
"squizlabs/php_codesniffer": "^3.12",
"phpstan/phpstan-doctrine": "^2.0"
},
"autoload": {
"psr-4": {
Expand All @@ -62,8 +65,10 @@
"phpstan": "./vendor/bin/phpstan analyse -l max",
"code-style": "./vendor/bin/phpcs",
"code-style-fix": "./vendor/bin/phpcbf",
"phpunit": "./vendor/bin/phpunit",
"phpunit": "scripts/run-phpunit.sh",
"phpunit-html-coverage": "XDEBUG_MODE=coverage ./vendor/bin/phpunit --coverage-html=coverage",
"rector": "./vendor/bin/rector process --dry-run",
"rector-fix": "./vendor/bin/rector process",
"dev-checks": [
"composer validate",
"@phpstan",
Expand All @@ -74,6 +79,9 @@
"config": {
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true
},
"platform": {
"php": "8.1.0"
}
}
}
4 changes: 3 additions & 1 deletion phpstan.neon.dist
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
includes:
- vendor/phpstan/phpstan-doctrine/extension.neon

parameters:
excludes_analyse:
paths:
- src
level: max
Expand Down
13 changes: 5 additions & 8 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="vendor/autoload.php"
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
bootstrap="vendor/autoload.php"
backupGlobals="false"
backupStaticAttributes="false"
colors="true"
verbose="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false">
<testsuites>
<testsuite name="Behat Orm Context Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
<coverage>
<coverage processUncoveredFiles="true">
<include>
<directory>./src</directory>
<directory suffix=".php">./src</directory>
</include>
<report>
<clover outputFile="clover.xml"/>
Expand Down
8 changes: 8 additions & 0 deletions rector.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

declare(strict_types=1);

use Rector\Config\RectorConfig;

return RectorConfig::configure()
->withPaths([__DIR__ . '/src']);
8 changes: 8 additions & 0 deletions scripts/run-phpunit.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env bash
set -euo pipefail
cd "$(dirname "$0")/.."
# PHPUnit 10+ treats runner warnings as failures unless these flags are set (PHPUnit 9 ignores them).
if vendor/bin/phpunit --version 2>/dev/null | grep -qE '^PHPUnit (10\.|1[1-9]\.|[2-9][0-9]\.)'; then
exec vendor/bin/phpunit --do-not-fail-on-phpunit-warning --do-not-fail-on-phpunit-deprecation "$@"
fi
exec vendor/bin/phpunit "$@"
Loading
Loading