Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide a step to check that a button is not in a region. #527

Merged
merged 3 commits into from
Feb 6, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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