Skip to content

Commit

Permalink
Merge pull request #273 from acbramley/Issue#272-not-in-row
Browse files Browse the repository at this point in the history
Provides "not in row" step definition and tests
  • Loading branch information
jhedstrom committed Jun 9, 2016
2 parents a36adfc + 0f4556a commit 917a380
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
12 changes: 8 additions & 4 deletions features/api.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions features/d8.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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 Doe" row

Scenario: Find a heading in a region
Given I am not logged in
Expand Down
12 changes: 12 additions & 0 deletions src/Drupal/DrupalExtension/Context/DrupalContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 917a380

Please sign in to comment.