Updated the listeners to use the new event classes

This commit is contained in:
Christophe Coevoet
2014-03-12 03:09:00 +01:00
parent f74ba60ff3
commit faaa8cc7fe
3 changed files with 19 additions and 13 deletions

View File

@@ -2,7 +2,7 @@
namespace spec\Behat\MinkExtension\Listener; 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\FeatureNode;
use Behat\Gherkin\Node\ScenarioNode; use Behat\Gherkin\Node\ScenarioNode;
use Behat\Mink\Mink; use Behat\Mink\Mink;

View File

@@ -10,8 +10,9 @@
namespace Behat\MinkExtension\Listener; namespace Behat\MinkExtension\Listener;
use Behat\Behat\Tester\Event\StepTested; use Behat\Behat\EventDispatcher\Event\AfterStepTested;
use Behat\Testwork\Tester\Result\TestResult; use Behat\Behat\EventDispatcher\Event\StepTested;
use Behat\Testwork\Tester\Result\ExceptionResult;
use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Behat\Mink\Mink; use Behat\Mink\Mink;
use Behat\Mink\Exception\Exception as MinkException; use Behat\Mink\Exception\Exception as MinkException;
@@ -51,21 +52,26 @@ class FailureShowListener implements EventSubscriberInterface
/** /**
* Shows last response of failed step with preconfigured command. * Shows last response of failed step with preconfigured command.
*
* Configuration is based on `behat.yml`: * Configuration is based on `behat.yml`:
* *
* `show_auto` enable this listener (default to false) * `show_auto` enable this listener (default to false)
* `show_cmd` command to run (`open %s` to open default browser on Mac) * `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) * `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; return;
} }
if (!$event->getTestResult()->getException() instanceof MinkException) { if (!$testResult->getException() instanceof MinkException) {
return; return;
} }

View File

@@ -10,12 +10,12 @@
namespace Behat\MinkExtension\Listener; namespace Behat\MinkExtension\Listener;
use Behat\Behat\Tester\Event\AbstractScenarioTested; use Behat\Behat\EventDispatcher\Event\ExampleTested;
use Behat\Behat\Tester\Event\ExampleTested; use Behat\Behat\EventDispatcher\Event\ScenarioLikeTested;
use Behat\Behat\Tester\Event\ScenarioTested; use Behat\Behat\EventDispatcher\Event\ScenarioTested;
use Behat\Mink\Mink; use Behat\Mink\Mink;
use Behat\Testwork\EventDispatcher\Event\ExerciseCompleted;
use Behat\Testwork\ServiceContainer\Exception\ProcessingException; use Behat\Testwork\ServiceContainer\Exception\ProcessingException;
use Behat\Testwork\Tester\Event\ExerciseCompleted;
use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\EventDispatcher\EventSubscriberInterface;
/** /**
@@ -67,11 +67,11 @@ class SessionsListener implements EventSubscriberInterface
* `@insulated` tag will cause Mink to stop current sessions before scenario * `@insulated` tag will cause Mink to stop current sessions before scenario
* instead of just soft-resetting them * instead of just soft-resetting them
* *
* @param AbstractScenarioTested $event * @param ScenarioLikeTested $event
* *
* @throws ProcessingException when the @javascript tag is used without a javascript session * @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(); $scenario = $event->getScenario();
$feature = $event->getFeature(); $feature = $event->getFeature();