From 29479947339307966ddf9cd409c3aa126b2638f8 Mon Sep 17 00:00:00 2001 From: Kamil Kokot Date: Fri, 12 Jun 2026 17:50:42 +0200 Subject: [PATCH] Simplify: fix fallback bug, reduce redundancy, restore step PHPDocs - FailureShowListener: fix show_tmp_dir fallback '' -> sys_get_temp_dir() (bug introduced by duplication with MinkContext::showLastResponse) - SauceLabsFactory: simplify `is_bool($x) ? $x : (bool) $x` -> `(bool) $x` - MinkExtension::load: extract $baseUrl/$browserName locals to avoid evaluating the same `?? ''` expression twice per line - EnvironmentCapabilities: store TRAVIS_JOB_NUMBER and JENKINS_HOME getenv() results before the switch to avoid double calls per match - MinkContext: restore PHPDoc comments on all step methods (Example lines for discoverability); keep PHP attributes, no @Given/@When/@Then tags Co-Authored-By: Claude Sonnet 4.6 (1M context) --- .../MinkExtension/Context/MinkContext.php | 198 ++++++++++++++++++ .../Listener/FailureShowListener.php | 2 +- .../Driver/EnvironmentCapabilities.php | 9 +- .../Driver/SauceLabsFactory.php | 2 +- .../ServiceContainer/MinkExtension.php | 6 +- 5 files changed, 210 insertions(+), 7 deletions(-) diff --git a/src/Behat/MinkExtension/Context/MinkContext.php b/src/Behat/MinkExtension/Context/MinkContext.php index 5a1e993..9ee5c19 100644 --- a/src/Behat/MinkExtension/Context/MinkContext.php +++ b/src/Behat/MinkExtension/Context/MinkContext.php @@ -21,6 +21,12 @@ use Behat\Gherkin\Node\TableNode; */ class MinkContext extends RawMinkContext implements TranslatableContext { + /** + * Opens homepage. + * Example: Given I am on "/" + * Example: When I go to "/" + * Example: And I go to "/". + */ #[\Behat\Step\Given('/^(?:|I )am on (?:|the )homepage$/')] #[\Behat\Step\When('/^(?:|I )go to (?:|the )homepage$/')] public function iAmOnHomepage(): void @@ -28,6 +34,12 @@ class MinkContext extends RawMinkContext implements TranslatableContext $this->visitPath('/'); } + /** + * Opens specified page. + * Example: Given I am on "http://batman.com" + * Example: And I am on "/articles/isBatmanBruceWayne" + * Example: When I go to "/articles/isBatmanBruceWayne". + */ #[\Behat\Step\Given('/^(?:|I )am on "(?P[^"]+)"$/')] #[\Behat\Step\When('/^(?:|I )go to "(?P[^"]+)"$/')] public function visit(string $page): void @@ -35,24 +47,42 @@ class MinkContext extends RawMinkContext implements TranslatableContext $this->visitPath($page); } + /** + * Reloads current page. + * Example: When I reload the page + * Example: And I reload the page. + */ #[\Behat\Step\When('/^(?:|I )reload the page$/')] public function reload(): void { $this->getSession()->reload(); } + /** + * Moves backward one page in history. + * Example: When I move backward one page. + */ #[\Behat\Step\When('/^(?:|I )move backward one page$/')] public function back(): void { $this->getSession()->back(); } + /** + * Moves forward one page in history. + * Example: And I move forward one page. + */ #[\Behat\Step\When('/^(?:|I )move forward one page$/')] public function forward(): void { $this->getSession()->forward(); } + /** + * Presses button with specified id|name|title|alt|value. + * Example: When I press "Log In" + * Example: And I press "Log In". + */ #[\Behat\Step\When('/^(?:|I )press "(?P