From dd5ae56d68bc3f3af10359cc5ebd35ea5dabc155 Mon Sep 17 00:00:00 2001 From: Mario Fehr <14167832+mario-fehr@users.noreply.github.com> Date: Mon, 3 Oct 2022 22:12:29 +0200 Subject: [PATCH] Add support for symfony 6 (#223) Co-authored-by: Alexander Schranz --- .github/workflows/test-application.yaml | 45 +++++++++++++++---- Tests/Application/Kernel.php | 4 +- Tests/Application/config/config.yml | 4 +- Tests/Application/config/routing_admin.yml | 2 +- .../Doctrine/CategoryFactoryTest.php | 2 +- .../DimensionContentRepositoryTest.php | 2 +- .../Doctrine/TagFactoryTest.php | 6 +-- composer.json | 45 +++++++++---------- phpunit.xml.dist | 4 ++ 9 files changed, 72 insertions(+), 42 deletions(-) diff --git a/.github/workflows/test-application.yaml b/.github/workflows/test-application.yaml index 262ed179..27477afd 100644 --- a/.github/workflows/test-application.yaml +++ b/.github/workflows/test-application.yaml @@ -9,7 +9,7 @@ on: jobs: test: - name: 'PHP ${{ matrix.php-version }} (${{ matrix.dependency-versions }}, Lint ${{ matrix.lint }}, Coverage ${{ matrix.coverage }})' + name: 'PHP ${{ matrix.php-version }} (${{ matrix.dependency-versions }}, Coverage ${{ matrix.coverage }})' runs-on: ubuntu-latest env: @@ -22,7 +22,6 @@ jobs: matrix: include: - php-version: '7.2' - lint: false coverage: false dependency-versions: 'lowest' tools: 'composer:v1' @@ -30,7 +29,6 @@ jobs: SYMFONY_DEPRECATIONS_HELPER: disabled - php-version: '7.4' - lint: true coverage: true dependency-versions: 'highest' tools: 'composer:v2' @@ -38,13 +36,18 @@ jobs: SYMFONY_DEPRECATIONS_HELPER: weak - php-version: '8.0' - lint: false coverage: false dependency-versions: 'highest' tools: 'composer:v2' env: SYMFONY_DEPRECATIONS_HELPER: weak + - php-version: '8.1' + coverage: false + dependency-versions: 'highest' + env: + SYMFONY_DEPRECATIONS_HELPER: weak + services: mysql: image: mysql:5.7 @@ -67,7 +70,7 @@ jobs: tools: ${{ matrix.tools }} - name: Install composer dependencies - uses: ramsey/composer-install@v1 + uses: ramsey/composer-install@v2 with: dependency-versions: ${{ matrix.dependency-versions }} composer-options: ${{ matrix.composer-options }} @@ -75,10 +78,6 @@ jobs: - name: Bootstrap test environment run: composer bootstrap-test-environment - - name: Lint Code - if: ${{ matrix.lint }} - run: composer lint - - name: Execute test cases if: matrix.coverage == false run: composer test @@ -98,3 +97,31 @@ jobs: - name: Check code coverage if: ${{ matrix.coverage }} run: composer check-coverage + + lint: + name: 'PHP Lint' + runs-on: ubuntu-latest + + env: + DATABASE_URL: mysql://root:root@127.0.0.1:3306/su_headless_test?serverVersion=5.7 + DATABASE_CHARSET: utf8mb4 + DATABASE_COLLATE: utf8mb4_unicode_ci + + steps: + - name: Checkout project + uses: actions/checkout@v2 + + - name: Install and configure PHP + uses: shivammathur/setup-php@v2 + with: + php-version: '7.4' + extensions: ctype, iconv, mysql + tools: 'composer:v2' + + - name: Install composer dependencies + uses: ramsey/composer-install@v2 + with: + dependency-versions: 'highest' + + - name: Lint Code + run: composer lint diff --git a/Tests/Application/Kernel.php b/Tests/Application/Kernel.php index 0f82fc54..25dc0d70 100644 --- a/Tests/Application/Kernel.php +++ b/Tests/Application/Kernel.php @@ -23,7 +23,7 @@ class Kernel extends SuluTestKernel { - public function registerBundles() + public function registerBundles(): iterable { $bundles = parent::registerBundles(); $bundles[] = new SuluContentBundle(); @@ -49,7 +49,7 @@ public function registerContainerConfiguration(LoaderInterface $loader) $loader->load(__DIR__ . '/config/config_' . $this->getContext() . '.yml'); } - protected function getKernelParameters() + protected function getKernelParameters(): array { $parameters = parent::getKernelParameters(); diff --git a/Tests/Application/config/config.yml b/Tests/Application/config/config.yml index 8180da20..0e0f8754 100644 --- a/Tests/Application/config/config.yml +++ b/Tests/Application/config/config.yml @@ -1,5 +1,5 @@ -swiftmailer: - disable_delivery: true +framework: + profiler: { enabled: true, collect: false } doctrine: orm: diff --git a/Tests/Application/config/routing_admin.yml b/Tests/Application/config/routing_admin.yml index b5d5d280..0ff04a87 100644 --- a/Tests/Application/config/routing_admin.yml +++ b/Tests/Application/config/routing_admin.yml @@ -1,7 +1,7 @@ # FosJsRoutingBundle fos_js_routing: prefix: /admin - resource: "@FOSJsRoutingBundle/Resources/config/routing/routing.xml" + resource: "@FOSJsRoutingBundle/Resources/config/routing/routing-sf4.xml" # Sulu sulu_tag_api: diff --git a/Tests/Functional/Content/Infrastructure/Doctrine/CategoryFactoryTest.php b/Tests/Functional/Content/Infrastructure/Doctrine/CategoryFactoryTest.php index 1760ea88..05db026e 100644 --- a/Tests/Functional/Content/Infrastructure/Doctrine/CategoryFactoryTest.php +++ b/Tests/Functional/Content/Infrastructure/Doctrine/CategoryFactoryTest.php @@ -27,7 +27,7 @@ protected function setUp(): void public function createCategoryFactory(): CategoryFactoryInterface { - return self::$container->get('sulu_content.category_factory'); + return self::getContainer()->get('sulu_content.category_factory'); } /** diff --git a/Tests/Functional/Content/Infrastructure/Doctrine/DimensionContentRepositoryTest.php b/Tests/Functional/Content/Infrastructure/Doctrine/DimensionContentRepositoryTest.php index 134325ed..b45d2703 100644 --- a/Tests/Functional/Content/Infrastructure/Doctrine/DimensionContentRepositoryTest.php +++ b/Tests/Functional/Content/Infrastructure/Doctrine/DimensionContentRepositoryTest.php @@ -29,7 +29,7 @@ protected function setUp(): void public function createContentDimensionRepository(): DimensionContentRepositoryInterface { - return self::$container->get('sulu_content.dimension_content_repository'); + return self::getContainer()->get('sulu_content.dimension_content_repository'); } public function testLoadExistAll(): void diff --git a/Tests/Functional/Content/Infrastructure/Doctrine/TagFactoryTest.php b/Tests/Functional/Content/Infrastructure/Doctrine/TagFactoryTest.php index 2c36a8e2..e3764601 100644 --- a/Tests/Functional/Content/Infrastructure/Doctrine/TagFactoryTest.php +++ b/Tests/Functional/Content/Infrastructure/Doctrine/TagFactoryTest.php @@ -31,7 +31,7 @@ protected function setUp(): void self::bootKernel(); self::purgeDatabase(); - $this->tagFactory = self::$container->get('sulu_content.tag_factory'); + $this->tagFactory = self::getContainer()->get('sulu_content.tag_factory'); } /** @@ -72,7 +72,7 @@ public function testCreateSameTagTwiceWithOtherEntityInUnitOfWork(): void $this->getEntityManager()->persist($this->createOtherEntity()); /** @var TagRepositoryInterface $tagRepository */ - $tagRepository = self::$container->get('sulu.repository.tag'); + $tagRepository = self::getContainer()->get('sulu.repository.tag'); $tag = $tagRepository->createNew(); $tag->setName('Other Tag'); $this->getEntityManager()->persist($tag); @@ -138,7 +138,7 @@ public function dataProvider(): \Generator private function createTags(array $existTagNames = []): void { /** @var TagRepositoryInterface $tagRepository */ - $tagRepository = self::$container->get('sulu.repository.tag'); + $tagRepository = self::getContainer()->get('sulu.repository.tag'); foreach ($existTagNames as $existTagName) { $existTag = $tagRepository->createNew(); diff --git a/composer.json b/composer.json index f20e8e7f..5c3d5ec0 100644 --- a/composer.json +++ b/composer.json @@ -19,47 +19,47 @@ "doctrine/doctrine-bundle": "^1.10 || ^2.0", "friendsofsymfony/rest-bundle": "^2.6 || ^3.0", "massive/search-bundle": "^2.4", - "ramsey/uuid": "^3.8", - "sulu/sulu": "^2.1 || ^2.3@dev", - "symfony/config": "^4.4 || ^5.0", - "symfony/dependency-injection": "^4.4 || ^5.0", - "symfony/event-dispatcher": "^4.4 || ^5.0", - "symfony/http-foundation": "^4.4 || ^5.0", - "symfony/http-kernel": "^4.4 || ^5.0", - "symfony/options-resolver": "^4.4 || ^5.0", - "symfony/property-access": "^4.4 || ^5.0", - "symfony/security-core": "^4.4 || ^5.0", - "symfony/serializer": "^4.4 || ^5.0", - "symfony/translation-contracts": "^1.0 || ^2.0", - "symfony/workflow": "^4.4 || ^5.0", + "ramsey/uuid": "^3.8 || ^4.0", + "sulu/sulu": "^2.1 || ^2.6@dev", + "symfony/config": "^4.4 || ^5.4 || ^6.0", + "symfony/dependency-injection": "^4.4 || ^5.4 || ^6.0", + "symfony/event-dispatcher": "^4.4 || ^5.4 || ^6.0", + "symfony/http-foundation": "^4.4 || ^5.4 || ^6.0", + "symfony/http-kernel": "^4.4 || ^5.4 || ^6.0", + "symfony/options-resolver": "^4.4 || ^5.4 || ^6.0", + "symfony/property-access": "^4.4 || ^5.4 || ^6.0", + "symfony/security-core": "^4.4 || ^5.4 || ^6.0", + "symfony/serializer": "^4.4 || ^5.4 || ^6.0", + "symfony/translation-contracts": "^1.0 || ^2.0 || ^3.0", + "symfony/workflow": "^4.4 || ^5.4 || ^6.0", "webmozart/assert": "^1.3" }, "require-dev": { "coduo/php-matcher": "^3.2 || ^4.0 || ^5.0 || ^6.0", "doctrine/data-fixtures": "^1.3.3", "doctrine/doctrine-fixtures-bundle": "^2.0 || ^3.0", - "friendsofphp/php-cs-fixer": "^2.17", + "friendsofphp/php-cs-fixer": "^2.17 || ^3.0", "handcraftedinthealps/code-coverage-checker": "^0.2.1", "handcraftedinthealps/zendsearch": "^2.0", "jackalope/jackalope-doctrine-dbal": "^1.3.4", "jangregor/phpstan-prophecy": "^0.8", "matthiasnoback/symfony-config-test": "^4.0", "matthiasnoback/symfony-dependency-injection-test": "^4.0", + "phpspec/prophecy": "^1.14", "phpstan/phpstan": "^0.12", "phpstan/phpstan-doctrine": "^0.12", "phpstan/phpstan-phpunit": "^0.12", "phpstan/phpstan-symfony": "^0.12", "phpstan/phpstan-webmozart-assert": "^0.12", - "qossmic/deptrac-shim": "^0.11.1", + "qossmic/deptrac-shim": "^0.11.1 || ^0.23.0", "sulu/automation-bundle": "^2.0@dev", - "symfony/browser-kit": "^4.4 || ^5.0", - "symfony/console": "^4.4 || ^5.0", - "symfony/debug": "^4.4", - "symfony/dotenv": "^4.4 || ^5.0", - "symfony/framework-bundle": "^4.4 || ^5.0", + "symfony/browser-kit": "^4.4 || ^5.4 || ^6.0", + "symfony/console": "^4.4 || ^5.4 || ^6.0", + "symfony/dotenv": "^4.4 || ^5.4 || ^6.0", + "symfony/framework-bundle": "^4.4 || ^5.4 || ^6.0", "symfony/monolog-bundle": "^3.1", - "symfony/phpunit-bridge": "^5.2", - "symfony/string": "^4.4 || ^5.0", + "symfony/phpunit-bridge": "^5.4 || ^6.0", + "symfony/string": "^4.4 || ^5.4 || ^6.0", "thecodingmachine/phpstan-strict-rules": "^0.12" }, "conflict": { @@ -106,7 +106,6 @@ "check-coverage": [ "@php vendor/bin/code-coverage-checker \"Tests/reports/coverage.php\" \"line\" \"100.00\" \"Content\" \"DependencyInjection\"" ], - "deptract": "vendor/bin/deptrac", "phpstan": [ "Tests/Application/bin/adminconsole cache:warmup --env dev", "@test install", diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 49d56651..5e204c74 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -31,4 +31,8 @@ + + + +