From ed4c70abf55830073ba1025cbee7085e7590d267 Mon Sep 17 00:00:00 2001 From: Ilias Dimopoulos Date: Tue, 5 Feb 2019 00:32:47 +0200 Subject: [PATCH 1/3] Provide a step to check that a button is not in a region. --- .../DrupalExtension/Context/MarkupContext.php | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/Drupal/DrupalExtension/Context/MarkupContext.php b/src/Drupal/DrupalExtension/Context/MarkupContext.php index 08179f7b..fb6afc2c 100644 --- a/src/Drupal/DrupalExtension/Context/MarkupContext.php +++ b/src/Drupal/DrupalExtension/Context/MarkupContext.php @@ -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) */ From 2002f6e5170d936dbda73e637a800f06d231357b Mon Sep 17 00:00:00 2001 From: Ilias Dimopoulos Date: Tue, 5 Feb 2019 13:20:59 +0200 Subject: [PATCH 2/3] Provide a test for the assert_not_button_in_region. --- features/blackbox.feature | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/features/blackbox.feature b/features/blackbox.feature index be28ae70..1d0f6dd1 100644 --- a/features/blackbox.feature +++ b/features/blackbox.feature @@ -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 "content" 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" From d3db9fcdf28871c7e8d4f180d82bf4bd2306bc4d Mon Sep 17 00:00:00 2001 From: Ilias Dimopoulos Date: Wed, 6 Feb 2019 12:17:20 +0200 Subject: [PATCH 3/3] Change the name of the region for an existing one. --- features/blackbox.feature | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/features/blackbox.feature b/features/blackbox.feature index 1d0f6dd1..25c3706a 100644 --- a/features/blackbox.feature +++ b/features/blackbox.feature @@ -43,7 +43,7 @@ Feature: Test DrupalContext Scenario: Button not in region Given I am on the homepage - Then I should not see the "Search" button in the "content" region + 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