diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 82ad637..3da3bf8 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -2,6 +2,8 @@ name: Build on: push: + branches: + - master pull_request: types: [opened, synchronize, edited, reopened] release: @@ -13,8 +15,7 @@ on: jobs: test: name: PHP ${{ matrix.php-version }} + Symfony ${{ matrix.symfony-version }} - runs-on: ubuntu-20.04 - continue-on-error: false + runs-on: ubuntu-22.04 strategy: fail-fast: false matrix: @@ -24,7 +25,6 @@ jobs: - '8.1' symfony-version: - '4.4.*' - - '5.3.*' - '5.4.*' - '6.0.*' exclude: @@ -32,29 +32,92 @@ jobs: symfony-version: '6.0.*' steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Setup PHP uses: shivammathur/setup-php@v2 with: coverage: none - ini-values: "memory_limit=-1" + ini-values: "memory_limit=-1, zend.assertions=1" php-version: ${{ matrix.php-version }} tools: composer:v2, flex + # This works around SYMFONY_REQUIRE currently not working (https://github.com/symfony/flex/issues/946): + - name: Lock Symfony version + run: VERSION=${{ matrix.symfony-version }} .github/workflows/lock-symfony-version.sh + + - name: Install dependencies + run: | + composer config --no-plugins allow-plugins.dealerdirect/phpcodesniffer-composer-installer true + composer install --prefer-dist --no-progress --no-plugins + #env: + # SYMFONY_REQUIRE: "${{ matrix.symfony-version }}" + + - name: Run tests + run: composer test + + psalm: + name: Run Psalm + runs-on: ubuntu-22.04 + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + coverage: none + ini-values: "memory_limit=-1, zend.assertions=1" + php-version: 7.4 + tools: composer:v2, flex + + - name: Install dependencies + run: | + composer config --no-plugins allow-plugins.dealerdirect/phpcodesniffer-composer-installer true + composer install --prefer-dist --no-progress --no-plugins + + - name: Run Psalm + run: vendor/bin/psalm src --no-progress + + validate-composer: + name: Validate composer.json + runs-on: ubuntu-22.04 + continue-on-error: false + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + coverage: none + ini-values: "memory_limit=-1, zend.assertions=1" + php-version: 8.1 + tools: composer:v2, flex + - name: Validate composer.json run: composer validate --strict + coding-standards: + name: Validate Coding Standards + runs-on: ubuntu-22.04 + continue-on-error: false + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + coverage: none + ini-values: "memory_limit=-1, zend.assertions=1" + php-version: 8.1 + tools: composer:v2, flex + - name: Install dependencies - run: composer install --prefer-dist --no-progress - env: - SYMFONY_REQUIRE: "${{ matrix.symfony-version }}" + run: | + composer config --no-plugins allow-plugins.dealerdirect/phpcodesniffer-composer-installer true + composer install --prefer-dist --no-progress - name: Run coding standard run: vendor/bin/ecs check --ansi --no-progress-bar src tests - - - name: Run Psalm - run: vendor/bin/psalm src --no-progress --php-version="${{ matrix.php-version }}" - - - name: Run tests - run: composer test diff --git a/.github/workflows/lock-symfony-version.sh b/.github/workflows/lock-symfony-version.sh new file mode 100755 index 0000000..8184271 --- /dev/null +++ b/.github/workflows/lock-symfony-version.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +cat <<< $(jq --indent 4 --arg version $VERSION '.require |= with_entries(if (.key|test("^symfony/")) then .value=$version else . end)' < composer.json) > composer.json +cat <<< $(jq --indent 4 --arg version $VERSION '."require-dev" |= with_entries(if (.key|test("^symfony/")) then .value=$version else . end)' < composer.json) > composer.json diff --git a/composer.json b/composer.json index c684537..6d99ed4 100644 --- a/composer.json +++ b/composer.json @@ -24,7 +24,7 @@ "friends-of-behat/mink-extension": "^2.5", "friends-of-behat/page-object-extension": "^0.3.2", "friends-of-behat/service-container-extension": "^1.1", - "sylius-labs/coding-standard": "^4.1.1", + "sylius-labs/coding-standard": ">=4.1.1, <=4.2.1", "symfony/browser-kit": "^4.4 || ^5.3 || ^6.0", "symfony/framework-bundle": "^4.4 || ^5.3 || ^6.0", "symfony/process": "^4.4 || ^5.3 || ^6.0", diff --git a/features/dependency_injection/autowiring_contexts.feature b/features/dependency_injection/autowiring_contexts.feature index 663bde4..0693509 100644 --- a/features/dependency_injection/autowiring_contexts.feature +++ b/features/dependency_injection/autowiring_contexts.feature @@ -48,6 +48,10 @@ Feature: Autowiring contexts App\Tests\SomeContext: public: true + + # https://github.com/symfony/symfony/pull/35879/ + Psr\Container\ContainerInterface: + alias: service_container """ When I run Behat Then it should pass @@ -128,6 +132,10 @@ Feature: Autowiring contexts App\Tests\: resource: '../tests/*' + + # https://github.com/symfony/symfony/pull/35879/ + Psr\Container\ContainerInterface: + alias: service_container """ When I run Behat Then it should pass @@ -177,4 +185,4 @@ Feature: Autowiring contexts resource: '../tests/*' """ When I run Behat - Then it should pass \ No newline at end of file + Then it should pass diff --git a/src/Context/Environment/Handler/ContextServiceEnvironmentHandler.php b/src/Context/Environment/Handler/ContextServiceEnvironmentHandler.php index 7b9e628..77f4309 100644 --- a/src/Context/Environment/Handler/ContextServiceEnvironmentHandler.php +++ b/src/Context/Environment/Handler/ContextServiceEnvironmentHandler.php @@ -132,7 +132,7 @@ final class ContextServiceEnvironmentHandler implements EnvironmentHandler throw new SuiteConfigurationException(sprintf( '"contexts" setting of the "%s" suite is expected to be an array, %s given.', $suite->getName(), - gettype($contexts) + gettype($contexts), ), $suite->getName()); } @@ -147,7 +147,7 @@ final class ContextServiceEnvironmentHandler implements EnvironmentHandler throw new SuiteConfigurationException(sprintf( '"contexts" setting of the "%s" suite is expected to be an array, %s given.', $suite->getName(), - gettype($contexts) + gettype($contexts), ), $suite->getName()); } @@ -182,7 +182,7 @@ final class ContextServiceEnvironmentHandler implements EnvironmentHandler throw new EnvironmentIsolationException(sprintf( '"%s" does not support isolation of "%s" environment.', static::class, - get_class($uninitializedEnvironment) + get_class($uninitializedEnvironment), ), $uninitializedEnvironment); } } @@ -197,7 +197,7 @@ final class ContextServiceEnvironmentHandler implements EnvironmentHandler get_class($this->symfonyKernel), $this->symfonyKernel->getEnvironment(), $this->symfonyKernel->isDebug() ? 'enabled' : 'disabled', - FriendsOfBehatSymfonyExtensionBundle::class + FriendsOfBehatSymfonyExtensionBundle::class, )); } diff --git a/src/Context/Environment/InitializedSymfonyExtensionEnvironment.php b/src/Context/Environment/InitializedSymfonyExtensionEnvironment.php index 1aa4bf6..1a38591 100644 --- a/src/Context/Environment/InitializedSymfonyExtensionEnvironment.php +++ b/src/Context/Environment/InitializedSymfonyExtensionEnvironment.php @@ -81,7 +81,7 @@ final class InitializedSymfonyExtensionEnvironment implements SymfonyExtensionEn if (!isset($this->contexts[$class])) { throw new ContextNotFoundException(sprintf( '`%s` context is not found in the suite environment. Have you registered it?', - $class + $class, ), $class); } diff --git a/src/Driver/SymfonyDriver.php b/src/Driver/SymfonyDriver.php index da12586..2621c10 100644 --- a/src/Driver/SymfonyDriver.php +++ b/src/Driver/SymfonyDriver.php @@ -19,7 +19,7 @@ final class SymfonyDriver extends BrowserKitDriver 'Please make sure the kernel is using "test" environment or have "framework.test" configuration option enabled.', get_class($kernel), $kernel->getEnvironment(), - $kernel->isDebug() ? 'enabled' : 'disabled' + $kernel->isDebug() ? 'enabled' : 'disabled', )); } @@ -31,7 +31,7 @@ final class SymfonyDriver extends BrowserKitDriver 'Service "test.client" should be an instance of "%s" or "%s", "%s" given.', Client::class, AbstractBrowser::class, - get_class($testClient) + get_class($testClient), )); } diff --git a/src/ServiceContainer/SymfonyExtension.php b/src/ServiceContainer/SymfonyExtension.php index 7431483..2000800 100644 --- a/src/ServiceContainer/SymfonyExtension.php +++ b/src/ServiceContainer/SymfonyExtension.php @@ -222,7 +222,7 @@ final class SymfonyExtension implements Extension if ($autodiscovered !== 1) { throw new \RuntimeException( 'Could not autodiscover the application kernel. ' . - 'Please define it manually with "FriendsOfBehat\SymfonyExtension.kernel" configuration option.' + 'Please define it manually with "FriendsOfBehat\SymfonyExtension.kernel" configuration option.', ); } @@ -260,7 +260,7 @@ final class SymfonyExtension implements Extension throw new \RuntimeException( 'Could not autodiscover the bootstrap file. ' . 'Please define it manually with "FriendsOfBehat\SymfonyExtension.bootstrap" configuration option. ' . - 'Setting that option to "false" disables autodiscovering.' + 'Setting that option to "false" disables autodiscovering.', ); } diff --git a/tests/Behat/Context/TestContext.php b/tests/Behat/Context/TestContext.php index 8bcf1e8..4f72975 100644 --- a/tests/Behat/Context/TestContext.php +++ b/tests/Behat/Context/TestContext.php @@ -310,7 +310,7 @@ YML } throw new \DomainException( - 'Behat was expecting to pass, but failed with the following output:' . \PHP_EOL . \PHP_EOL . $this->getProcessOutput() + 'Behat was expecting to pass, but failed with the following output:' . \PHP_EOL . \PHP_EOL . $this->getProcessOutput(), ); } @@ -333,7 +333,7 @@ YML } throw new \DomainException( - 'Behat was expecting to fail, but passed with the following output:' . \PHP_EOL . \PHP_EOL . $this->getProcessOutput() + 'Behat was expecting to fail, but passed with the following output:' . \PHP_EOL . \PHP_EOL . $this->getProcessOutput(), ); } @@ -371,7 +371,7 @@ YML throw new \DomainException(sprintf( 'Pattern "%s" does not match the following output:' . \PHP_EOL . \PHP_EOL . '%s', $pattern, - $output + $output, )); } }