Skip to content

Commit

Permalink
symfony 6 support
Browse files Browse the repository at this point in the history
  • Loading branch information
Cristoforo Cervino committed Dec 17, 2021
1 parent 1eca41f commit 692ca35
Show file tree
Hide file tree
Showing 8 changed files with 95 additions and 87 deletions.
112 changes: 53 additions & 59 deletions .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,76 +2,70 @@ name: page-filter-form-bundle-CI
on:
[push, pull_request]
jobs:
build-php-7-4:
phpstan:
runs-on: ubuntu-latest
name: PHPStan
steps:
- uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
- uses: actions/checkout@v2
- name: composer install
run: composer install

build-php-8:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Checkout
uses: actions/checkout@v2
- name: composer install
run: composer install

check-code-php-7-4:
runs-on: ubuntu-latest
needs: [ build-php-7-4 ]
steps:
- uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
- uses: actions/checkout@v2
- name: composer install
run: composer install

- name: cs-check
run: composer cs-check

- name: phpstan
- name: PHPStan
run: composer phpstan

check-code-php-8:
env:
REQUIRE_DEV: true
cs-fixer:
runs-on: ubuntu-latest
needs: [ build-php-8 ]
name: PHP-CS-Fixer
steps:
- uses: actions/checkout@v2
- name: Checkout
uses: actions/checkout@v2
- name: composer install
run: composer install

- name: cs-check
- name: CS Check
run: composer cs-check

- name: phpstan
run: composer phpstan

tests-php-7-4:
tests:
runs-on: ubuntu-latest
needs: [ build-php-7-4 ]
strategy:
matrix:
name:
- 'PHP 7.4 tests (Symfony 4.4)'
- 'PHP 7.4 tests (Symfony 5.1)'
- 'PHP 8.0 tests (Symfony 5.2)'
- 'PHP 8.0 tests (Symfony 5.3)'
- 'PHP 8.0 tests (Symfony 5.4)'
- 'PHP 8.0 tests (Symfony 6.0)'
include:
- php: '7.4'
symfony: 4.4.*
- php: '7.4'
symfony: 5.1.*
- php: '8.0'
symfony: 5.2.*
- php: '8.0'
symfony: 5.3.*
- php: '8.0'
symfony: 5.4.*
- php: '8.0'
symfony: 6.0.*
- php: '8.1'
symfony: 6.0.*
name: ${{ matrix.name }}
steps:
- uses: shivammathur/setup-php@v2
- name: Checkout
uses: actions/checkout@v2
- name: Setup MySQL
run: |
sudo systemctl enable mysql.service
sudo systemctl start mysql.service
mysql -uroot -proot -h localhost -e "CREATE DATABASE test CHARACTER SET utf8 COLLATE utf8_general_ci;"
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
- uses: actions/checkout@v2

- name: composer install
run: composer install

- name: phpunit
run: composer phpunit

tests-php-8:
runs-on: ubuntu-latest
needs: [ build-php-8 ]
steps:
- uses: actions/checkout@v2
- name: composer install
run: composer install

- name: phpunit
run: composer phpunit
php-version: ${{ matrix.php }}
- run: |
sed -ri 's/"symfony\/(.+)": "(.+)"/"symfony\/\1": "${{ matrix.symfony }}"/' composer.json;
if: matrix.symfony
- run: composer update --no-interaction --no-progress --ansi
- run: composer phpunit
20 changes: 13 additions & 7 deletions .php_cs.dist → .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,15 @@
* Additional rules or rules to override.
* These rules will be added to default rules or will override them if the same key already exists.
*/

$additionalRules = [
'native_function_invocation' => true,
'phpdoc_add_missing_param_annotation' => ['only_untyped' => false],
'native_function_invocation' => [
'include' => [
'@all',
],
'scope' => 'all',
'strict' => true,
],
'phpdoc_add_missing_param_annotation' => ['only_untyped' => true],
'phpdoc_align' => true,
'phpdoc_return_self_reference' => true,
'phpdoc_trim_consecutive_blank_line_separation' => true,
Expand All @@ -16,14 +21,15 @@
'@Symfony' => true,
];

$config = PhpCsFixer\Config::create();
$config->setRules($additionalRules);
$config = new PhpCsFixer\Config();
$config->setUsingCache(false);
$config->setRiskyAllowed(true);
$config->setRules($additionalRules);

$finder = PhpCsFixer\Finder::create()
$finder = (new PhpCsFixer\Finder())
->in(__DIR__)
->exclude('var');
->exclude('var')
;

$config->setFinder($finder);

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@

[![Latest Version](https://img.shields.io/github/release/andanteproject/page-filter-form-bundle.svg)](https://github.com/andanteproject/page-filter-form-bundle/releases)
![Github actions](https://github.com/andanteproject/page-filter-form-bundle/actions/workflows/workflow.yml/badge.svg?branch=main)
![Framework](https://img.shields.io/badge/Symfony-4.x|5.x-informational?Style=flat&logo=symfony)
![Framework](https://img.shields.io/badge/Symfony-4.x|5.x|6.x-informational?Style=flat&logo=symfony)
![Php7](https://img.shields.io/badge/PHP-%207.4|8.x-informational?style=flat&logo=php)
![PhpStan](https://img.shields.io/badge/PHPStan-Level%208-syccess?style=flat&logo=php)

A Symfony Bundle to simplify the handling of page filters for lists/tables in admin panels. 🧪

## Requirements

Symfony 4.x-5.x and PHP 7.4.
Symfony 4.x-6.x and PHP 7.4-8.0.

## Features

Expand Down
21 changes: 13 additions & 8 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,18 @@
],
"require": {
"php": "^7.4 || ^8.0",
"symfony/form": "^4.0 || ^5.0"
"symfony/form": "^4.0 || ^5.0 || ^6.0"
},
"require-dev": {
"symfony/framework-bundle": "^4.0 | ^5.0",
"symfony/framework-bundle": "^4.0 | ^5.0 | ^6.0",
"roave/security-advisories": "dev-master",
"phpunit/phpunit": "^9.5",
"symfony/yaml": "^5.2",
"friendsofphp/php-cs-fixer": "^2.18",
"phpstan/phpstan": "^0.12.78",
"phpstan/phpstan-phpunit": "^0.12.17",
"friendsofphp/php-cs-fixer": "^3.4",
"phpstan/phpstan": "^1.0",
"phpstan/phpstan-phpunit": "^1.0",
"phpstan/extension-installer": "^1.1",
"phpstan/phpstan-symfony": "^0.12.20",
"phpstan/phpstan-symfony": "^1.0",
"ext-json": "*"
},
"autoload": {
Expand All @@ -55,7 +55,12 @@
"phpunit-base": "phpunit tests/",
"phpunit": "@phpunit-base --testdox",
"phpunit-coverage-text": "@phpunit-base --coverage-text --colors=never",
"cs-check": "mkdir -p var/cache && php-cs-fixer fix --dry-run --diff --cache-file=var/cache/.php_cs.cache --config=.php_cs.dist",
"cs-fix": "mkdir -p var/cache && php-cs-fixer fix --diff --cache-file=var/cache/.php_cs.cache --config=.php_cs.dist"
"cs-check": "mkdir -p var/cache && php-cs-fixer fix --dry-run --diff --cache-file=var/cache/.php_cs.cache",
"cs-fix": "mkdir -p var/cache && php-cs-fixer fix --diff --cache-file=var/cache/.php_cs.cache"
},
"config": {
"allow-plugins": {
"phpstan/extension-installer": true
}
}
}
18 changes: 9 additions & 9 deletions tests/Functional/PageFilterManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ protected function setUp(): void
public function testCreateAndHandleFilterWithObject(): void
{
/** @var PageFilterManagerInterface $filterManager */
$filterManager = self::$container->get(PageFilterManager::class);
$filterManager = self::getContainer()->get(PageFilterManager::class);
$fakeQueryBuilder = new \stdClass();
$fakeQueryBuilder->criteriaSearch1 = null;
$fakeQueryBuilder->criteriaSearch2 = null;
Expand All @@ -48,7 +48,7 @@ public function testCreateAndHandleFilterWithObject(): void
public function testCreateAndHandleFilterWithObjectNullArgs(): void
{
/** @var PageFilterManagerInterface $filterManager */
$filterManager = self::$container->get(PageFilterManager::class);
$filterManager = self::getContainer()->get(PageFilterManager::class);
$fakeQueryBuilder = new \stdClass();
$fakeQueryBuilder->criteriaSearch1 = null;
$fakeQueryBuilder->criteriaSearch2 = null;
Expand All @@ -68,7 +68,7 @@ public function testCreateAndHandleFilterWithObjectNullArgs(): void
public function testCreateAndHandleFilterWithObjectNullArgsWithNoNullableArgs2(): void
{
/** @var PageFilterManagerInterface $filterManager */
$filterManager = self::$container->get(PageFilterManager::class);
$filterManager = self::getContainer()->get(PageFilterManager::class);
$fakeQueryBuilder = new \stdClass();
$fakeQueryBuilder->criteriaSearch1 = null;
$fakeQueryBuilder->criteriaSearch2 = null;
Expand All @@ -87,7 +87,7 @@ public function testCreateAndHandleFilterWithObjectNullArgsWithNoNullableArgs2()
public function testCreateAndHandleFilterWithObjectNotEnoughParameters(): void
{
/** @var PageFilterManagerInterface $filterManager */
$filterManager = self::$container->get(PageFilterManager::class);
$filterManager = self::getContainer()->get(PageFilterManager::class);
$fakeQueryBuilder = new \stdClass();
$fakeQueryBuilder->criteriaSearch1 = null;
$this->expectException(TargetCallableArgumentException::class);
Expand All @@ -104,7 +104,7 @@ public function testCreateAndHandleFilterWithObjectNotEnoughParameters(): void
public function testCreateAndHandleFilterWithObjectWrongTypeHint1(): void
{
/** @var PageFilterManagerInterface $filterManager */
$filterManager = self::$container->get(PageFilterManager::class);
$filterManager = self::getContainer()->get(PageFilterManager::class);
$fakeQueryBuilder = new \stdClass();
$fakeQueryBuilder->criteriaSearch1 = null;
$this->expectException(TargetCallableArgumentException::class);
Expand All @@ -121,7 +121,7 @@ public function testCreateAndHandleFilterWithObjectWrongTypeHint1(): void
public function testCreateAndHandleFilterWithObjectWrongTypeHint2(): void
{
/** @var PageFilterManagerInterface $filterManager */
$filterManager = self::$container->get(PageFilterManager::class);
$filterManager = self::getContainer()->get(PageFilterManager::class);
$fakeQueryBuilder = new \stdClass();
$fakeQueryBuilder->criteriaSearch1 = null;
$this->expectException(TargetCallableArgumentException::class);
Expand All @@ -138,7 +138,7 @@ public function testCreateAndHandleFilterWithObjectWrongTypeHint2(): void
public function testCreateAndHandleFilterWithObjectWrongTypeHint3(): void
{
/** @var PageFilterManagerInterface $filterManager */
$filterManager = self::$container->get(PageFilterManager::class);
$filterManager = self::getContainer()->get(PageFilterManager::class);
$fakeQueryBuilder = new \stdClass();
$fakeQueryBuilder->criteriaSearch1 = null;
$this->expectException(TargetCallableArgumentException::class);
Expand All @@ -155,7 +155,7 @@ public function testCreateAndHandleFilterWithObjectWrongTypeHint3(): void
public function testCreateAndHandleFilterWithArray(): void
{
/** @var PageFilterManagerInterface $filterManager */
$filterManager = self::$container->get(PageFilterManager::class);
$filterManager = self::getContainer()->get(PageFilterManager::class);
$array = [
'criteriaSearch1' => null,
'criteriaSearch2' => null,
Expand All @@ -176,7 +176,7 @@ public function testCreateAndHandleFilterWithArray(): void
public function testCreateAndHandleFilterWithArrayByValue(): void
{
/** @var PageFilterManagerInterface $filterManager */
$filterManager = self::$container->get(PageFilterManager::class);
$filterManager = self::getContainer()->get(PageFilterManager::class);
$array = [
'criteriaSearch1' => null,
];
Expand Down
2 changes: 1 addition & 1 deletion tests/Functional/SetUpTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ protected function setUp(): void
public function testDependencyInjection(): void
{
/** @var DumbService $dumbService */
$dumbService = self::$container->get(DumbService::class);
$dumbService = self::getContainer()->get(DumbService::class);
$rProperty = new \ReflectionProperty($dumbService, 'pageFilterManager');
$rProperty->setAccessible(true);
$filterManager = $rProperty->getValue($dumbService);
Expand Down
3 changes: 3 additions & 0 deletions tests/HttpKernel/config/config_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ parameters:
kernel.secret: "secret"
locale: "en"

framework:
test: true

services:
_defaults:
public: true
Expand Down
2 changes: 1 addition & 1 deletion tests/KernelTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class KernelTestCase extends \Symfony\Bundle\FrameworkBundle\Test\KernelTestCase
{
protected function getFormFactory(): FormFactoryInterface
{
$container = self::$container;
$container = self::getContainer();
/** @var FormFactoryInterface $formFactory */
$formFactory = $container->get('form.factory');

Expand Down

0 comments on commit 692ca35

Please sign in to comment.