From a63b17e180b4c4b78f233f1636d4d2f7d5c20693 Mon Sep 17 00:00:00 2001 From: victor-aston Date: Wed, 27 Nov 2024 16:51:57 +0200 Subject: [PATCH] PhpUnit 11 (#17) * #1118: Added PhpUnit 10 and Symfony 7 requirements for composer.json. Updated CI tests to test PHPUnit 10 version for latest PHP 8.x versions. Co-authored-by: Yevhen Korniievskyi Co-authored-by: AstonVictor --- .github/workflows/ci.yml | 19 ++++++++++--------- composer.json | 4 ++-- src/TestTraits/BehatProvidingTrait.php | 12 ++++++------ src/TestTraits/BehatTestTrait.php | 6 +++--- tests/BehatProvidingTraitTest.php | 2 +- 5 files changed, 22 insertions(+), 21 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 55ff60e..2f496b2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,27 +1,27 @@ name: CI -on: [push, pull_request] +on: + - push + - pull_request jobs: build-test: runs-on: ubuntu-latest strategy: matrix: - phpunit: [6.5.13, 7.5.18, 8.5.31, 9.5.26] - php: [7.3, 7.4] include: - - phpunit: 8.5.31 - php: 8.0 - phpunit: 9.5.26 - php: 8.0 + php: 8.2 - phpunit: 9.5.26 - php: 8.1 - - phpunit: 10.5.38 - php: 8.1 + php: 8.3 - phpunit: 10.5.38 php: 8.2 - phpunit: 10.5.38 php: 8.3 + - phpunit: 11.4.3 + php: 8.2 + - phpunit: 11.4.3 + php: 8.3 steps: - uses: actions/checkout@v3 @@ -35,3 +35,4 @@ jobs: with: php_version: ${{ matrix.php }} version: ${{ matrix.phpunit }} + test_suffix: "Test.php" diff --git a/composer.json b/composer.json index fdb8936..cea8466 100644 --- a/composer.json +++ b/composer.json @@ -11,8 +11,8 @@ } ], "require": { - "php": "^7.0 || ^8.0", - "phpunit/phpunit": "^6.0 || ^7.0 || ^8.0 || ^9.0 || ^10", + "php": "^8.2 || ^8.3", + "phpunit/phpunit": "^9.0 || ^10 || ^11", "behat/behat": "^3.0.0", "symfony/dependency-injection": "^4.0 || ^5.0 || ^6.0 || ^7.0" }, diff --git a/src/TestTraits/BehatProvidingTrait.php b/src/TestTraits/BehatProvidingTrait.php index 5f7ca20..e80d939 100644 --- a/src/TestTraits/BehatProvidingTrait.php +++ b/src/TestTraits/BehatProvidingTrait.php @@ -24,8 +24,8 @@ trait BehatProvidingTrait { * @return Behat\Gherkin\Node\FeatureNode * A Behat feature. */ - public function parseBehatFeature($featureString, $keywords = NULL) { - $lexer = new Lexer($this->getBehatKeywords($keywords)); + public static function parseBehatFeature($featureString, $keywords = NULL) { + $lexer = new Lexer(self::getBehatKeywords($keywords)); $parser = new Parser($lexer); $feature = $parser->parse($featureString); return $feature; @@ -46,7 +46,7 @@ public function parseBehatFeature($featureString, $keywords = NULL) { * @return array * An array of scenarios, each an array of title, scenario, and feature. */ - public function provideBehatFeature(FeatureNode $feature) { + public static function provideBehatFeature(FeatureNode $feature) { $scenarios = []; foreach ($feature->getScenarios() as $scenario) { if ($scenario instanceof OutlineNode) { @@ -69,9 +69,9 @@ public function provideBehatFeature(FeatureNode $feature) { * * @return \Behat\Gherkin\Keywords\ArrayKeywords */ - protected function getBehatKeywords($keywords = NULL) { + protected static function getBehatKeywords($keywords = NULL) { if (is_null($keywords)) { - $keywords = $this->getBehatDefaultKeywords(); + $keywords = self::getBehatDefaultKeywords(); } return $keywords; } @@ -81,7 +81,7 @@ protected function getBehatKeywords($keywords = NULL) { * * @return \Behat\Gherkin\Keywords\ArrayKeywords */ - public function getBehatDefaultKeywords() { + public static function getBehatDefaultKeywords() { return new ArrayKeywords([ 'en' => [ 'feature' => 'Feature', diff --git a/src/TestTraits/BehatTestTrait.php b/src/TestTraits/BehatTestTrait.php index 84f73ec..6e7a48b 100644 --- a/src/TestTraits/BehatTestTrait.php +++ b/src/TestTraits/BehatTestTrait.php @@ -13,9 +13,9 @@ trait BehatTestTrait { * Parses the ::feature property as a Behat feature, * breaking it down into individual scenarios for testing. */ - public function providerTestBehatScenario() { - $feature = $this->parseBehatFeature($this->feature); - return $this->provideBehatFeature($feature); + public static function providerTestBehatScenario() { + $feature = self::parseBehatFeature(self::$feature); + return self::provideBehatFeature($feature); } /** diff --git a/tests/BehatProvidingTraitTest.php b/tests/BehatProvidingTraitTest.php index 4259518..f3bd301 100644 --- a/tests/BehatProvidingTraitTest.php +++ b/tests/BehatProvidingTraitTest.php @@ -14,7 +14,7 @@ class BehatProvidingTraitTest extends TestCase { use BehatTestTrait; - protected $feature = <<<'FEATURE' + protected static $feature = <<<'FEATURE' Feature: BehatProvidingTrait In order to test a feature We need to able provide it to phpunit