Skip to content

Commit

Permalink
Merge branch 'master' into throw-helpful-exception-for-ajax-timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
jhedstrom authored Mar 13, 2019
2 parents 0f6ed6a + 2938b26 commit dbb2a0c
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
### Changed
* [#528](https://github.com/jhedstrom/drupalextension/pull/528) Show a more helpful failure when running `@javascript`
scenarios with incorrect configuration.
### Added
* [#527](https://github.com/jhedstrom/drupalextension/pull/527) Provide a step to check that a button is not in a region.
## [4.0.0 beta2] 2018-12-19
### Added
* [#514](https://github.com/jhedstrom/drupalextension/pull/514) Add a note about the need to remove the entries in behat.yml to use BEHAT_PARAMS.
Expand Down
4 changes: 4 additions & 0 deletions features/blackbox.feature
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ Feature: Test DrupalContext
Given I am on the homepage
Then I should see the "Search" button in the "navigation"

Scenario: Button not in region
Given I am on the homepage
Then I should not see the "Search" button in the "right header" region

Scenario: Find an element in a region
Given I am on the homepage
Then I should see the "h1" element in the "left header"
Expand Down
24 changes: 24 additions & 0 deletions src/Drupal/DrupalExtension/Context/MarkupContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,30 @@ public function assertRegionButton($button, $region)
}
}

/**
* Asserts that a button does not exists in a region.
*
* @Then I should not see the button :button in the :region( region)
* @Then I should not see the :button button in the :region( region)
*
* @param $button
* string The id|name|title|alt|value of the button
* @param $region
* string The region in which the button should not be found
*
* @throws \Exception
* If region is not found or the button is found within the region.
*/
public function assertNotRegionButton($button, $region)
{
$regionObj = $this->getRegion($region);

$buttonObj = $regionObj->findButton($button);
if (!empty($buttonObj)) {
throw new \Exception(sprintf("The button '%s' was found in the region '%s' on the page %s but should not", $button, $region, $this->getSession()->getCurrentUrl()));
}
}

/**
* @Then I( should) see the :tag element in the :region( region)
*/
Expand Down

0 comments on commit dbb2a0c

Please sign in to comment.