From 98d874767be1bd26c821d210768d3fe59e7dda69 Mon Sep 17 00:00:00 2001 From: Adam Bramley Date: Thu, 21 Apr 2016 14:11:59 +1000 Subject: [PATCH 1/3] Implement new step definition. --- src/Drupal/DrupalExtension/Context/DrupalContext.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/Drupal/DrupalExtension/Context/DrupalContext.php b/src/Drupal/DrupalExtension/Context/DrupalContext.php index 41c7d740..10a25d9e 100644 --- a/src/Drupal/DrupalExtension/Context/DrupalContext.php +++ b/src/Drupal/DrupalExtension/Context/DrupalContext.php @@ -179,6 +179,18 @@ public function assertTextInTableRow($text, $rowText) { } } + /** + * Asset text not in a table row containing given text. + * + * @Then I should not see (the text ):text in the :rowText row + */ + public function assertTextNotInTableRow($text, $rowText) { + $row = $this->getTableRow($this->getSession()->getPage(), $rowText); + if (strpos($row->getText(), $text) !== FALSE) { + throw new \Exception(sprintf('Found a row containing "%s", but it contained the text "%s".', $rowText, $text)); + } + } + /** * Attempts to find a link in a table row containing giving text. This is for * administrative pages such as the administer content types screen found at From 3fc39163f2b1b0613f2b5d82a7d359ffdf5f46c1 Mon Sep 17 00:00:00 2001 From: Adam Bramley Date: Thu, 21 Apr 2016 14:12:07 +1000 Subject: [PATCH 2/3] Add step def to tests. --- features/api.feature | 12 ++++++++---- features/d8.feature | 1 + 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/features/api.feature b/features/api.feature index 054f633b..5fec342f 100644 --- a/features/api.feature +++ b/features/api.feature @@ -106,20 +106,24 @@ Feature: DrupalContext @d7 Scenario: Create users with roles Given users: - | name | mail | roles | - | Joe User | joe@example.com | administrator | + | name | mail | roles | + | Joe User | joe@example.com | administrator | + | Jane User | jane@example.com | | And I am logged in as a user with the "administrator" role When I visit "admin/people" Then I should see the text "administrator" in the "Joe User" row + And I should not see the text "administrator" in the "Jane User" row @d8 Scenario: Create users with roles Given users: - | name | mail | roles | - | Joe User | joe@example.com | administrator | + | name | mail | roles | + | Joe User | joe@example.com | administrator | + | Jane User | jane@example.com | | And I am logged in as a user with the "administrator" role When I visit "admin/people" Then I should see the text "Administrator" in the "Joe User" row + And I should not see the text "administrator" in the "Jane User" row @d7 @d8 Scenario: Login as a user created during this scenario diff --git a/features/d8.feature b/features/d8.feature index 6b625e83..9032a7d9 100644 --- a/features/d8.feature +++ b/features/d8.feature @@ -24,6 +24,7 @@ Feature: DrupalContext And I am logged in as a user with the "administrator" role When I visit "admin/people" Then I should see the text "Administrator" in the "Joe User" row + And I should not see the text "administrator" in the "Jane User" row Scenario: Find a heading in a region Given I am not logged in From 0f4556ac5adf3e8f88ce474fe3f2b1e3e3c5771a Mon Sep 17 00:00:00 2001 From: Adam Bramley Date: Thu, 21 Apr 2016 14:37:32 +1000 Subject: [PATCH 3/3] Fix user name in test. --- features/d8.feature | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/features/d8.feature b/features/d8.feature index 9032a7d9..d079c60a 100644 --- a/features/d8.feature +++ b/features/d8.feature @@ -24,7 +24,7 @@ Feature: DrupalContext And I am logged in as a user with the "administrator" role When I visit "admin/people" Then I should see the text "Administrator" in the "Joe User" row - And I should not see the text "administrator" in the "Jane User" row + And I should not see the text "administrator" in the "Jane Doe" row Scenario: Find a heading in a region Given I am not logged in