From 39f8f364979433eb58f55574ada608e6dfcc2799 Mon Sep 17 00:00:00 2001 From: Dieter Beck Date: Wed, 7 May 2025 14:20:09 +0200 Subject: [PATCH 1/2] Fix loading keywords in behat/gherkin v4.12 (#6839) (#6855) (cherry picked from commit d7b88e7f89a970a0f6336ca579bb681461817271) --- composer.json | 2 +- src/Codeception/Test/Loader/Gherkin.php | 8 ++------ 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/composer.json b/composer.json index 2df065bcb2..9bfd4b3bc6 100644 --- a/composer.json +++ b/composer.json @@ -19,7 +19,7 @@ "ext-curl": "*", "ext-json": "*", "ext-mbstring": "*", - "behat/gherkin": "^4.6.2", + "behat/gherkin": "^4.12", "codeception/lib-asserts": "^2.0", "codeception/stub": "^4.1", "phpunit/phpunit": "^9.5.20 || ^10.0 || ^11.0 || ^12.0", diff --git a/src/Codeception/Test/Loader/Gherkin.php b/src/Codeception/Test/Loader/Gherkin.php index 1c0a9bc65b..efdc0c9f10 100644 --- a/src/Codeception/Test/Loader/Gherkin.php +++ b/src/Codeception/Test/Loader/Gherkin.php @@ -5,7 +5,7 @@ namespace Codeception\Test\Loader; use Behat\Gherkin\Filter\RoleFilter; -use Behat\Gherkin\Keywords\ArrayKeywords as GherkinKeywords; +use Behat\Gherkin\Keywords\CachedArrayKeywords as GherkinKeywords; use Behat\Gherkin\Lexer as GherkinLexer; use Behat\Gherkin\Node\ExampleNode; use Behat\Gherkin\Node\FeatureNode; @@ -24,7 +24,6 @@ use function array_map; use function array_merge; use function class_exists; -use function dirname; use function file_get_contents; use function get_class_methods; use function glob; @@ -72,10 +71,7 @@ public function __construct(array $settings = []) if (!class_exists(GherkinKeywords::class)) { throw new TestParseException('Feature file can only be parsed with Behat\Gherkin library. Please install `behat/gherkin` with Composer'); } - $gherkin = new ReflectionClass(\Behat\Gherkin\Gherkin::class); - $gherkinClassPath = dirname($gherkin->getFileName()); - $i18n = require $gherkinClassPath . '/../../../i18n.php'; - $keywords = new GherkinKeywords($i18n); + $keywords = GherkinKeywords::withDefaultKeywords(); $lexer = new GherkinLexer($keywords); $this->parser = new GherkinParser($lexer); $this->fetchGherkinSteps(); From 7d5e5b8736ee8eb9a3f08323a65fd7935270c8d1 Mon Sep 17 00:00:00 2001 From: Gustavo Nieves Date: Wed, 7 May 2025 07:48:28 -0500 Subject: [PATCH 2/2] 5.2.2 --- CHANGELOG-5.x.md | 21 +++++++++++++++++++++ src/Codeception/Codecept.php | 2 +- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/CHANGELOG-5.x.md b/CHANGELOG-5.x.md index f37f3609c9..9721c47c39 100644 --- a/CHANGELOG-5.x.md +++ b/CHANGELOG-5.x.md @@ -1,3 +1,24 @@ +#### 5.3.0 + +* Update readme.md by @rossaddison in #6834 +* Fix loading keywords in behat/gherkin v4.12 by @W0rma in #6839 +* Update Scenario.php: Adding default value to current() by @ThomasLandauer in #6798 +* Simplify Step classes by @TavoNiievez in #6842 +* Simplify reporter classes by @TavoNiievez in #6803 +* Simplify Subscriber classes by @TavoNiievez in #6843 +* Fix AssertsTest CI pipeline by @W0rma in #6847 +* Simplify Test classes by @TavoNiievez in #6845 +* Simplify Template classes by @TavoNiievez in #6844 +* Simplify Util classes by @TavoNiievez in #6846 +* Simplify src root classes by @TavoNiievez in #6849 +* Remove PHP 8.1 support by @TavoNiievez in #6848 +* Migrate commands to use AsCommand attribute by @TavoNiievez in #6850 +* Add PHPStan integration by @TavoNiievez in #6851 + +#### 5.2.2 + +* Fix loading keywords in behat/gherkin v4.12 by @W0rma in #6855 + #### 5.2.1 * Support PHPUnit 12 by @W0rma in #6826 diff --git a/src/Codeception/Codecept.php b/src/Codeception/Codecept.php index 03536fb574..9f6b06ee5a 100644 --- a/src/Codeception/Codecept.php +++ b/src/Codeception/Codecept.php @@ -36,7 +36,7 @@ class Codecept /** * @var string */ - public const VERSION = '5.2.1'; + public const VERSION = '5.2.2'; protected ResultAggregator $resultAggregator;