Skip to content

Commit

Permalink
feature #227 Bump dependencies. test against symfony 7 (michnovka)
Browse files Browse the repository at this point in the history
This PR was merged into the 2.x-dev branch.

Discussion
----------

Bump dependencies. test against symfony 7

Update tests and check against versions that are not EOL:

https://endoflife.date/symfony

Commits
-------

572f0d8 Bump dependencies. Test against Symfony 7
  • Loading branch information
ogizanagi committed Jan 8, 2024
2 parents a64a1fa + 572f0d8 commit bd65e9e
Show file tree
Hide file tree
Showing 18 changed files with 275 additions and 85 deletions.
63 changes: 27 additions & 36 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
vendor/bin/simple-phpunit install
echo "::endgroup::"
env:
SYMFONY_REQUIRE: "6.2*dev"
SYMFONY_REQUIRE: "6.4*dev"

- name: 'Lint - PHP CS Fixer'
if: always() && steps.deps.outcome == 'success'
Expand Down Expand Up @@ -94,60 +94,53 @@ jobs:
mysql: true
allow-unstable: true

- name: 'Test Symfony 6.0 [Linux, PHP 8.1]'
- name: 'Test Symfony 6.3 [Linux, PHP 8.1]'
os: 'ubuntu-latest'
php: '8.1'
symfony: '6.0.*@dev'
symfony: '6.3.*@dev'
mongodb: true
mysql: true
allow-unstable: true

- name: 'Test Symfony 6.1 [Linux, PHP 8.1]'
- name: 'Test Symfony 6.4 [Linux, PHP 8.1]'
os: 'ubuntu-latest'
php: '8.1'
symfony: '6.1.*@dev'
symfony: '6.4.*@dev'
allow-unstable: true
mysql: true
mongodb: true

- name: 'Test Symfony 6.2 [Linux, PHP 8.1]'
- name: 'Test Symfony 7.0 [Linux, PHP 8.2]'
os: 'ubuntu-latest'
php: '8.1'
symfony: '6.2.*@dev'
php: '8.2'
symfony: '7.0.*@dev'
allow-unstable: true
mysql: true
mongodb: true
mongodbnew: true

# Bleeding edge (unreleased dev versions where failures are allowed)
- name: 'Test next Symfony [Linux, PHP 8.1] (allowed failure)'
os: 'ubuntu-latest'
php: '8.1'
symfony: '6.3.*@dev'
composer-flags: '--ignore-platform-req php'
allow-unstable: true
allow-failure: true
mysql: true
mongodb: true

- name: 'Test next Symfony [Linux, PHP 8.2] (allowed failure)'
- name: 'Test next Symfony 7.1 [Linux, PHP 8.2] (allowed failure)'
os: 'ubuntu-latest'
php: '8.2'
symfony: '6.3.*@dev'
symfony: '7.1.*@dev'
composer-flags: '--ignore-platform-req php'
allow-unstable: true
allow-failure: true
mysql: true
mongodb: true
mongodbnew: true

- name: 'Test next Symfony [Linux, PHP 8.3] (allowed failure)'
- name: 'Test next Symfony 7.1 [Linux, PHP 8.3] (allowed failure)'
os: 'ubuntu-latest'
php: '8.3'
symfony: '6.3.*@dev'
symfony: '7.1.*@dev'
composer-flags: '--ignore-platform-req php'
allow-unstable: true
allow-failure: true
mysql: true
mongodb: true
mongodbnew: true

steps:
- name: 'Set git to use LF'
Expand All @@ -167,19 +160,13 @@ jobs:
tools: 'composer:v2,flex'

- name: 'Start MongoDB (Linux)'
uses: supercharge/mongodb-github-action@1.8.0
uses: supercharge/mongodb-github-action@1.10.0
if: ${{ matrix.mongodb && matrix.os == 'ubuntu-latest' }}

- name: 'Remove MongoDB (Windows)'
uses: crazy-max/ghaction-chocolatey@v2
with:
args: uninstall mongodb mongodb.install -y --all-versions
if: ${{ matrix.mongodb && matrix.os == 'windows-latest' }}

- name: 'Start MongoDB (Windows)'
uses: crazy-max/ghaction-chocolatey@v2
uses: crazy-max/ghaction-chocolatey@v3
with:
args: install mongodb.install --version=5.0.14 --allow-downgrade
args: install mongodb.install --version=7.0.4 --allow-downgrade
if: ${{ matrix.mongodb && matrix.os == 'windows-latest' }}

- name: 'Shutdown Default Ubuntu MySQL'
Expand All @@ -189,7 +176,7 @@ jobs:
- name: 'Setup MySQL'
uses: ankane/setup-mysql@v1
with:
mysql-version: '8.0'
mysql-version: '8.0.35'
database: doctrine_tests
if: ${{ matrix.mysql }}

Expand All @@ -210,9 +197,13 @@ jobs:
run: composer config minimum-stability dev
if: ${{ matrix.allow-unstable }}

- name: 'Require Doctrine MongoDB dependencies'
- name: 'Require Doctrine MongoDB dependencies for old symfony'
run: composer require --no-update ${{ matrix.composer-flags }} --dev --no-interaction --ansi "doctrine/mongodb-odm:^2.4" "doctrine/mongodb-odm-bundle:^4.5.1"
if: ${{ matrix.mongodb }}
if: ${{ matrix.mongodb && !matrix.mongodbnew }}

- name: 'Require Doctrine MongoDB dependencies for new symfony'
run: composer require --no-update ${{ matrix.composer-flags }} --dev --no-interaction --ansi "doctrine/mongodb-odm:^2.6" "doctrine/mongodb-odm-bundle:5.0.x-dev"
if: ${{ matrix.mongodb && matrix.mongodbnew }}

- name: 'Install dependencies'
run: |
Expand All @@ -227,11 +218,11 @@ jobs:
SYMFONY_REQUIRE: "${{ matrix.symfony }}"

- name: 'Set Doctrine MySQL DSN (Linux)'
run: echo "DOCTRINE_DBAL_URL=pdo-mysql://root@127.0.0.1:3306/doctrine_tests?serverVersion=8.0" >> $GITHUB_ENV
run: echo "DOCTRINE_DBAL_URL=pdo-mysql://root@127.0.0.1:3306/doctrine_tests?serverVersion=8.0.35" >> $GITHUB_ENV
if: ${{ matrix.mysql && matrix.os == 'ubuntu-latest' }}

- name: 'Set Doctrine MySQL DSN (Windows)'
run: echo "DOCTRINE_DBAL_URL=pdo-mysql://root@127.0.0.1:3306/doctrine_tests?serverVersion=8.0" >> $env:GITHUB_ENV
run: echo "DOCTRINE_DBAL_URL=pdo-mysql://root@127.0.0.1:3306/doctrine_tests?serverVersion=8.0.35" >> $env:GITHUB_ENV
if: ${{ matrix.mysql && matrix.os == 'windows-latest' }}

- name: 'Run PHPUnit tests'
Expand Down
31 changes: 19 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,24 +32,31 @@ install.54:
symfony composer config minimum-stability dev
symfony composer update --ignore-platform-req=ext-mongodb

## Install - Install Symfony 6.0 deps
install.60: setup
install.60: export SYMFONY_REQUIRE = 6.0.*@dev
install.60:
## Install - Install Symfony 6.3 deps
install.63: setup
install.63: export SYMFONY_REQUIRE = 6.3.*@dev
install.63:
symfony composer config minimum-stability dev
symfony composer update --ignore-platform-req=ext-mongodb

## Install - Install Symfony 6.1 deps
install.61: setup
install.61: export SYMFONY_REQUIRE = 6.1.*@dev
install.61:
## Install - Install Symfony 6.4 deps
install.64: setup
install.64: export SYMFONY_REQUIRE = 6.4.*@dev
install.64:
symfony composer config minimum-stability dev
symfony composer update --ignore-platform-req=ext-mongodb

## Install - Install Symfony 6.2 deps
install.62: setup
install.62: export SYMFONY_REQUIRE = 6.2.*@dev
install.62:
## Install - Install Symfony 7.0 deps
install.70: setup
install.70: export SYMFONY_REQUIRE = 7.0.*@dev
install.70:
symfony composer config minimum-stability dev
symfony composer update --ignore-platform-req=ext-mongodb

## Install - Install Symfony 7.1 deps
install.71: setup
install.71: export SYMFONY_REQUIRE = 7.1.*@dev
install.71:
symfony composer config minimum-stability dev
symfony composer update --ignore-platform-req=ext-mongodb

Expand Down
25 changes: 13 additions & 12 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,17 @@
"doctrine/orm": "^2.10",
"phpstan/phpstan": "^1.10",
"phpstan/phpstan-symfony": "^1.2",
"symfony/browser-kit": "^5.4|^6.0",
"symfony/config": "^5.4|^6.0",
"symfony/dependency-injection": "^5.4.2|^6.0.1",
"symfony/filesystem": "^5.4|^6.0",
"symfony/form": "^5.4|^6.0",
"symfony/framework-bundle": "^5.4|^6.0",
"symfony/http-kernel": "^5.4.2|^6.0.1",
"symfony/phpunit-bridge": "^5.4|^6.0",
"symfony/translation": "^5.4|^6.0",
"symfony/var-dumper": "^5.4|^6.0",
"symfony/yaml": "^5.4|^6.0"
"symfony/browser-kit": "^5.4|^6.3|^7.0",
"symfony/config": "^5.4|^6.3|^7.0",
"symfony/dependency-injection": "^5.4.2|^6.3|^7.0",
"symfony/filesystem": "^5.4|^6.3|^7.0",
"symfony/form": "^5.4|^6.3|^7.0",
"symfony/framework-bundle": "^5.4|^6.3|^7.0",
"symfony/http-kernel": "^5.4.2|^6.3|^7.0",
"symfony/phpunit-bridge": "^5.4|^6.3|^7.0",
"symfony/translation": "^5.4|^6.3|^7.0",
"symfony/var-dumper": "^5.4|^6.3|^7.0",
"symfony/yaml": "^5.4|^6.3|^7.0"
},
"extra": {
"branch-alias": {
Expand All @@ -68,5 +68,6 @@
"*": "dist"
},
"sort-packages": true
}
},
"minimum-stability": "dev"
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

use Doctrine\DBAL\Platforms\AbstractMySQLPlatform;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Platforms\MySQLPlatform;
use Elao\Enum\Exception\LogicException;

/**
Expand All @@ -26,8 +27,14 @@ abstract class AbstractEnumSQLDeclarationType extends AbstractEnumType
*/
public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform): string
{
if (!$platform instanceof AbstractMySQLPlatform) {
throw new LogicException('SQL ENUM type is not supported on the current platform');
if (class_exists(AbstractMySQLPlatform::class)) {
if (!$platform instanceof AbstractMySQLPlatform) {
throw new LogicException('SQL ENUM type is not supported on the current platform');
}
} elseif (class_exists(MySQLPlatform::class)) {
if (!$platform instanceof MySQLPlatform) {
throw new LogicException('SQL ENUM type is not supported on the current platform');
}
}

$values = array_map(
Expand Down
19 changes: 11 additions & 8 deletions src/Bridge/Doctrine/DBAL/Types/AbstractEnumType.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,14 +95,17 @@ public function convertToPHPValue($value, AbstractPlatform $platform): ?\BackedE
*/
public function getSQLDeclaration(array $column, AbstractPlatform $platform): string
{
return $this->isIntBackedEnum()
? $platform->getIntegerTypeDeclarationSQL($column)
: (
method_exists($platform, 'getStringTypeDeclarationSQL') ?
$platform->getStringTypeDeclarationSQL($column) :
$platform->getVarcharTypeDeclarationSQL($column)
)
;
if ($this->isIntBackedEnum()) {
return $platform->getIntegerTypeDeclarationSQL($column);
}

if (empty($column['length'])) {
$column['length'] = 255;
}

return method_exists($platform, 'getStringTypeDeclarationSQL') ?
$platform->getStringTypeDeclarationSQL($column) :
$platform->getVarcharTypeDeclarationSQL($column);
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
framework:
router:
resource: '%kernel.project_dir%/config/routing-annotation.yaml'
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
framework:
annotations:
enabled: false
router:
resource: '%kernel.project_dir%/config/routing.yaml'
8 changes: 7 additions & 1 deletion tests/Fixtures/Integration/Symfony/config/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ framework:
secret: 'elao'
form: true
router:
resource: '%kernel.project_dir%/config/routing.yaml'
strict_requirements: '%kernel.debug%'
utf8: true
session:
handler_id: null
storage_factory_id: 'session.storage.factory.mock_file'
test: ~
assets: false
Expand Down Expand Up @@ -44,6 +44,12 @@ services:
App\Controller\QueryBodyBackedEnumValueResolverController:
autoconfigure: true
autowire: true
App\ControllerAnnotation\BackedEnumValueResolverController:
autoconfigure: true
autowire: true
App\ControllerAnnotation\QueryBodyBackedEnumValueResolverController:
autoconfigure: true
autowire: true

logger:
class: Psr\Log\NullLogger
Expand Down
4 changes: 4 additions & 0 deletions tests/Fixtures/Integration/Symfony/config/doctrine-new.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
doctrine:
orm:
report_fields_where_declared: true
enable_lazy_ghost_objects: true
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
controllers:
resource: ../src/ControllerAnnotation/
type: annotation
2 changes: 1 addition & 1 deletion tests/Fixtures/Integration/Symfony/config/routing.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
controllers:
resource: ../src/Controller/
type: annotation
type: attribute
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
use App\Enum\Suit;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Routing\Attribute\Route;
use Symfony\Component\VarDumper\Dumper\CliDumper;
use Symfony\Component\VarDumper\Test\VarDumperTestTrait;

Expand All @@ -30,19 +30,19 @@ public function __construct()
}

#[Route(path: '/from-attributes/{suit}')]
public function fromAttributes(Suit $suit)
public function fromAttributes(Suit $suit): Response
{
return new Response($this->getDump($suit));
}

#[Route(path: '/from-attributes-nullable/{suit}')]
public function fromAttributesNullable(?Suit $suit = null)
public function fromAttributesNullable(?Suit $suit = null): Response
{
return new Response($this->getDump($suit));
}

#[Route(path: '/from-attributes-with-default')]
public function fromAttributesWithDefault(Suit $suit = Suit::Spades)
public function fromAttributesWithDefault(Suit $suit = Suit::Spades): Response
{
return new Response($this->getDump($suit));
}
Expand Down
Loading

0 comments on commit bd65e9e

Please sign in to comment.