Move stepHasTag to trait

This commit is contained in:
Damian Mooyman 2017-08-02 11:28:18 +12:00
parent cf49da1926
commit c1bac8baae
No known key found for this signature in database
GPG Key ID: 78B823A10DE27D1A
2 changed files with 23 additions and 24 deletions

View File

@ -6,10 +6,8 @@ use Behat\Behat\Context\Context;
use Behat\Behat\Definition\Call;
use Behat\Behat\Hook\Scope\AfterScenarioScope;
use Behat\Behat\Hook\Scope\AfterStepScope;
use Behat\Behat\Hook\Scope\BeforeScenarioScope;
use Behat\Behat\Hook\Scope\BeforeStepScope;
use Behat\Behat\Hook\Scope\StepScope;
use Behat\Gherkin\Node\ScenarioNode;
use Behat\Mink\Driver\Selenium2Driver;
use Behat\Mink\Element\NodeElement;
use Behat\Mink\Session;
@ -1225,26 +1223,4 @@ JS;
{
file_put_contents('php://stderr', 'Exception caught: ' . $exception->getMessage());
}
/**
* Check if a step has a given tag
*
* @param StepScope $event
* @param string $tag
* @return bool
*/
protected function stepHasTag(StepScope $event, $tag)
{
// Check feature
$feature = $event->getFeature();
if ($feature && $feature->hasTag($tag)) {
return true;
}
// Check scenario
$scenario = $this->getStepScenario($feature, $event->getStep());
if ($scenario && $scenario->hasTag($tag)) {
return true;
}
return false;
}
}

View File

@ -2,6 +2,7 @@
namespace SilverStripe\BehatExtension\Utility;
use Behat\Behat\Hook\Scope\StepScope;
use Behat\Gherkin\Node\FeatureNode;
use Behat\Gherkin\Node\NodeInterface;
use Behat\Gherkin\Node\ScenarioInterface;
@ -60,4 +61,26 @@ trait StepHelper
} while (--$timeout >= 0);
throw $firstEx;
}
/**
* Check if a step has a given tag
*
* @param StepScope $event
* @param string $tag
* @return bool
*/
protected function stepHasTag(StepScope $event, $tag)
{
// Check feature
$feature = $event->getFeature();
if ($feature && $feature->hasTag($tag)) {
return true;
}
// Check scenario
$scenario = $this->getStepScenario($feature, $event->getStep());
if ($scenario && $scenario->hasTag($tag)) {
return true;
}
return false;
}
}