diff --git a/src/Behat/Gherkin/Keywords/CachedArrayKeywords.php b/src/Behat/Gherkin/Keywords/CachedArrayKeywords.php index 71220132..f1ca123b 100644 --- a/src/Behat/Gherkin/Keywords/CachedArrayKeywords.php +++ b/src/Behat/Gherkin/Keywords/CachedArrayKeywords.php @@ -19,6 +19,11 @@ */ class CachedArrayKeywords extends ArrayKeywords { + public static function withDefaultKeywords(): self + { + return new self(__DIR__ . '/../../../../i18n.php'); + } + /** * Initializes holder with file. * @@ -26,6 +31,6 @@ class CachedArrayKeywords extends ArrayKeywords */ public function __construct($file) { - parent::__construct(include $file); + parent::__construct(require $file); } } diff --git a/tests/Behat/Gherkin/Keywords/CachedArrayKeywordsTest.php b/tests/Behat/Gherkin/Keywords/CachedArrayKeywordsTest.php index 09809418..159b76f4 100644 --- a/tests/Behat/Gherkin/Keywords/CachedArrayKeywordsTest.php +++ b/tests/Behat/Gherkin/Keywords/CachedArrayKeywordsTest.php @@ -17,12 +17,13 @@ class CachedArrayKeywordsTest extends KeywordsTestCase { protected function getKeywords() { - return new CachedArrayKeywords(__DIR__ . '/../../../../i18n.php'); + // Test with the default i18n file provided in this repository + return CachedArrayKeywords::withDefaultKeywords(); } protected function getKeywordsArray() { - return include __DIR__ . '/../../../../i18n.php'; + return require __DIR__ . '/../../../../i18n.php'; } protected function getSteps($keywords, $text, &$line, $keywordType)