Skip to content

Commit

Permalink
Allow Symfony 7
Browse files Browse the repository at this point in the history
  • Loading branch information
norkunas committed Dec 1, 2023
1 parent f2cc87e commit 40c20f0
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 43 deletions.
55 changes: 21 additions & 34 deletions .github/workflows/code_checks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,42 +14,41 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
php: ['7.1', '7.2', '7.4', '8.0', '8.1', '8.2']
symfony: ['^3.4', '^4.0', '^5.0']
exclude:
- symfony: ^5.0
php: 7.1
php: ['7.1', '7.2', '7.4', '8.0', '8.1', '8.2', '8.3']
symfony: ['^3.4', '^4.0', '^5.0', '^6.0', '^7.0']
# exclude:
# - symfony: ^5.0
# php: 7.1
include:
- symfony: ^6.0
php: 8.0
- symfony: ^6.0
php: 8.1
- symfony: ^6.0
php: 8.2
- symfony: ^7.0
php: 8.2
- symfony: ^7.0
php: 8.3
fail-fast: false
name: PHPUnit (PHP ${{ matrix.php }}) (Symfony ${{ matrix.symfony }})
steps:

- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
coverage: none # disable xdebug, pcov

- name: Get Composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

- name: Cache Composer
uses: actions/cache@v3
- name: Install PHP dependencies
uses: ramsey/composer-install@v2
env:
SYMFONY_REQUIRE: ${{ matrix.symfony }}
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-php-${{ matrix.php }}-composer-${{ hashFiles('**/composer.json **/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-${{ matrix.php }}-composer-
tools: flex

- name: Restrict Symfony version
if: matrix.symfony != ''
Expand All @@ -59,9 +58,9 @@ jobs:
composer config extra.symfony.require "${{ matrix.symfony }}"
# remove this after support for symfony 3 is dropped
- name: Remove PhpUnit 10 support for old Symfony Versions
if: matrix.symfony == '^3.4' || matrix.symfony == '^4.0'
run: composer require --no-update "phpunit/phpunit:^7|^8|^9"
# - name: Remove PhpUnit 10 support for old Symfony Versions
# if: matrix.symfony == '^3.4' || matrix.symfony == '^4.0'
# run: composer require --no-update "phpunit/phpunit:^7|^8|^9"

- name: Install PHP dependencies
run: composer install --no-interaction
Expand All @@ -77,28 +76,16 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 7.4
php-version: 8.3
coverage: xdebug

- name: Get Composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

- name: Cache Composer
uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-php-${{ matrix.php }}-composer-${{ hashFiles('**/composer.json **/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-${{ matrix.php }}-composer-
- name: Install PHP dependencies
run: composer install --no-interaction
uses: ramsey/composer-install@v2

- name: Run code coverage
run: vendor/bin/phpunit --coverage-text --coverage-clover=coverage.clover
Expand Down
3 changes: 2 additions & 1 deletion Tests/Validator/Constraints/Recaptcha3ValidatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Karser\Recaptcha3Bundle\Validator\Constraints\Recaptcha3Validator;
use PHPUnit\Framework\MockObject\MockObject;
use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\ConstraintValidatorInterface;
use Symfony\Component\Validator\Exception\UnexpectedTypeException;
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;

Expand All @@ -24,7 +25,7 @@ public function setUp(): void
parent::setUp();
}

protected function createValidator()
protected function createValidator(): ConstraintValidatorInterface
{
$this->recaptcha = new RecaptchaMock();
return new Recaptcha3Validator($this->recaptcha, $enabled = true, $this->resolver);
Expand Down
1 change: 1 addition & 0 deletions Tests/fixtures/config/symfony6.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
framework:
http_method_override: false
session:
storage_factory_id: session.storage.factory.mock_file
4 changes: 3 additions & 1 deletion Validator/Constraints/Recaptcha3.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ final class Recaptcha3 extends Constraint
{
const INVALID_FORMAT_ERROR = '7147ffdb-0af4-4f7a-bd5e-e9dcfa6d7a2d';

protected static $errorNames = [
protected const ERROR_NAMES = [
self::INVALID_FORMAT_ERROR => 'INVALID_FORMAT_ERROR',
];

protected static $errorNames = self::ERROR_NAMES;

public $message = 'Your computer or network may be sending automated queries';
public $messageMissingValue = 'The captcha value is missing';

Expand Down
14 changes: 7 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,17 @@
"require": {
"php": ">=7.1",
"google/recaptcha": "^1.2",
"symfony/form": "^3.4|^4.0|^5.0|^6.0",
"symfony/framework-bundle": "^3.4.26|^4.2.7|^5.0|^6.0",
"symfony/expression-language": "^3.4|^4.0|^5.0|^6.0",
"symfony/yaml": "^3.4|^4.0|^5.0|^6.0",
"symfony/validator": "^3.4|^4.0|^5.0|^6.0",
"symfony/twig-bundle": "^3.4|^4.0|^5.0|^6.0",
"symfony/form": "^3.4|^4.0|^5.0|^6.0|^7.0",
"symfony/framework-bundle": "^3.4.26|^4.2.7|^5.0|^6.0|^7.0",
"symfony/expression-language": "^3.4|^4.0|^5.0|^6.0|^7.0",
"symfony/yaml": "^3.4|^4.0|^5.0|^6.0|^7.0",
"symfony/validator": "^3.4|^4.0|^5.0|^6.0|^7.0",
"symfony/twig-bundle": "^3.4|^4.0|^5.0|^6.0|^7.0",
"twig/twig": "^2.9|^3.0"
},
"require-dev": {
"phpunit/phpunit": "^7|^8|^9|^10",
"symfony/http-client": "^4.3|^5.0|^6.0"
"symfony/http-client": "^4.3|^5.0|^6.0|^7.0"
},
"autoload": {
"psr-4": {
Expand Down

0 comments on commit 40c20f0

Please sign in to comment.