Skip to content

Commit

Permalink
Add a test.
Browse files Browse the repository at this point in the history
  • Loading branch information
pfrenssen committed Oct 1, 2018
1 parent a5addfa commit 72a9c18
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
6 changes: 6 additions & 0 deletions features/blackbox.feature
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,9 @@ Feature: Test DrupalContext
Given I am on the homepage
When I click "Download & Extend"
Then I should see the link "Distributions"

@scenariotag
Scenario: Check tags on feature and scenario
Then the "scenariotag" tag should be present
And the "blackbox" tag should be present
But the "nonexisting" tag should not be present
30 changes: 30 additions & 0 deletions features/bootstrap/FeatureContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Drupal\DrupalExtension\Context\RawDrupalContext;
use Drupal\DrupalExtension\Hook\Scope\BeforeNodeCreateScope;
use Drupal\DrupalExtension\Hook\Scope\EntityScope;
use Drupal\DrupalExtension\TagTrait;
use Symfony\Component\Process\PhpExecutableFinder;
use Symfony\Component\Process\Process;

Expand All @@ -16,6 +17,9 @@
* conflicts.
*/
class FeatureContext extends RawDrupalContext {

use TagTrait;

/**
* Hook into node creation to test `@beforeNodeCreate`
*
Expand Down Expand Up @@ -419,6 +423,32 @@ public function itShouldFail($success)
}
}

/**
* Checks if the current scenario or feature has the given tag.
*
* @Then the :tag tag should be present
*
* @param string $tag
* The tag to check.
*/
public function shouldHaveTag($tag)
{
PHPUnit_Framework_Assert::assertTrue($this->hasTag($tag));
}

/**
* Checks if the current scenario or feature does not have the given tag.
*
* @Then the :tag tag should not be present
*
* @param string $tag
* The tag to check.
*/
public function shouldNotHaveTag($tag)
{
PHPUnit_Framework_Assert::assertFalse($this->hasTag($tag));
}

private function getExitCode()
{
return $this->process->getExitCode();
Expand Down

0 comments on commit 72a9c18

Please sign in to comment.