From 3ea49f4ef61fbbd43a837e6a13b1d09e24a7365f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Letord?= Date: Wed, 19 Mar 2025 09:44:14 +0100 Subject: [PATCH 1/2] Improve sf6 compatibility --- .coveralls.yml | 3 --- .travis.yml | 25 ------------------- Resources/config/services.xml | 1 + .../Proxy/Impl/UseCaseProxyFactoryImpl.php | 14 +++-------- 4 files changed, 5 insertions(+), 38 deletions(-) delete mode 100644 .coveralls.yml delete mode 100644 .travis.yml diff --git a/.coveralls.yml b/.coveralls.yml deleted file mode 100644 index 9320fb2..0000000 --- a/.coveralls.yml +++ /dev/null @@ -1,3 +0,0 @@ -service_name: travis-ci -src_dir: ./ -coverage_clover: build/logs/clover.xml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index d253dd9..0000000 --- a/.travis.yml +++ /dev/null @@ -1,25 +0,0 @@ -language: php - -php: - - "7.1" - - "7.3" - -env: - - SYMFONY_VERSION=3.4.* - - SYMFONY_VERSION=4.3.* - -before_script: - - composer self-update - - if [ "$SYMFONY_VERSION" != "" ]; then composer require "symfony/dependency-injection:${SYMFONY_VERSION}" --no-update; fi; - - if [ "$SYMFONY_VERSION" != "" ]; then composer require "symfony/config:${SYMFONY_VERSION}" --no-update; fi; - - if [ "$SYMFONY_VERSION" != "" ]; then composer require "symfony/http-kernel:${SYMFONY_VERSION}" --no-update; fi; - - if [ "$SYMFONY_VERSION" != "" ]; then composer require "symfony/security:${SYMFONY_VERSION}" --no-update; fi; - - if [ "$SYMFONY_VERSION" != "" ]; then composer require "symfony/event-dispatcher:${SYMFONY_VERSION}" --no-update; fi; - - composer install --no-scripts --no-interaction --dev - - composer dump-autoload -o - -after_script: - - php vendor/bin/coveralls -v - -script: - - ./vendor/bin/phpunit --coverage-clover build/logs/clover.xml diff --git a/Resources/config/services.xml b/Resources/config/services.xml index e7cec74..f297e83 100644 --- a/Resources/config/services.xml +++ b/Resources/config/services.xml @@ -7,6 +7,7 @@ + diff --git a/Services/Proxy/Impl/UseCaseProxyFactoryImpl.php b/Services/Proxy/Impl/UseCaseProxyFactoryImpl.php index bff305f..0af9534 100644 --- a/Services/Proxy/Impl/UseCaseProxyFactoryImpl.php +++ b/Services/Proxy/Impl/UseCaseProxyFactoryImpl.php @@ -48,7 +48,9 @@ class UseCaseProxyFactoryImpl implements UseCaseProxyFactory */ private $builder; - public function __construct() + public function __construct( + private readonly AuthorizationCheckerInterface $authorizationChecker + ) { $this->builder = new UseCaseProxyBuilderImpl(); } @@ -114,15 +116,7 @@ private function buildSecurity(array $tagParameters) if (isset($tagParameters['security'])) { $security = $this->container->get($tagParameters['security']); } else { - $defaultSecurityContextId = $this->container->getParameter( - 'openclassrooms.use_case.default_authorization_checker' - ); - if (!$this->container->has($defaultSecurityContextId)) { - throw new SecurityIsNotDefinedException('Default security context: \''.$defaultSecurityContextId.'\' is not defined.'); - } - $security = $this->container->get( - $this->container->getParameter('openclassrooms.use_case.default_authorization_checker') - ); + $security = $this->authorizationChecker; } if ($security instanceof AuthorizationCheckerInterface) { /** @var SecurityFactory $securityFactory */ From 3bc0b85f4848e47c4f04e58b83012432e29a54bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Letord?= Date: Wed, 19 Mar 2025 09:52:03 +0100 Subject: [PATCH 2/2] Adapt test --- .../Fixtures/Resources/config/services.xml | 1 + ...rityOpenClassroomsUseCaseExtensionTest.php | 26 ------------------- 2 files changed, 1 insertion(+), 26 deletions(-) diff --git a/Tests/DependencyInjection/Fixtures/Resources/config/services.xml b/Tests/DependencyInjection/Fixtures/Resources/config/services.xml index 8e945b7..f408055 100644 --- a/Tests/DependencyInjection/Fixtures/Resources/config/services.xml +++ b/Tests/DependencyInjection/Fixtures/Resources/config/services.xml @@ -16,6 +16,7 @@ OpenClassrooms\Bundle\UseCaseBundle\Tests\DependencyInjection\Fixtures\BusinessRules\UseCases\EventUseCaseStub + diff --git a/Tests/DependencyInjection/SecurityOpenClassroomsUseCaseExtensionTest.php b/Tests/DependencyInjection/SecurityOpenClassroomsUseCaseExtensionTest.php index fd159a6..f911415 100644 --- a/Tests/DependencyInjection/SecurityOpenClassroomsUseCaseExtensionTest.php +++ b/Tests/DependencyInjection/SecurityOpenClassroomsUseCaseExtensionTest.php @@ -11,32 +11,6 @@ */ class SecurityOpenClassroomsUseCaseExtensionTest extends AbstractDependencyInjectionTestCase { - /** - * @test - */ - public function WithSecurityConfigurationWithoutSecurityContext_SecurityUseCase_ThrowException() - { - $this->expectException(SecurityIsNotDefinedException::class); - - $this->configLoader->load('SecurityConfiguration.php'); - $this->container->compile(); - - $this->container->get('openclassrooms.tests.use_cases.configuration_security_use_case_stub'); - } - - /** - * @test - */ - public function WithDefaultConfigurationWithoutSecurityContext_SecurityUseCase_ThrowException() - { - $this->expectException(SecurityIsNotDefinedException::class); - - $this->configLoader->load('DefaultConfiguration.php'); - $this->container->compile(); - - $this->container->get('openclassrooms.tests.use_cases.configuration_security_use_case_stub'); - } - /** * @test */