diff --git a/spec/Behat/MinkExtension/Listener/SessionsListenerSpec.php b/spec/Behat/MinkExtension/Listener/SessionsListenerSpec.php index 8bd31fd..aedbe43 100644 --- a/spec/Behat/MinkExtension/Listener/SessionsListenerSpec.php +++ b/spec/Behat/MinkExtension/Listener/SessionsListenerSpec.php @@ -2,7 +2,7 @@ namespace spec\Behat\MinkExtension\Listener; -use Behat\Behat\Tester\Event\ScenarioTested; +use Behat\Behat\EventDispatcher\Event\ScenarioTested; use Behat\Gherkin\Node\FeatureNode; use Behat\Gherkin\Node\ScenarioNode; use Behat\Mink\Mink; diff --git a/src/Behat/MinkExtension/Listener/FailureShowListener.php b/src/Behat/MinkExtension/Listener/FailureShowListener.php index 92a22f2..3e8a0d3 100644 --- a/src/Behat/MinkExtension/Listener/FailureShowListener.php +++ b/src/Behat/MinkExtension/Listener/FailureShowListener.php @@ -10,8 +10,9 @@ namespace Behat\MinkExtension\Listener; -use Behat\Behat\Tester\Event\StepTested; -use Behat\Testwork\Tester\Result\TestResult; +use Behat\Behat\EventDispatcher\Event\AfterStepTested; +use Behat\Behat\EventDispatcher\Event\StepTested; +use Behat\Testwork\Tester\Result\ExceptionResult; use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Behat\Mink\Mink; use Behat\Mink\Exception\Exception as MinkException; @@ -51,21 +52,26 @@ class FailureShowListener implements EventSubscriberInterface /** * Shows last response of failed step with preconfigured command. + * * Configuration is based on `behat.yml`: * * `show_auto` enable this listener (default to false) * `show_cmd` command to run (`open %s` to open default browser on Mac) * `show_tmp_dir` folder where to store temp files (default is system temp) * - * @param StepTested $event + * @param AfterStepTested $event + * + * @throws \RuntimeException if show_cmd is not configured */ - public function showFailedStepResponse(StepTested $event) + public function showFailedStepResponse(AfterStepTested $event) { - if (TestResult::FAILED !== $event->getResultCode()) { + $testResult = $event->getTestResult(); + + if (!$testResult instanceof ExceptionResult) { return; } - if (!$event->getTestResult()->getException() instanceof MinkException) { + if (!$testResult->getException() instanceof MinkException) { return; } diff --git a/src/Behat/MinkExtension/Listener/SessionsListener.php b/src/Behat/MinkExtension/Listener/SessionsListener.php index 9c9d08a..f372918 100644 --- a/src/Behat/MinkExtension/Listener/SessionsListener.php +++ b/src/Behat/MinkExtension/Listener/SessionsListener.php @@ -10,12 +10,12 @@ namespace Behat\MinkExtension\Listener; -use Behat\Behat\Tester\Event\AbstractScenarioTested; -use Behat\Behat\Tester\Event\ExampleTested; -use Behat\Behat\Tester\Event\ScenarioTested; +use Behat\Behat\EventDispatcher\Event\ExampleTested; +use Behat\Behat\EventDispatcher\Event\ScenarioLikeTested; +use Behat\Behat\EventDispatcher\Event\ScenarioTested; use Behat\Mink\Mink; +use Behat\Testwork\EventDispatcher\Event\ExerciseCompleted; use Behat\Testwork\ServiceContainer\Exception\ProcessingException; -use Behat\Testwork\Tester\Event\ExerciseCompleted; use Symfony\Component\EventDispatcher\EventSubscriberInterface; /** @@ -67,11 +67,11 @@ class SessionsListener implements EventSubscriberInterface * `@insulated` tag will cause Mink to stop current sessions before scenario * instead of just soft-resetting them * - * @param AbstractScenarioTested $event + * @param ScenarioLikeTested $event * * @throws ProcessingException when the @javascript tag is used without a javascript session */ - public function prepareDefaultMinkSession(AbstractScenarioTested $event) + public function prepareDefaultMinkSession(ScenarioLikeTested $event) { $scenario = $event->getScenario(); $feature = $event->getFeature();