Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use hardcoded path to i18n file if not provided #290

Open
wants to merge 3 commits into
base: release-4.12.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/Behat/Gherkin/Keywords/CachedArrayKeywords.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,18 @@
*/
class CachedArrayKeywords extends ArrayKeywords
{
public static function withDefaultKeywords(): self
{
return new self(__DIR__ . '/../../../../i18n.php');
}

/**
* Initializes holder with file.
*
* @param string $file Cached array path
*/
public function __construct($file)
{
parent::__construct(include $file);
parent::__construct(require $file);
}
}
5 changes: 3 additions & 2 deletions tests/Behat/Gherkin/Keywords/CachedArrayKeywordsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading