Skip to content

Commit

Permalink
SUPPORT-86535 - add symfony 6 support
Browse files Browse the repository at this point in the history
  • Loading branch information
Yuri Gaidoba committed Nov 23, 2023
1 parent 136dc06 commit 0b6b29c
Show file tree
Hide file tree
Showing 21 changed files with 293 additions and 37 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ jobs:
# { php-version: '8.0', symfony-version: '5.4.*', dependency-versions: 'latest' },
# { php-version: '8.1', symfony-version: '5.4.*', dependency-versions: 'lowest' },
# { php-version: '8.1', symfony-version: '5.4.*', dependency-versions: 'latest' },
{ php-version: '8.1', symfony-version: '6.4.*', dependency-versions: 'lowest' },
{ php-version: '8.1', symfony-version: '6.4.*', dependency-versions: 'latest' },
]
steps:
- name: Checkout
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ composer.lock
bin/
var/
!bin/update-constraints-to-lowest.php

.phpunit.result.cache
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.7.0]
### Added
- Support for Symfony 6.4

### Changed
- Fixed code style
- Fixed tests

## [1.6.0]
### Added
- Allow library to work with various version of `paysera/lib-object-wrapper` from `0.1.0`
Expand Down
18 changes: 11 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"name": "paysera/lib-api-bundle",
"version": "1.7.0",
"description": "Symfony bundle that allows easy configuration for your REST endpoints.",
"keywords": ["REST", "RESTful", "API"],
"type": "symfony-bundle",
Expand All @@ -17,9 +18,9 @@
"require": {
"php": "^7.1 || ^8.0",
"ext-json": "*",
"symfony/framework-bundle": "^3.4.34|^4.3|^5.4",
"symfony/security-bundle": "^3.4.34|^4.3|^5.4",
"symfony/validator": "^3.4.34|^4.3|^5.4",
"symfony/framework-bundle": "^3.4.34|^4.3|^5.4|^6.0",
"symfony/security-bundle": "^3.4.34|^4.3|^5.4|^6.0",
"symfony/validator": "^3.4.34|^4.3|^5.4|^6.0",
"paysera/lib-normalization-bundle": "^1.1.0",
"paysera/lib-normalization": "^1.2",
"paysera/lib-object-wrapper": "~0.1",
Expand All @@ -31,13 +32,16 @@
"require-dev": {
"phpunit/phpunit": "^6.5 || ^9.0",
"mockery/mockery": "^1.2.4",
"symfony/yaml": "^3.4.34|^4.3|^5.4",
"doctrine/doctrine-bundle": "^1.7.2|^2.0",
"symfony/yaml": "^3.4.34|^4.3|^5.4|^6.0",
"doctrine/doctrine-bundle": "^1.12.0|^2.1",
"doctrine/orm": "~2.5.14|^2.6.3",
"doctrine/annotations": "^v1.7"
"doctrine/annotations": "^v1.14"
},
"config": {
"bin-dir": "bin"
"bin-dir": "bin",
"allow-plugins": {
"ocramius/package-versions": false
}
},
"scripts": {
"phpunit": "phpunit",
Expand Down
2 changes: 1 addition & 1 deletion phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
convertWarningsToExceptions = "true"
processIsolation = "false"
stopOnFailure = "false"
bootstrap = "vendor/autoload.php" >
bootstrap = "tests/bootstrap.php" >

<testsuites>
<testsuite name="Project Test Suite">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Symfony\Component\Config\FileLocator;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
use Symfony\Component\DependencyInjection\Loader;
use Symfony\Component\HttpKernel\Kernel;

/**
* This is the class that loads and manages your bundle configuration.
Expand All @@ -24,7 +25,8 @@ public function load(array $configs, ContainerBuilder $container)
$config = $this->processConfiguration($configuration, $configs);

$loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
$loader->load('services.xml');
$prefix = Kernel::MAJOR_VERSION <= 4 ? 'legacy_' : '';
$loader->load($prefix . 'services.xml');

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?xml version="1.0" encoding="UTF-8" ?>

<routes xmlns="http://symfony.com/schema/routing"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/routing http://symfony.com/schema/routing/routing-1.0.xsd">

<import resource="../../Controller/" type="annotation"/>

<route id="paysera_fixture_test_1" path="/config/by-full-controller">
<default key="_controller">PayseraFixtureTestBundle:Default:action1</default>
</route>
<route id="paysera_fixture_test_1b" path="/config/by-full-controller-and-class-name">
<default key="_controller">PayseraFixtureTestBundle:Default:action1b</default>
</route>
<route id="paysera_fixture_test_2" path="/config/by-class-name">
<default key="_controller">Paysera\Bundle\ApiBundle\Tests\Functional\Fixtures\FixtureTestBundle\Controller\DefaultController::action2</default>
</route>
<route id="paysera_fixture_test_3" path="/config/by-service-name">
<default key="_controller">paysera_fixture_test.controller.default_controller:action3</default>
</route>
<route id="paysera_fixture_test_4" path="/config/routing-by-service-name-config-by-class-name">
<default key="_controller">paysera_fixture_test.controller.default_controller:action4</default>
</route>
<route id="paysera_fixture_test_5" path="/config/routing-by-class-name-config-by-service-name">
<default key="_controller">Paysera\Bundle\ApiBundle\Tests\Functional\Fixtures\FixtureTestBundle\Controller\DefaultController::action5</default>
</route>

<route id="paysera_fixture_test" path="/">
<default key="_controller">paysera_fixture_test.controller.default_controller:action</default>
</route>
<route id="paysera_fixture_test_with_return" path="/with-return">
<default key="_controller">paysera_fixture_test.controller.default_controller:actionWithReturn</default>
</route>
<route id="paysera_fixture_test_with_url_parameter" path="/with-url-parameter/{urlParameter}">
<default key="_controller">paysera_fixture_test.controller.default_controller:action</default>
</route>
<route id="paysera_fixture_test_with_several_url_parameters" path="/with-url-parameters/{urlParameter1}/{urlParameter2}">
<default key="_controller">paysera_fixture_test.controller.default_controller:actionWithMultipleParameters</default>
</route>
<route id="paysera_fixture_test_with_several_parameters" path="/with-parameters">
<default key="_controller">paysera_fixture_test.controller.default_controller:actionWithMultipleParameters</default>
</route>
</routes>
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
<?xml version="1.0" ?>

<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">

<services>
<service class="Paysera\Bundle\ApiBundle\Tests\Functional\Fixtures\FixtureTestBundle\Controller\DefaultController"
id="paysera_fixture_test.controller.default_controller"
public="true"/>

<service id="paysera_fixture_test.normalizer.item_denormalizer.parameter"
class="Paysera\Bundle\ApiBundle\Tests\Functional\Fixtures\FixtureTestBundle\Normalizer\ItemDenormalizer">
<tag name="paysera_normalization.object_denormalizer" type="extract:parameter"/>
<argument>parameter</argument>
</service>
<service id="paysera_fixture_test.normalizer.item_denormalizer.parameter.custom"
class="Paysera\Bundle\ApiBundle\Tests\Functional\Fixtures\FixtureTestBundle\Normalizer\ItemDenormalizer">
<tag name="paysera_normalization.object_denormalizer" type="extract:parameter" group="custom"/>
<argument>parameter_custom</argument>
</service>
<service id="paysera_fixture_test.normalizer.item_denormalizer.key"
class="Paysera\Bundle\ApiBundle\Tests\Functional\Fixtures\FixtureTestBundle\Normalizer\ItemDenormalizer">
<tag name="paysera_normalization.object_denormalizer" type="extract:key"/>
<argument>key</argument>
</service>
<service id="paysera_fixture_test.normalizer.item_denormalizer.key.custom"
class="Paysera\Bundle\ApiBundle\Tests\Functional\Fixtures\FixtureTestBundle\Normalizer\ItemDenormalizer">
<tag name="paysera_normalization.object_denormalizer" type="extract:key" group="custom"/>
<argument>key_custom</argument>
</service>
<service id="Paysera\Bundle\ApiBundle\Tests\Functional\Fixtures\FixtureTestBundle\Normalizer\PrefixedDenormalizer">
<tag name="paysera_normalization.mixed_type_denormalizer"/>
</service>
<service id="Paysera\Bundle\ApiBundle\Tests\Functional\Fixtures\FixtureTestBundle\Normalizer\MyObjectNormalizer">
<tag name="paysera_normalization.object_denormalizer"/>
<tag name="paysera_normalization.normalizer"/>
</service>
<service id="Paysera\Bundle\ApiBundle\Tests\Functional\Fixtures\FixtureTestBundle\Normalizer\MyObjectCustomNormalizer">
<tag name="paysera_normalization.object_denormalizer" type="my_object_custom"/>
<tag name="paysera_normalization.normalizer" type="my_object_custom"/>
<tag name="paysera_normalization.normalizer"
type="Paysera\Bundle\ApiBundle\Tests\Functional\Fixtures\FixtureTestBundle\Entity\MyObject"
group="custom"/>
</service>
<service id="Paysera\Bundle\ApiBundle\Tests\Functional\Fixtures\FixtureTestBundle\Normalizer\PersistedEntityFilterDenormalizer">
<tag name="paysera_normalization.object_denormalizer"/>
</service>
<service id="Paysera\Bundle\ApiBundle\Tests\Functional\Fixtures\FixtureTestBundle\Normalizer\PersistedEntityNormalizer">
<tag name="paysera_normalization.normalizer"/>
</service>

<service id="paysera_fixture_test.rest_request_options.1"
class="Paysera\Bundle\ApiBundle\Entity\RestRequestOptions">
<tag name="paysera_api.request_options" controller="PayseraFixtureTestBundle:Default:action1"/>
<tag name="paysera_api.request_options"
controller="Paysera\Bundle\ApiBundle\Tests\Functional\Fixtures\FixtureTestBundle\Controller\DefaultController::action1bAction"/>
<tag name="paysera_api.request_options"
controller="Paysera\Bundle\ApiBundle\Tests\Functional\Fixtures\FixtureTestBundle\Controller\DefaultController::action2"/>
<tag name="paysera_api.request_options" controller="paysera_fixture_test.controller.default_controller:action3"/>
<tag name="paysera_api.request_options"
controller="Paysera\Bundle\ApiBundle\Tests\Functional\Fixtures\FixtureTestBundle\Controller\DefaultController::action4"/>
<tag name="paysera_api.request_options" controller="paysera_fixture_test.controller.default_controller::action5"/>

<call method="addQueryResolverOptions">
<argument type="service">
<service class="Paysera\Bundle\ApiBundle\Entity\QueryResolverOptions">
<call method="setDenormalizationType">
<argument>extract:parameter</argument>
</call>
<call method="setParameterName">
<argument>parameter</argument>
</call>
</service>
</argument>
</call>
</service>

<service id="Paysera\Bundle\ApiBundle\Tests\Functional\Fixtures\FixtureTestBundle\Controller\AnnotatedController"
public="true"/>
<service id="Paysera\Bundle\ApiBundle\Tests\Functional\Fixtures\FixtureTestBundle\Controller\AnnotatedClassRequiredPermissionsController"
public="true"/>
<service id="Paysera\Bundle\ApiBundle\Tests\Functional\Fixtures\FixtureTestBundle\Controller\AnnotatedClassValidationController"
public="true"/>
<service id="Paysera\Bundle\ApiBundle\Tests\Functional\Fixtures\FixtureTestBundle\Controller\PagedQueryController"
public="true">
<argument type="service" id="doctrine.orm.entity_manager"/>
</service>

<service id="Paysera\Bundle\ApiBundle\Tests\Functional\Fixtures\FixtureTestBundle\PathAttributeResolver\PrefixedPathAttributeResolver">
<tag name="paysera_api.path_attribute_resolver" type="prefixed"/>
</service>
<service id="Paysera\Bundle\ApiBundle\Tests\Functional\Fixtures\FixtureTestBundle\PathAttributeResolver\MyObjectResolver">
<tag name="paysera_api.path_attribute_resolver" type="my_object_resolver"/>
<tag name="paysera_api.path_attribute_resolver"
type="Paysera\Bundle\ApiBundle\Tests\Functional\Fixtures\FixtureTestBundle\Entity\MyObject"/>
</service>
<service id="Paysera\Bundle\ApiBundle\Tests\Functional\Fixtures\FixtureTestBundle\PathAttributeResolver\NullResolver">
<tag name="paysera_api.path_attribute_resolver" type="always_null"/>
</service>
</services>
</container>
Original file line number Diff line number Diff line change
@@ -1,43 +1,51 @@
<?xml version="1.0" encoding="UTF-8" ?>

<routes xmlns="http://symfony.com/schema/routing"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/routing http://symfony.com/schema/routing/routing-1.0.xsd">
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/routing http://symfony.com/schema/routing/routing-1.0.xsd">

<import resource="../../Controller/" type="annotation"/>

<route id="paysera_fixture_test_1" path="/config/by-full-controller">
<default key="_controller">PayseraFixtureTestBundle:Default:action1</default>
<default key="_controller">Paysera\Bundle\ApiBundle\Tests\Functional\Fixtures\FixtureTestBundle\Controller\DefaultController::action1Action</default>
</route>
<route id="paysera_fixture_test_1b" path="/config/by-full-controller-and-class-name">
<default key="_controller">PayseraFixtureTestBundle:Default:action1b</default>
<default key="_controller">
Paysera\Bundle\ApiBundle\Tests\Functional\Fixtures\FixtureTestBundle\Controller\DefaultController::action1bAction
</default>
</route>
<route id="paysera_fixture_test_2" path="/config/by-class-name">
<default key="_controller">Paysera\Bundle\ApiBundle\Tests\Functional\Fixtures\FixtureTestBundle\Controller\DefaultController::action2</default>
<default key="_controller">
Paysera\Bundle\ApiBundle\Tests\Functional\Fixtures\FixtureTestBundle\Controller\DefaultController::action2
</default>
</route>
<route id="paysera_fixture_test_3" path="/config/by-service-name">
<default key="_controller">paysera_fixture_test.controller.default_controller:action3</default>
<default key="_controller">paysera_fixture_test.controller.default_controller::action3</default>
</route>
<route id="paysera_fixture_test_4" path="/config/routing-by-service-name-config-by-class-name">
<default key="_controller">paysera_fixture_test.controller.default_controller:action4</default>
<default key="_controller">paysera_fixture_test.controller.default_controller::action4</default>
</route>
<route id="paysera_fixture_test_5" path="/config/routing-by-class-name-config-by-service-name">
<default key="_controller">Paysera\Bundle\ApiBundle\Tests\Functional\Fixtures\FixtureTestBundle\Controller\DefaultController::action5</default>
<default key="_controller">
Paysera\Bundle\ApiBundle\Tests\Functional\Fixtures\FixtureTestBundle\Controller\DefaultController::action5
</default>
</route>

<route id="paysera_fixture_test" path="/">
<default key="_controller">paysera_fixture_test.controller.default_controller:action</default>
<default key="_controller">paysera_fixture_test.controller.default_controller::action</default>
</route>
<route id="paysera_fixture_test_with_return" path="/with-return">
<default key="_controller">paysera_fixture_test.controller.default_controller:actionWithReturn</default>
<default key="_controller">paysera_fixture_test.controller.default_controller::actionWithReturn</default>
</route>
<route id="paysera_fixture_test_with_url_parameter" path="/with-url-parameter/{urlParameter}">
<default key="_controller">paysera_fixture_test.controller.default_controller:action</default>
<default key="_controller">
Paysera\Bundle\ApiBundle\Tests\Functional\Fixtures\FixtureTestBundle\Controller\DefaultController::action
</default>
</route>
<route id="paysera_fixture_test_with_several_url_parameters" path="/with-url-parameters/{urlParameter1}/{urlParameter2}">
<default key="_controller">paysera_fixture_test.controller.default_controller:actionWithMultipleParameters</default>
<default key="_controller">paysera_fixture_test.controller.default_controller::actionWithMultipleParameters</default>
</route>
<route id="paysera_fixture_test_with_several_parameters" path="/with-parameters">
<default key="_controller">paysera_fixture_test.controller.default_controller:actionWithMultipleParameters</default>
<default key="_controller">paysera_fixture_test.controller.default_controller::actionWithMultipleParameters</default>
</route>
</routes>
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@
controller="Paysera\Bundle\ApiBundle\Tests\Functional\Fixtures\FixtureTestBundle\Controller\DefaultController::action1bAction"/>
<tag name="paysera_api.request_options"
controller="Paysera\Bundle\ApiBundle\Tests\Functional\Fixtures\FixtureTestBundle\Controller\DefaultController::action2"/>
<tag name="paysera_api.request_options" controller="paysera_fixture_test.controller.default_controller:action3"/>
<tag name="paysera_api.request_options" controller="paysera_fixture_test.controller.default_controller::action3"/>
<tag name="paysera_api.request_options"
controller="Paysera\Bundle\ApiBundle\Tests\Functional\Fixtures\FixtureTestBundle\Controller\DefaultController::action4"/>
<tag name="paysera_api.request_options" controller="paysera_fixture_test.controller.default_controller:action5"/>
<tag name="paysera_api.request_options" controller="paysera_fixture_test.controller.default_controller::action5"/>

<call method="addQueryResolverOptions">
<argument type="service">
Expand Down
2 changes: 1 addition & 1 deletion tests/Functional/Fixtures/TestKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function __construct($testCase, $commonFile = 'common.yml')
$this->commonFile = $commonFile;
}

public function registerBundles()
public function registerBundles(): iterable
{
return [
new FrameworkBundle(),
Expand Down
11 changes: 7 additions & 4 deletions tests/Functional/Fixtures/config/common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,15 @@ security:
password: pass
roles: ['ROLE_USER', 'ROLE_ADMIN']
firewalls:
config:
pattern: ^/(config)/
security: false
main:
anonymous: true
http_basic: ~
stateless: true
encoders:
Symfony\Component\Security\Core\User\User: plaintext
password_hashers:
Symfony\Component\Security\Core\User\InMemoryUser:
algorithm: plaintext

doctrine:
orm:
Expand All @@ -33,7 +36,7 @@ doctrine:

services:
logger:
class: Symfony\Component\Debug\BufferingLogger
class: Symfony\Component\ErrorHandler\BufferingLogger
public: true
rest_registry:
alias: paysera_api.rest_request_options_registry
Expand Down
Loading

0 comments on commit 0b6b29c

Please sign in to comment.